Hey all, I'm trying to define a graph backed asset...
# ask-community
c
Hey all, I'm trying to define a graph backed asset that is also partitioned, I think I may be misunderstanding something about the dagster data model for this scenario; it appears that the only op closures where i'm allowed access to the partition key (
context.asset_partition_key_for_output()
) are the `op`s that are marked as producing a result output for the overarching graph. Ideally i'd like to just access this info from any op within the graph underlying the asset, not necessarily just the
op
that is supposedly producing the asset. Dummy example (please excuse, writing a simplified version of my problem by hand here, might not exactly compile but essentially looks like this):
Copy code
from dagster import graph, op, job, AssetsDefinition, DailyPartitionsDefinition

@op
def root_op(context):
    # raises `dagster._check.CheckError: Failure condition: The output has no asset partitions`
    partition_date_str = context.asset_partition_key_for_output()


@op
def leaf_op(root_op):
    return 1

@graph
def my_graph():
    return leaf_op(root_op())

AssetsDefinition.from_graph(my_graph, partitions_def=DailyPartitionsDefinition(start_date=DEFAULT_START))
o
hi @Clement Emmanuel! this is definitely a bit of an odd quirk. but as for a solution, all asset outputs in a given run will share a partition key, and so you can instead just use
context.partition_key
which does not care if the given asset is associated with an asset key or not.
c
Ah wow thanks, perfect!
🌈 1