Repository navigation
Use BaseXCom serialize_value when objectstorage_threshold is less than given input #49173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b5a6e87
af98bd7
63d7179
f18de86
f04fa85
1ecfa3f
a7ebc36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,8 +118,7 @@ def serialize_value( # type: ignore[override] | |
| run_id: str | None = None, | ||
| map_index: int | None = None, | ||
| ) -> bytes | str: | ||
| # we will always serialize ourselves and not by BaseXCom as the deserialize method | ||
| # from BaseXCom accepts only XCom objects and not the value directly | ||
| # We will use this serialized value to write to the object store. | ||
| s_val = json.dumps(value, cls=XComEncoder) | ||
| s_val_encoded = s_val.encode("utf-8") | ||
|
|
||
|
|
@@ -131,7 +130,7 @@ def serialize_value( # type: ignore[override] | |
| threshold = _get_threshold() | ||
| if threshold < 0 or len(s_val_encoded) < threshold: # Either no threshold or value is small enough. | ||
| if AIRFLOW_V_3_0_PLUS: | ||
| return s_val | ||
| return BaseXCom.serialize_value(value) | ||
| else: | ||
| # TODO: Remove this branch once we drop support for Airflow 2 | ||
| # This is for Airflow 2.10 where the value is expected to be bytes | ||
|
|
@@ -160,9 +159,18 @@ def deserialize_value(result) -> Any: | |
|
|
||
| Compression is inferred from the file extension. | ||
| """ | ||
| data = BaseXCom.deserialize_value(result) | ||
| base_xcom_deser_result = BaseXCom.deserialize_value(result) | ||
| data = base_xcom_deser_result | ||
|
|
||
| if not AIRFLOW_V_3_0_PLUS: | ||
| try: | ||
| # When XComObjectStorageBackend is used, xcom value will be serialized using json.dumps | ||
| # likely, we need to deserialize it using json.loads | ||
| data = json.loads(base_xcom_deser_result, cls=XComDecoder) | ||
| except (TypeError, ValueError): | ||
| pass | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we re raise this one?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is fine, this raises error happen only when base_xcom_deser_result is object store path, likely this is string that means we should continue to next below to read from ObjectStore with path. WDYT?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep seems ok |
||
| try: | ||
| path = XComObjectStorageBackend._get_full_path(data) | ||
| path = XComObjectStorageBackend._get_full_path(base_xcom_deser_result) | ||
| except (TypeError, ValueError): # Likely value stored directly in the database. | ||
| return data | ||
| try: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.