https://dagster.io/ logo
#ask-ai
Title
# ask-ai
p

Peter Lim

02/29/2024, 1:07 AM
is there a way to run all stale assets?
s

Scout

02/29/2024, 1:07 AM
Yes, there is a way to run all stale assets in Dagster. The documentation mentions the use of an asset reconciliation sensor that can be constructed using
build_asset_reconciliation_sensor
. This sensor automatically materializes assets that have never been materialized or whose upstream assets have changed since the last time they were materialized. It works with partitioned assets as well. Additionally, you can add a
FreshnessPolicy
to your software-defined assets to specify how up-to-date you expect that asset to be. You can then use the
@freshness_policy_sensor
to alert when assets are missing their targets and to kick off runs to materialize assets based on their freshness policies. For more granular control, you can define custom sensors with the
@multi_asset_sensor
decorator that trigger based on the materializations of multiple assets. This allows you to monitor the state of more than one asset and trigger runs accordingly. If you want to automate the process of materializing stale assets, you can use schedules, sensors, or auto-materialization policies to trigger each asset. These can be configured to materialize data only when it is necessary, such as when upstream data or code changes. For specific code examples and further details on how to implement these features, you should refer to the Dagster documentation on asset sensors, freshness policies, and asset reconciliation sensors.
p

Peter Lim

02/29/2024, 1:10 AM
@Scout is there a way to list all stale assets using python api?
s

Scout

02/29/2024, 1:10 AM
As of the last update from the documentation, there isn't a direct API call provided by Dagster to list all stale assets using the Python API. However, there is an open issue discussing the possibility of exposing functions to check the staleness of assets in the API, which indicates that this functionality might be considered for future implementation. For now, if you need to determine which assets are stale, you might have to implement custom logic using the available APIs to check the last materialization time against your freshness criteria. This could involve querying the asset catalog and comparing timestamps or using the event log to determine when assets were last materialized. Keep an eye on the Dagster releases and documentation for updates regarding this functionality, as it may be added in a future version of Dagster.
3 Views