From 0b5fa15db2b530304f595a1aa2c40c3eb184185a Mon Sep 17 00:00:00 2001 From: Claire Lin Date: Mon, 6 Nov 2023 12:44:19 -0800 Subject: [PATCH] update tests and comments --- .../dagster/_core/definitions/time_window_partitions.py | 6 ++++++ .../definitions_tests/test_time_window_partitions.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/python_modules/dagster/dagster/_core/definitions/time_window_partitions.py b/python_modules/dagster/dagster/_core/definitions/time_window_partitions.py index b443d70ae9495..6c2679ab72e90 100644 --- a/python_modules/dagster/dagster/_core/definitions/time_window_partitions.py +++ b/python_modules/dagster/dagster/_core/definitions/time_window_partitions.py @@ -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} ) @@ -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 ) diff --git a/python_modules/dagster/dagster_tests/definitions_tests/test_time_window_partitions.py b/python_modules/dagster/dagster_tests/definitions_tests/test_time_window_partitions.py index 050aeb56444d2..9c04cc10cc5b9 100644 --- a/python_modules/dagster/dagster_tests/definitions_tests/test_time_window_partitions.py +++ b/python_modules/dagster/dagster_tests/definitions_tests/test_time_window_partitions.py @@ -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):