https://dagster.io/ logo
Title
d

Drew You

03/21/2023, 7:04 PM
I'd like to branch on whether an asset is partitioned by time or not in my
IOManager
. Here's my current implementation:
if context.has_partition_key:
            had_it = False
            try:
                had_it = context.asset_partitions_time_window
            except:
                pass
            if had_it:
                raise NotImplementedError(
                    "Time partitioning not implemented in IO Manager"
                )
Is there any way to check if the asset is time window partitioned without a try except block?
j

jamie

03/21/2023, 8:03 PM
In our IO managers, we do
isinstance
checks
if context.has_asset_partitions:
    if isinstance(context.asset_partitions_def, MultiPartitionsDefinition):
         # handle multi partition case 
     elif isinstance(context.asset_partitions_def, TimeWindowPartitionsDefinition):
         # handle time partitions case
     else:
         # handle static partition case
❤️ 1