You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "TJaniF (via GitHub)" <gi...@apache.org> on 2025/03/16 17:32:09 UTC

[I] [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler [airflow]

TJaniF opened a new issue, #47832:
URL: https://github.com/apache/airflow/issues/47832

   ### Apache Airflow version
   
   3.0.0
   
   ### If "Other Airflow 2 version" selected, which one?
   
   3.0.0b3
   
   ### What happened?
   
   I was attempting to pass data between @asset decorated tasks with the following code:
   
   ```python
   from airflow.sdk.definitions.asset.decorators import (
       asset,  # A
   )
   
   @asset(schedule="@daily")  # C
   def raw_quotes():  # D
       """
       Extracts a random set of quotes.
       """
       import requests  # E
   
       quotes = "Hello"
   
       return quotes  # F
   
   
   @asset(schedule=raw_quotes)  # A
   def selected_quotes(quotes=raw_quotes):  # B
       """
       Transforms the extracted quotes.
       """
   
       print(quotes)
   ```
   
   After unpausing both generated dags I ran the raw_quotes dag, which completes successfully, then triggers the selected_quotes dag. 
   
   This dag gets stuck in running state because the scheduler crashes with:
   
   ```
   scheduler  | File "/Users/tamara.fingerlin/.pyenv/versions/3.12.8/lib/python3.12/multiprocessing/queues.py", line 389, in get
   scheduler  | return _ForkingPickler.loads(res)
   scheduler  | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   scheduler  | TypeError: ServerResponseError.__init__() missing 2 required keyword-only arguments: 'request' and 'response'
   scheduler  | [2025-03-16 18:02:03 +0100] [74940] [INFO] Shutting down: Master
   ```
   
   Full error log: 
   
   [scheduler_logs.txt](https://github.com/user-attachments/files/19273718/scheduler_logs.txt)
   
   ### What you think should happen instead?
   
   Ideally the downstream asset should fetch the XCom returned from the upstream asset. If I got the syntax wrong, the downstream asset should fail with an error, without crashing the scheduler.
   
   ### How to reproduce
   
   1. Add the code provided above
   2. unpause both dags that are created
   3. run the raw_quotes dag
   4. see the error appear in the scheduler logs 
   
   ### Operating System
   
   Apple M1 Pro 15.3.1 
   
   ### Versions of Apache Airflow Providers
   
   None.
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   Standalone beta3.0.0 installed with this:
   
   ```
   uv pip install --find-links \
   https://dist.apache.org/repos/dist/dev/airflow/3.0.0b3/ \
      apache-airflow==3.0.0b3 \
      apache-airflow-task-sdk==1.0.0b3 \
      apache-airflow-providers-celery==3.10.4b3 \
      apache-airflow-providers-cncf-kubernetes==10.4.0b3 \
      apache-airflow-providers-common-compat==1.5.2b3 \
      apache-airflow-providers-fab==2.0.0b3 \
      apache-airflow-providers-openlineage==2.1.2b3 \
      apache-airflow-providers-standard==0.1.2b3
   ```
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on issue #47832:
URL: https://github.com/apache/airflow/issues/47832#issuecomment-2731911461

   The third item is basically we haven’t ported any handlers to task sdk. Tracking it in #45424 instead; we can close this as done.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr closed issue #47832: [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler
URL: https://github.com/apache/airflow/issues/47832


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler [airflow]

Posted by "vatsrahul1001 (via GitHub)" <gi...@apache.org>.
vatsrahul1001 commented on issue #47832:
URL: https://github.com/apache/airflow/issues/47832#issuecomment-2728064155

   @uranusjr we were noticing the different error in scheduler when we tested this scenario
   
   ```
     File "/opt/airflow/airflow/jobs/scheduler_job_runner.py", line 880, in process_executor_events
       ti.handle_failure(error=msg, session=session)
     File "/opt/airflow/airflow/utils/session.py", line 98, in wrapper
       return func(*args, **kwargs)
     File "/opt/airflow/airflow/models/taskinstance.py", line 3206, in handle_failure
       _handle_failure(
     File "/opt/airflow/airflow/utils/session.py", line 98, in wrapper
       return func(*args, **kwargs)
     File "/opt/airflow/airflow/models/taskinstance.py", line 1073, in _handle_failure
       failure_context = TaskInstance.fetch_handle_failure_context(
     File "/opt/airflow/airflow/models/taskinstance.py", line 3114, in fetch_handle_failure_context
       context = ti.get_template_context(session)
     File "/opt/airflow/airflow/models/taskinstance.py", line 3234, in get_template_context
       return _get_template_context(
     File "/opt/airflow/airflow/models/taskinstance.py", line 935, in _get_template_context
       context: Context = runtime_ti.get_template_context()
     File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 148, in get_template_context
       "inlet_events": InletEventsAccessors(self.task.inlets),
     File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/context.py", line 302, in __init__
       asset = OutletEventAccessors._get_asset_from_db(name=inlet.name)
     File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/context.py", line 267, in _get_asset_from_db
       from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
   ImportError: cannot import name 'SUPERVISOR_COMMS' from 'airflow.sdk.execution_time.task_runner' (/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py)
   root@a799eb98b17f:/opt/airflow#
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on issue #47832:
URL: https://github.com/apache/airflow/issues/47832#issuecomment-2728455268

   One the first point… actually maybe we can make this work? Pytest does.
   
   ```python
   import pytest
   
   @pytest.fixture
   def a():
       return None
   
   def test_a_arg(a=1):
       assert a == 1
   
   def test_a_fix(a):
       assert a is None
   ```
   
   Not unreasonable IMO. I think I’ll do this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler [airflow]

Posted by "marclamberti (via GitHub)" <gi...@apache.org>.
marclamberti commented on issue #47832:
URL: https://github.com/apache/airflow/issues/47832#issuecomment-2729446076

   @uranusjr I see that the test TC_013 indicates that scheduling an asset based on a previous asset with `@asset(schedule=my_previous_asset)` should work. The status is positive. Is that has been changed?
   https://cwiki.apache.org/confluence/display/AIRFLOW/Test+cases+AIP-75+New+Asset-Centric+Syntax


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Beta3] Attempting to pass an @asset decorated function as an input to the next asset crashes the scheduler [airflow]

Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on issue #47832:
URL: https://github.com/apache/airflow/issues/47832#issuecomment-2728399542

   OK so there are three separate problems here.
   
   First, we don’t support syntax like `quotes=raw_quotes` in the arguments (you’re supposed to just reference the asset by argument name like in pytest), so this should fail on parse time. We need to add a check in the dag parser.
   
   Second, when you try to reference an asset that does not exist (here `quote` because of the previous point), AssetOperations does not handle 404 correct and thus crash the entire task. We should handle this more gracefully (although it should probably still make the task fail).
   
   Third (the exception in Rahul’s comment), when a task is failed, the scheduler calls `_handle_failure`, which tries to get the ti context, but during the ti context creation process it tries to use the supervisor. The supervisor is not available in the scheduler, and the entire thing crumbles down. I’m not sure how to handle this one though. Should this handler be moved into the task runner? Or should we add some logic so the supervisor is usable in the scheduler (but actually just goes to the db directly instead)? Need some input from the sdk folks here.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org