airflow: Asset graph is not visible on the assets page
Apache Airflow version
3.0.0rc1
If “Other Airflow 2 version” selected, which one?
No response
What happened?
Asset graph is not visible on the assets page
API server logs:
File “/usr/local/lib/python3.9/site-packages/starlette/routing.py”, line 288, in handle await self.app(scope, receive, send) File “/usr/local/lib/python3.9/site-packages/starlette/routing.py”, line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File “/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py”, line 53, in wrapped_app raise exc File “/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py”, line 42, in wrapped_app await app(scope, receive, sender) File “/usr/local/lib/python3.9/site-packages/starlette/routing.py”, line 73, in app response = await f(request) File “/usr/local/lib/python3.9/site-packages/fastapi/routing.py”, line 301, in app raw_response = await run_endpoint_function( File “/usr/local/lib/python3.9/site-packages/fastapi/routing.py”, line 214, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) File “/usr/local/lib/python3.9/site-packages/starlette/concurrency.py”, line 37, in run_in_threadpool return await anyio.to_thread.run_sync(func) File “/usr/local/lib/python3.9/site-packages/anyio/to_thread.py”, line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File “/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py”, line 2470, in run_sync_in_worker_thread return await future File “/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py”, line 967, in run result = context.run(func, *args) File “/opt/airflow/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dependencies.py”, line 49, in get_dependencies for dag, dependencies in sorted(SerializedDagModel.get_dag_dependencies().items()): File “/opt/airflow/airflow-core/src/airflow/utils/session.py”, line 102, in wrapper return func(*args, session=session, **kwargs) File “/opt/airflow/airflow-core/src/airflow/models/serialized_dag.py”, line 656, in get_dag_dependencies dag_depdendencies_by_dag = resolver.resolve() File “/opt/airflow/airflow-core/src/airflow/models/serialized_dag.py”, line 94, in resolve dag_deps.extend(self.resolve_asset_name_ref_dag_dep(dep_data)) File “/opt/airflow/airflow-core/src/airflow/models/serialized_dag.py”, line 180, in resolve_asset_name_ref_dag_dep asset_id, asset_name = self.asset_ref_name_to_asset_id_name[dep_id] KeyError: ‘asset11_producer’
What you think should happen instead?
No response
How to reproduce
- Have a dag which is associated with an asset.
- Navigate to the assets page and see asset graph is not visible for any of the assets, even after creating an asset event.
from airflow.sdk.definitions.asset.decorators import asset
@asset(schedule=None, tags=["asset", "AIP-75"])
def conditional_asset1():
pass
Looks like Asset.ref is creating this issue:
from __future__ import annotations
from airflow.decorators import dag, task
from airflow.sdk import Asset
from airflow.sdk.definitions.asset.decorators import asset
@asset(uri="s3://bucket/asset11_producer", schedule=None)
def producer1():
pass
@asset(uri="s3://bucket/asset2_producer", schedule=None)
def producer2():
pass
@asset(uri="abc", schedule=None)
def producer3():
pass
@dag(
schedule=Asset.ref(name="asset11_producer") & Asset.ref(name="asset2_producer"),
catchup=False,
tags=["asset"],
)
def consumer():
@task()
def process_nothing(triggering_asset_events):
for a, events in triggering_asset_events.items():
print(a.name, events)
consumer()
Operating System
Linux
Versions of Apache Airflow Providers
No response
Deployment
Other
Deployment details
No response
Anything else?
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (19 by maintainers)
@Lee-W yes I’m working on that right now
#48920 is merged, so @Lee-W do we have anything pending here?
@atul-astronomer can you test it once and confirm the issue is resolved
Dag error is not viable. Warning is possible; this can be done when we check for orphaned assets in the scheduler. I think it’d be usefull; having a ref pointing to nowhere is likely a user error, similar to having a dangling symlink.
I guess similar issue will apply to
Asset.ref(uri=uri)too.cc: @Lee-W @uranusjr @bbovenzi @pierrejeambrun