https://dagster.io/ logo
Title
g

geoHeil

03/01/2022, 2:57 PM
How can I work with partitioned software-defined assets? In a graph which combines
op
and
asset
? Right now I get a:
DagsterInvalidConfigError: Error in config for job
Error 1: Missing required config entry "dummy_asset_partitioned" at path root:ops. Sample config for missing entry: {'dummy_asset_partitioned': {'config': {'date': '...'}}}
as Dagster is feedng the configuration per-op and somehow is only filling the partition date into a single of the two steps
when forming a partitioned schchedule:
@daily_partitioned_config(start_date=datetime(2022, 2, 1))
def my_partitioned_config(start: datetime, _end: datetime):
    return {"ops": {"my_op": {"config": {"date": start.strftime("%Y-%m-%d")}}}}
Is it somehow possible to feed the partition globally? And not for each operation which is part of the graph materializing the asset?
(I guess it would be the same problem when working with many software-defined assets as well (assuming they are partitioned))
s

sandy

03/01/2022, 4:33 PM
You shouldn't need to use the
daily_partitioned_config
decorator for software-defined assets. Instead, you attach a
DailyPartitionsDefinition
to each asset. Inside the asset's compute function, you can directly access the partition from the context. E.g.
@asset(partitions_def=DailyPartitionsDefinition(start_date="2020-04-04")
def my_asset(context):
    partition_key = context.output_asset_partition_key()

    # alternatively...
    start_dt, end_dt = context.output_asset_partitions_time_window()
g

geoHeil

03/01/2022, 4:36 PM
interesting. Can I share the
DailyPartitionsDefinition
and
daily_partitioned_config
when mixing ops and assets in a graph?
s

sandy

03/01/2022, 4:37 PM
we don't currently have a straightforward way to mix ops and assets within a graph, though we plan to add one. if that's a blocker for you, I might be able to help you figure something out
g

geoHeil

03/01/2022, 4:38 PM
no this is fine for now knowing it is a limitation