Skip to content

Commit

Permalink
update tests and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
clairelin135 committed Nov 9, 2023
1 parent ec491b2 commit 0b5fa15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class TimeWindow(NamedTuple):
end: PublicAttr[datetime]


# Unfortunately we can't use @whitelist_for_serdes on TimeWindowPartitionsDefinition
# because args to __new__ are a different order than the fields in the NamedTuple, and we can't
# reorder them because it's a public API. Until TimeWindowPartitionsDefinition can decorated,
# this class is used to serialize it.
@whitelist_for_serdes(
field_serializers={"start": DatetimeFieldSerializer, "end": DatetimeFieldSerializer}
)
Expand Down Expand Up @@ -222,6 +226,8 @@ def __new__(
" TimeWindowPartitionsDefinition."
)

# When adding new fields to the NamedTuple, update the SerializableTimeWindowPartitionsDefinition
# class with the same fields.
return super(TimeWindowPartitionsDefinition, cls).__new__(
cls, start_dt, timezone, end_dt, fmt, end_offset, cron_schedule
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ def test_partition_with_end_date(
"partitions_def",
[
(DailyPartitionsDefinition("2023-01-01", timezone="America/New_York")),
(DailyPartitionsDefinition("2023-01-01", timezone="America/New_York")),
(DailyPartitionsDefinition("2023-01-01")),
],
)
def test_time_window_partitions_def_serialization(partitions_def):
Expand Down

0 comments on commit 0b5fa15

Please sign in to comment.