James Robinson
02/27/2024, 11:14 AMreport_asset_materialization
API endpoint to report an failure in an asset materialisation?Scout
02/27/2024, 11:14 AMreport_asset_materialization
API endpoint is specifically designed for reporting successful asset materializations. If you need to report a failure in an asset materialization, this endpoint would not be appropriate as it does not provide a way to indicate a failure state. The documentation provides details on how to use the report_asset_materialization
endpoint to report successful materializations, including the required parameters such as asset_key
, metadata
, data_version
, and description
. However, it does not mention the ability to report failures through this endpoint. For reporting failures or other types of asset events, you would need to look for a different mechanism within Dagster's APIs or consider implementing custom logic to handle such cases.James Robinson
02/27/2024, 11:19 AMreport_asset_check
, but given that this is an external asset, is it possible to add an external asset check to the external asset?Scout
02/27/2024, 11:19 AMreport_asset_check
endpoint. This endpoint allows you to report the results of an asset check, including whether the check passed or failed, and you can associate it with an external asset. The documentation mentions that when loading a dbt project into the asset graph, Dagster’s dbt integration can load all dbt tests as Asset Checks. This makes it easier to visualize the success and failure of those tests, as they show up on the Dagster asset that corresponds to the dbt models that they’re checking. Additionally, there was an issue reported on GitHub where a user wanted to report an asset check on an external asset using the REST API. The user expected to see the asset verification report in the user interface, similar to how materialization reports work. This suggests that it is indeed possible to report asset checks for external assets. However, it's important to note that the ability to report asset checks for external assets may depend on the specific version of Dagster you are using and the configuration of your Dagster instance. If you encounter any issues or limitations with reporting asset checks for external assets, it would be advisable to check the latest Dagster documentation or seek support from the Dagster community or maintainers for guidance on the best practices for your specific use case.James Robinson
02/27/2024, 11:22 AM1.5.13
, so have access to the external assets via AssetSpec
. These are not dbt assets. How do I add an external asset check to this asset?
external_spec = dag.AssetSpec(...)
external_asset = dag.external_asset_from_spec(external_spec)
Scout
02/27/2024, 11:22 AM1.5.13
, Dagster supports the concept of external assets, which are assets that are not materialized by Dagster but are still part of your asset graph. These assets can represent data produced by systems outside of Dagster's control. To add an asset check to an external asset, you would typically use the report_asset_check
API endpoint to report the outcome of checks associated with that asset. However, defining asset checks directly in the code for external assets is not the same as for assets that are materialized by Dagster, since external assets do not have computation functions where you can place checks. For external assets, you would generally perform the checks outside of Dagster and then report the results to Dagster using the REST API or other mechanisms. Here's a general approach to how you might handle this: 1. Perform your asset checks externally, in whatever system or process is responsible for the external asset. 2. Use the Dagster REST API to report the results of these checks to Dagster. Here's a hypothetical example of how you might report an asset check for an external asset using the REST API: python import requests DAGSTER_INSTANCE_URL = "<http://your-dagster-instance.com>" ASSET_KEY = "your_external_asset_key" # This is a placeholder for your actual check logic def perform_external_asset_check(): # Your check logic here passed = True # or False, based on your check return passed # Perform the check check_passed = perform_external_asset_check() # Report the check result to Dagster response = <http://requests.post|requests.post>( url=f"{DAGSTER_INSTANCE_URL}/api/asset_checks/report", json={ "asset_key": ASSET_KEY, "check_result": { "passed": check_passed, # Include any additional metadata or information about the check here }, }, ) response.raise_for_status() # This will raise an error if the request failed
Please note that the above code is a simplified example and assumes the existence of an endpoint at /api/asset_checks/report
, which is not an actual Dagster API endpoint. You will need to refer to the Dagster documentation or API reference for the correct API endpoint and payload structure to use when reporting asset checks. If you need to report asset checks programmatically within a Dagster pipeline, you might consider using sensors or other mechanisms to trigger the reporting based on events or conditions in your external systems. Since external assets and asset checks are evolving features, it's always a good idea to consult the latest Dagster documentation for the most up-to-date guidance and best practices.