Is it possible to determine whether an asset is in...
# ask-ai
c
Is it possible to determine whether an asset is in the process of being materialized?
s
Yes, it is possible to determine whether an asset is currently being materialized. According to the documentation, you can query the Dagster instance via the context to check if an asset is in the process of being materialized. Here is an example provided in the documentation:
Copy code
python from dagster import asset, AssetKey, DagsterEventType, RunsFilter from dagster._core.storage.pipeline_run import IN_PROGRESS_RUN_STATUSES  @asset  def current_materializations(context):     event = context.instance.get_event_records(event_records_filter=EventRecordsFilter(event_type=DagsterEventType.ASSET_MATERIALIZATION_PLANNED, asset_key=AssetKey("foo")), limit=1)     in_progress = context.instance.get_runs(                         filters=RunsFilter(                             run_ids=[                                 event[0].event_log_entry.run_id                             ],                             statuses=IN_PROGRESS_RUN_STATUSES,                         )                     )      # in_progress is a bool of where the materialization run is currently executing
Please note that
IN_PROGRESS_RUN_STATUSES
is a non-public API, and it may change between releases. This means that while the method shown is currently valid, it may be subject to change and should be used with caution. Always refer to the latest documentation for the most up-to-date methods and APIs.