# ask-ai

Darryl Ng

02/23/2024, 1:57 AM
@Scout How can I get all the AssetKeys that are associated to a particular op?


02/23/2024, 1:57 AM
The documentation does not explicitly provide a direct method to retrieve all AssetKeys associated with a particular op. However, there are a few methods and properties related to AssetKeys and execution contexts that might be relevant to your question: 1. Asset Provenance: The
method can return the provenance information for the most recent materialization of an asset when provided with an
. This method is available in both
. 2. Asset Definitions: The
property indicates if there is a backing
for what is currently executing. This could imply that the op has associated assets, but it does not provide a direct way to list all AssetKeys. 3. Asset Keys by Prefix: While not directly related to ops, there is a method to return a filtered subset of asset keys managed by an instance, which can be filtered by a prefix. This method is
and could be used if you know the prefix that might be associated with the assets created by a particular op. 4. Asset Records: Similarly,
can return an
for each of the given asset keys, but this also requires you to already know the asset keys you are interested in. If you need to associate AssetKeys with a particular op, you might consider implementing a naming convention or tagging system that allows you to infer the relationship between ops and assets. For example, you could use tags to mark assets with information about the ops that create or interact with them, and then use the
method to retrieve these tags within an execution context. For a more specific solution tailored to your use case, you might need to look into the implementation details of your Dagster project or consider reaching out to the Dagster community for advice on best practices for tracking the relationship between ops and assets.