Skip to content

Conversation

@jason810496
Copy link
Member

Why

When using breeze shell --use-airflow-version owner:repo/branch --mount-sources providers-and-tests and run pytest directly in the shell, I encounter the following error:

ERROR providers/standard/tests/unit/standard/operators/test_trigger_dagrun.py - FileNotFoundError: [Errno 2] No such file or directory: '/usr/python/lib/airflow-core/src/airflow/config_templates/unit_tests.cfg'
Full traceback:
============================================================================================ ERRORS ============================================================================================
___________________________________________________ ERROR collecting providers/standard/tests/unit/standard/operators/test_trigger_dagrun.py ___________________________________________________
providers/standard/tests/unit/standard/operators/test_trigger_dagrun.py:29: in <module>
    from airflow.models.dag import DagModel
/usr/python/lib/python3.10/site-packages/airflow/models/dag.py:55: in <module>
    from airflow.models.dagrun import DagRun
/usr/python/lib/python3.10/site-packages/airflow/models/dagrun.py:74: in <module>
    from airflow.sdk.definitions.deadline import DeadlineReference
/usr/python/lib/python3.10/site-packages/airflow/sdk/definitions/deadline.py:25: in <module>
    from airflow.sdk.serde import deserialize, serialize
/usr/python/lib/python3.10/site-packages/airflow/sdk/serde/__init__.py:34: in <module>
    from airflow.sdk.configuration import conf
/usr/python/lib/python3.10/site-packages/airflow/sdk/configuration.py:264: in __getattr__
    val = initialize_config()
/usr/python/lib/python3.10/site-packages/airflow/sdk/configuration.py:258: in initialize_config
    airflow_config_parser.load_test_config()
/usr/python/lib/python3.10/site-packages/airflow/sdk/configuration.py:173: in load_test_config
    unit_test_config = unit_test_config_file.read_text()
/usr/python/lib/python3.10/pathlib.py:1134: in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
/usr/python/lib/python3.10/pathlib.py:1119: in open
    return self._accessor.open(self, mode, buffering, encoding, errors,
E   FileNotFoundError: [Errno 2] No such file or directory: '/usr/python/lib/airflow-core/src/airflow/config_templates/unit_tests.cfg'
=================================================================================== short test summary info ====================================================================================
ERROR providers/standard/tests/unit/standard/operators/test_trigger_dagrun.py - FileNotFoundError: [Errno 2] No such file or directory: '/usr/python/lib/airflow-core/src/airflow/config_templates/unit_tests.cfg'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================= 1 warning, 1 error in 2.08s ==================================================================================

The SDK's load_test_config() method was using an incorrect path calculation to locate unit_tests.cfg, which only worked in the monorepo structure. When the SDK is installed as a package in site-packages, the path resolution failed because it assumed the monorepo directory structure.

What

We updated load_test_config() to use the same dual-path resolution pattern as _default_config_file_path():

def _default_config_file_path(file_name: str) -> str:
"""Get path to airflow core config.yml file."""
# TODO: Task SDK will have its own config.yml
# Temporary: SDK uses Core's config files during development
# Option 1: For installed packages
config_path = pathlib.Path(__file__).parent.parent / "config_templates" / file_name
if config_path.exists():
return str(config_path)
# Option 2: Monorepo structure
config_path = (
pathlib.Path(__file__).parent.parent.parent.parent.parent
/ "airflow-core"
/ "src"
/ "airflow"
/ "config_templates"
/ file_name
)
if config_path.exists():
return str(config_path)
raise FileNotFoundError(f"Could not find '{file_name}' in config_templates. ")

@jason810496 jason810496 changed the title Fix TaskSDK unit test config file path handling for installed package… Fix TaskSDK unit test config file path handling for installed packages and monorepo Jan 20, 2026
@jason810496 jason810496 merged commit 84fbeec into apache:main Jan 20, 2026
100 checks passed
jason810496 added a commit to jason810496/airflow that referenced this pull request Jan 22, 2026
suii2210 pushed a commit to suii2210/airflow that referenced this pull request Jan 26, 2026
shreyas-dev pushed a commit to shreyas-dev/airflow that referenced this pull request Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants