https://dagster.io/ logo
#ask-community
Title
# ask-community
a

Andras Somi

02/20/2023, 10:54 AM
Hey, I have a weekly partitioned multi asset that generates assets based on new files in an S3 bucket. Some of the outputs are not mandatory (
is_required=False
), because the provider might not put down the corresponding file for that week, while the rest of the files is expected to be there for each partition. The optional assets will have gaps in their partition history which in turn seems to turn on the “Stale” flag on the asset (even if the latest partition is green) which will propagate to downstream assets, making a big branch of my assets permanently stale even though we consider them fresh practically. Is there a way to make these optional partitioned assets look fresh if the latest partition was found? Or is it the opposite of what people would expect from a partitioned asset?
v

Vinnie

02/20/2023, 11:13 AM
I’m not sure if this is the recommended way to go, but you might wanna look into
DynamicPartitions
. I have a similar use case with an asset that needs to be historized but is only irregularly updated. I believe it’s currently undocumented, but I found the code (incl. code example) to be very straightforward: https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/_core/definitions/partition.py#L538 Alternatively, you could just materialize an empty object when the partition is not present.
a

Andras Somi

02/20/2023, 12:52 PM
Alternatively, you could just materialize an empty object when the partition is not present.
That’s what I’m looking into right now, but it feels “dirty”. I also lose some information about the missing partitions. It’s useful to know if one is missing, just don’t want it to make my asset stale if I already have a more recent partition.
DynamicPartitions
looks interesting though. I saw a few discussions earlier around the concept but I didn’t know it’s already implemented to some extent. Thanks for bringing it up!
c

claire

02/21/2023, 9:05 PM
Agree with Vinnie that dynamic partitions are a great application for this use case. We do have unreleased documentation out for this feature that will make it out this week: https://docs.dagster.io/master/concepts/partitions-schedules-sensors/partitions#dynamically-partitioned-assets You can go ahead and begin using the feature as it is already implemented, though it is experimental at the moment 🌈
a

Andras Somi

02/21/2023, 10:20 PM
Thanks for confirming!
🌈 1
s

sandy

02/23/2023, 4:26 PM
@Andras Somi - if / when you try this out, I'm curious to hear how it goes for you
a

Andras Somi

02/23/2023, 4:32 PM
@sandy i'll let you know. I had to move on from this issue with a less than ideal solution of making the assets non-partitioned, but I plan to get back to the DynamicPartition thing.
v

Vinnie

02/23/2023, 5:23 PM
@sandy I adapted this same pattern for what’s essentially a yearly budget asset. I want to keep it historized but it didn’t make sense to put it on a strict schedule; depending on the time of month it might not be updated at all or multiple times during a single day. Works pretty much as expected. The only “con” is there could be days/weeks missing from the list of partitions, but that’s to be expected. I haven’t needed any more information than it’s provided me out of the box.
s

sandy

02/23/2023, 6:25 PM
would it be accurate to say that each partition corresponds to a time window, but those time windows aren't regularly spaced out?
v

Vinnie

02/23/2023, 6:28 PM
Yep!
👍 1
8 Views