uranusjr commented on code in PR #58289:
URL: https://github.com/apache/airflow/pull/58289#discussion_r2555244934
##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -458,6 +471,45 @@ def decode_timetable(var: dict[str, Any]) -> Timetable:
return timetable_class.deserialize(var[Encoding.VAR])
+def _load_partition_mapper(importable_string) -> PartitionMapper | None:
+ if importable_string.startswith("airflow.timetables."):
+ return import_string(importable_string)
+ else:
+ return None
+
+
+def encode_partition_mapper(var: PartitionMapper) -> dict[str, Any]:
+ """
+ Encode a PartitionMapper instance.
+
+ This delegates most of the serialization work to the type, so the behavior
+ can be completely controlled by a custom subclass.
+
+ :meta private:
+ """
+ partition_mapper_class = type(var)
+ importable_string = qualname(partition_mapper_class)
+ if _load_partition_mapper(importable_string) is None:
+ raise _PartitionMapperNotFound(importable_string)
Review Comment:
Why do we need to check this? Isn’t the mapper guarenteed to exist since we
just accepted an instance `var`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]