Skip to content

I want to define a piece of metadata on a graph_asset, and have that metadata be accessible via the context in ops #17843

Answered by jamiedemaria
achen187 asked this question in Q&A
Discussion options

You must be logged in to vote

Using metadata you can do something like this

@op
def dummy_op_2(context, dummy_op):
    value = context.assets_def.metadata_by_key[dummy_asset.key]
    context.log.info(value)

@op
def dummy_op(context):
    value = context.assets_def.metadata_by_key[dummy_asset.key]
    context.log.info(value)


@graph_asset(
    metadata={"my_key": "my_value"})
def dummy_asset():
    return dummy_op_2(dummy_op())

with config you could do something like this

@op(
    config_schema={"value": str}
)
def dummy_op_2(context, dummy_op):
    value = context.op_config["value"]
    context.log.info(value)

@op(
    config_schema={"value": str}
)
def dummy_op(context):
    value = context.op_config["value"]
    c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@zcemycl
Comment options

Answer selected by jamiedemaria
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: ops/graphs/jobs Related to Dagster ops, graphs and jobs area: metadata Related to metadata
3 participants