[AIP-85] Move DAG importer abstractions and registry into Task SDK - #72369
Open
dilnazanlid wants to merge 2 commits into
Open
[AIP-85] Move DAG importer abstractions and registry into Task SDK#72369dilnazanlid wants to merge 2 commits into
dilnazanlid wants to merge 2 commits into
Conversation
…e the /importers base classes into the task SDK
dilnazanlid
requested review from
amoghrajesh,
ashb,
kaxil and
potiuk
as code owners
September 1, 2026 10:58
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request is one of the incremental parts of the AIP-85: DAG Importer implementation.
It restructures the DAG importer base abstractions and moves them into the Task SDK (
task-sdk/src/airflow/sdk/importers/), while migrating shared file-parsing utilities intoairflow_shared.module_loading.Motivation & Background
Under the Airflow 3 architecture, the Task SDK (
airflow.sdk) serves as the lightweight DAG authoring and execution boundary, while DAG file processing and bundling operate without workers requiring direct database access.To support pluggable DAG importers across various formats without creating tight coupling, the fundamental DAG importer interfaces, definitions, registries, and built-in importers (
PythonDagImporter,ZipImporter) must live inside the Task SDK.Summary of Changes
1. Shared Module Loading (
shared/module_loading)get_unique_dag_module_name,might_contain_dag, andmight_contain_dag_via_default_heuristicfromairflow.utils.fileintoairflow_shared.module_loading.dag_file.airflow.utils.filevia module attribute fallbacks/deprecation paths.shared/module_loading/tests/module_loading/test_dag_file.py.2. Task SDK Importer Abstractions (
task-sdk/src/airflow/sdk/importers/)DagDefinition&FileDagDefinition:freshness_token(used for cache invalidation and change detection), relative location resolution, direct content reading (read_bytes,read_text), and a context manager for file access (as_file()).FileDagDefinition: Concrete implementation backed by local filesystem files.DagImportError: Structured error reporting capturing source references, line/column numbers, error types, contextual snippets, suggestions, and stack traces.DagImportWarning: Non-fatal warnings captured during Dag importing.DagImportResult: Encapsulates imported Dags, errors, skipped definitions, warnings, and dependencies.DagSourceCode: Data structure containing raw source code and language identifier for Code view presentation.AbstractDagImporter: Base interface specifyingsupported_extensions,import_definition(),can_handle(),list_dag_definitions(), andget_source_code().DagImporterRegistry: Thread-safe singleton registry mapping file extensions to their corresponding importer implementations, with default registration for.pyand.zip, conflict warnings, and test isolation reset support.PythonDagImporter:.py) supportingsafe_modeheuristics, import timeouts, module execution with unique prefix isolation (unusual_prefix_), and top-levelDAG/DagContextextraction with bundle metadata tracking.get_source_codereturning Python source.ZipImporter&ZipFileDagDefinition:.ziparchives.sys.path, and routes archive members to registered internal importers (such asPythonDagImporter).freshness_tokenand source code extraction.3. Test Coverage
task-sdk/tests/task_sdk/importers/test_python_importer.py: Tests for importing valid Dags, syntax error reporting, skipping non-Dag files, bundle metadata propagation, and source code retrieval.task-sdk/tests/task_sdk/importers/test_registry.py: Tests for singleton lifecycle, default registrations, extension resolution, case insensitivity, and registry resets.task-sdk/tests/task_sdk/importers/test_zip_importer.py: Tests for ZIP Dag importing, ZipSlip directory traversal prevention, source code extraction (whole archive and archive member), and composite freshness tokens.task-sdk/tests/task_sdk/docs/test_public_api.py: Updated public API verification to includeairflow.sdk.importers.Was generative AI tooling used to co-author this PR?
Generated-by: Antigravity following the guidelines