Skip to content

Commit

Permalink
Allow users to add dag_integrity_exceptions.txt to ignore errors (#1613)
Browse files Browse the repository at this point in the history
* Allow users to add dag_integrity_exceptions.txt to ignore errors

* add text file to astro dev init

---------

Co-authored-by: David Koenitzer <[email protected]>
  • Loading branch information
collinmcnulty and sunkickr authored May 10, 2024
1 parent 3483791 commit a8d64c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions airflow/airflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func Init(path, airflowImageName, airflowImageTag string) error {
"README.md": Readme,
"tests/dags/test_dag_example.py": DagExampleTest,
".astro/test_dag_integrity_default.py": DagIntegrityTestDefault,
".astro/dag_integrity_exceptions.txt": "# Add dag files to exempt from parse test below. ex: dags/<test-file>",
}

// Initailize directories
Expand Down
6 changes: 5 additions & 1 deletion airflow/include/dagintegritytestdefault.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ def strip_path_prefix(path):
)
def test_file_imports(rel_path, rv):
"""Test for import errors on a file"""
if rv != "No import errors":
if os.path.exists(".astro/dag_integrity_exceptions.txt"):
with open(".astro/dag_integrity_exceptions.txt", "r") as f:
exceptions = f.readlines()
print(f"Exceptions: {exceptions}")
if (rv != "No import errors") and rel_path not in exceptions:
# If rv is not "No import errors," consider it a failed test
raise Exception(f"{rel_path} failed to import with message \n {rv}")
else:
Expand Down

0 comments on commit a8d64c9

Please sign in to comment.