-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build DagFactory DAGs when there is an invalid YAML in the DAGs folder (
#184) Before, when the Airflow DAGs folder had an invalid YAML file, no DagFactory DAGs would be loaded. This PR changes this behaviour to log any invalid YAML file paths but render valid DagFactory YAML-based DAGs. Co-authored-by: Tatiana Al-Chueyr <[email protected]>
- Loading branch information
Showing
6 changed files
with
61 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,5 @@ logs/ | |
# VIM | ||
*.sw[a-z] | ||
|
||
# Airflow | ||
examples/.airflowignore |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: John Doe | ||
age: 30 | ||
is_student: yes | ||
address: | ||
street: 123 Main St | ||
city: New York | ||
postal_code 10001 | ||
- phone: 555-1234 | ||
email: [email protected] |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from __future__ import annotations | ||
from pathlib import Path | ||
|
||
import airflow | ||
from airflow.models.dagbag import DagBag | ||
from packaging.version import Version | ||
|
||
|
||
EXAMPLE_DAGS_DIR = Path(__file__).parent.parent / "examples" | ||
AIRFLOW_IGNORE_FILE = EXAMPLE_DAGS_DIR / ".airflowignore" | ||
AIRFLOW_VERSION = Version(airflow.__version__) | ||
|
||
|
||
MIN_VER_DAG_FILE_VER: dict[str, list[str]] = { | ||
"2.3": ["example_dynamic_task_mapping.py"], | ||
} | ||
|
||
|
||
def test_no_import_errors(): | ||
with open(AIRFLOW_IGNORE_FILE, "w+") as file: | ||
for min_version, files in MIN_VER_DAG_FILE_VER.items(): | ||
if AIRFLOW_VERSION < Version(min_version): | ||
print(f"Adding {files} to .airflowignore") | ||
file.writelines([f"{file}\n" for file in files]) | ||
|
||
db = DagBag(EXAMPLE_DAGS_DIR, include_examples=False) | ||
assert db.dags | ||
assert not db.import_errors |
This file contains 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