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 56e2cd4609256..c1b2c39d64e83 100644 --- a/python_modules/dagster/dagster/_core/definitions/time_window_partitions.py +++ b/python_modules/dagster/dagster/_core/definitions/time_window_partitions.py @@ -1893,15 +1893,23 @@ def __new__( num_partitions: Optional[int], included_time_windows: Sequence[TimeWindow], ): + check.sequence_param(included_time_windows, "included_time_windows", of_type=TimeWindow) + + time_windows_with_timezone = [ + TimeWindow( + start=pendulum.instance(tw.start).in_tz(tz=partitions_def.timezone), + end=pendulum.instance(tw.end).in_tz(tz=partitions_def.timezone), + ) + for tw in included_time_windows + ] + return super(TimeWindowPartitionsSubset, cls).__new__( cls, partitions_def=check.inst_param( partitions_def, "partitions_def", TimeWindowPartitionsDefinition ), num_partitions=check.opt_int_param(num_partitions, "num_partitions"), - included_time_windows=check.sequence_param( - included_time_windows, "included_time_windows", of_type=TimeWindow - ), + included_time_windows=time_windows_with_timezone, ) def get_included_time_windows(self) -> Sequence[TimeWindow]: diff --git a/python_modules/dagster/dagster_tests/asset_defs_tests/test_partitions_subset.py b/python_modules/dagster/dagster_tests/asset_defs_tests/test_partitions_subset.py index 2e088e4d208ed..9b94d70ce7d31 100644 --- a/python_modules/dagster/dagster_tests/asset_defs_tests/test_partitions_subset.py +++ b/python_modules/dagster/dagster_tests/asset_defs_tests/test_partitions_subset.py @@ -87,7 +87,7 @@ def test_empty_subsets(): "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_subset_serialization_deserialization( @@ -105,4 +105,8 @@ def test_time_window_partitions_subset_serialization_deserialization( time_window_partitions_def ).with_partition_keys(["2023-01-01"]) - assert deserialize_value(serialize_value(cast(TimeWindowPartitionsSubset, subset))) == subset + deserialized = deserialize_value( + serialize_value(cast(TimeWindowPartitionsSubset, subset)), TimeWindowPartitionsSubset + ) + assert deserialized == subset + assert deserialized.get_partition_keys() == ["2023-01-01"]