how do you specify a range of partitions for an up...
# ask-community
c
how do you specify a range of partitions for an upstream dependency (e.g., i want my op to proceeds then last 30 days of data)
c
Hi Chris. One immediate way I can think of is to use the standard date-partitioned configuration, and within your op, use context.op_config to get the current date. Then, within the op, you can do computation on the last 30 days based on the current date value.
c
how do i block that op from running if the past 30 days of data do not exist?
c
You could use two ops, the first to check for the existence of the past 30 days, and the second to run the computation you want. You could output an optional output from the first op if the last 30 days exist. If the optional output isn't yielded, the second op won't run.
c
dooesn’t that break lineage if i’m using ops to check for dependencies?
c
Hi Chris. What do you mean by breaking lineage?
c
i guess i would still define the AssetIn() as the upstream thing i want 30 dyas of. does the AssetIn definition presume a specific partition?
c
If you're using ops, you can partition using PartitionedConfig objects. If you are using assets, then you can use PartitionsDefinitions. If you provided a PartitionMapping object to your AssetIn definition, that object will define the upstream to downstream partition mapping given a partition key range. Perhaps an example might help to clarify this: https://github.com/dagster-io/dagster/blob/b59682d7e8fd0039fa426a46af9c0599fec651a[…]ts/core_tests/asset_defs_tests/test_asset_partition_mappings.py