dagster icon indicating copy to clipboard operation
dagster copied to clipboard

Add context method to get observable asset key

Open benpankow opened this issue 2 years ago • 1 comments

Summary

Addresses #18896. Adds a new property observable_asset_key on the OpExecutionContext which returns the asset key associated with the currently executing @observable_source_asset, if inside the body of such an asset.

Right now it's pretty cumbersome to access, users have to use the (pretty opaque) context.asset_key_for_output("result"). Not sure if this is better addressed elsewhere w/ the context reworks.

@observable_source_asset(
    ...
)
def source_asset_with_observer(context: OpExecutionContext):
    context.log.info("Self key: %s", context.observable_asset_key)

Also tentatively updates asset_key prop to return the observable asset key.

Test Plan

New unit test.

benpankow avatar Dec 26 '23 20:12 benpankow

This stack of pull requests is managed by Graphite. Learn more about stacking.

benpankow avatar Dec 26 '23 20:12 benpankow