Dev-iL opened a new issue, #44775:
URL: https://github.com/apache/airflow/issues/44775

   ### Apache Airflow version
   
   Other Airflow 2 version (please specify below)
   
   ### If "Other Airflow 2 version" selected, which one?
   
   2.10.2
   
   ### What happened?
   
   One of the tests in our CI is creating a DagBag. After adding a DAG that's 
scheduled on a DatasetAlias, the bag cannot be created. Confusingly, this issue 
does not occur in other settings/environments (e.g. dag.test, local pytest, 
non-CI Airflow run in Docker).
   
   ### What you think should happen instead?
   
   DagBag creation should not fail on a one-shot parse pass of the dags folder 
regardless of order.
   
   ### How to reproduce
   
   1. Obtain the docker image: `apache/airflow:2.10.2-python3.9`
   2. Add the following DAG to the `dags` folder:
   ```python
   from pendulum import datetime
   
   from airflow import DAG
   from airflow.datasets import DatasetAlias
   
   with DAG(
       dag_id="foo",
       start_date=datetime(2000, 1, 1),
       schedule=[
           DatasetAlias("bar"),
       ],
       catchup=False,
   ):
       pass
   ```
   3. Open a python shell, and run:
   ```python
   from airflow.models import DagBag
   DagBag(include_examples=False)
   ```
   
   ### Operating System
   
   Rocky Linux 9.3
   
   ### Versions of Apache Airflow Providers
   
   (Irrelevant)
   
   ### Deployment
   
   Other Docker-based deployment
   
   ### Deployment details
   
   Dockerfile-ci:
   ```
   FROM apache/airflow:2.10.2-python3.9
   
   # Install system packages
   USER root
   RUN apt-get update \
       && apt-get install -y --no-install-recommends build-essential vim strace 
iproute2 git \
          pkg-config libxml2-dev libxmlsec1-dev libxmlsec1-openssl \
       && apt-get autoremove -yqq --purge \
       && apt-get clean \
       && rm -rf /var/lib/apt/lists/*
   
   USER airflow
   ```
   
   ci script:
   ```yaml
     script:
       - git config --global --add safe.directory $PWD
       - pip install uv pre-commit-uv --upgrade
       - uv pip install -e .[dev] --constraint 
"https://raw.githubusercontent.com/apache/airflow/constraints-2.10.2/constraints-3.9.txt";
       - uv tool install pre-commit --force --with pre-commit-uv 
--force-reinstall
       - export PIP_USER=false && pre-commit install --install-hooks
       - pre-commit run --all-files --show-diff-on-failure
   ```
   
   ### Anything else?
   
   Presumably, this issue isn't present in a "running" Airflow instance where 
there is at least one DAG that outputs a DatasetAlias, which causes the 
necessary tables to be created, and then the 2nd parse of the alias-scheduled 
DAG succeeds.
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to