-
Couldn't load subscription status.
- Fork 15.9k
AIP-44 Support TaskInstance serialization/deserialization. #29355
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
ac84238
731ac67
f534463
3c45f85
20b9652
9e95c51
fbe02ce
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 |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ | |
| from airflow.models.mappedoperator import MappedOperator | ||
| from airflow.models.operator import Operator | ||
| from airflow.models.param import Param, ParamsDict | ||
| from airflow.models.taskinstance import SimpleTaskInstance | ||
| from airflow.models.taskinstance import SimpleTaskInstance, TaskInstance | ||
| from airflow.models.taskmixin import DAGNode | ||
| from airflow.models.xcom_arg import XComArg, deserialize_xcom_arg, serialize_xcom_arg | ||
| from airflow.providers_manager import ProvidersManager | ||
|
|
@@ -448,6 +448,10 @@ def serialize( | |
| return cls._encode(dict(uri=var.uri, extra=var.extra), type_=DAT.DATASET) | ||
| elif isinstance(var, SimpleTaskInstance): | ||
| return cls._encode(cls.serialize(var.__dict__, strict=strict), type_=DAT.SIMPLE_TASK_INSTANCE) | ||
| elif isinstance(var, TaskInstance): | ||
| # FIXME: We can't use var.serialize() there due to problems in test | ||
| # test_recursive_serialize_calls_must_forward_kwargs | ||
| return cls._encode(cls.serialize(var=var.to_dict(), strict=strict), type_=DAT.TASK_INSTANCE) | ||
| else: | ||
| log.debug("Cast type %s to str in serialization.", type(var)) | ||
| if strict: | ||
|
|
@@ -502,6 +506,8 @@ def deserialize(cls, encoded_var: Any) -> Any: | |
| return Dataset(**var) | ||
| elif type_ == DAT.SIMPLE_TASK_INSTANCE: | ||
| return SimpleTaskInstance(**cls.deserialize(var)) | ||
| elif type_ == DAT.TASK_INSTANCE: | ||
|
||
| return TaskInstance.deserialize(ti_dict=cls.deserialize(var), version=1) | ||
| else: | ||
| raise TypeError(f"Invalid type {type_!s} in deserialization.") | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.