When creating graph-backed assets, is it possible ...
# ask-community
a
When creating graph-backed assets, is it possible to only apply a partition_def to a subset of the resulting asset definitions? For example, say I have a graph that produces 3 assets - (1) needs to have daily partitioning, (1) needs weekly, and (1) does not need any partitioning. How would I go about this? Currently the only way I see to apply a partition is as follows:
Copy code
graph_assets = AssetsDefinition.from_graph(the_graph, partitions_def=DailyPartitionsDefinition(...), can_subset=True)
👀 1
dagster bot responded by community 1
c
Unfortunately this is not possible at the moment, each asset created from a graph must share the same partitions definition. If you could break your graph apart into multiple different
@asset
s, you could get the partitioning structure you're hoping for
r
Something hack-y that worked worked for me was passing each of the assets outputted from the graph through a dummy op to create a new asset, and then partitioning that, something like
Copy code
graph_assets = AssetsDefinition.from_graph(
    the_graph, 
    partitions_def=DailyPartitionsDefinition(...), 
    can_subset=True,
    keys_by_output = {
        "output1" : AssetKey("_output1"),
        "output2" : AssetKey("_output2")
})

@op 
def dummy_op(dummy_input):
    return dummy_input

output1 = AssetsDefinition.from_op(dummy_op, keys_by_input = {"dummy_input" : AssetKey("_output1"}, partitions_def=...)

output2 = AssetsDefinition.from_op(dummy_op, keys_by_input = {"dummy_input" : AssetKey("_output2"}, partitions_def=...)
a
@claire Thank you for confirming that I wasn't just overlooking anything! @Rohil Badkundri 🤔 interesting - I will give that a try. Thank you for the suggestion!