dbt: dbt-ol
should transparently exit with the same exit code as the child dbt
process
#2560
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.
Problem
See #2558
If
dbt-ol
doesn't exit with the same code as the childdbt
process, then any upstream process(es), including Airflow DAGs, won't be able to detect workflow failures.Closes: #2558
Solution
dbt-ol.main
should return thereturn_code
of the childdbt
process, and we should explicitlysys.exit
it.This PR also adds a couple of extra changes to make the code of
dbt-ol
more PEP/Flake compliant. In particular:Logging functions should favor lazy evaluation over f-strings.
subprocess.Popen
should always be run through a context manager (for proper process/resources clean up).One-line summary:
dbt-ol
should transparently exit with the same exit code as the childdbt
process.Checklist
[ ] Your changes are accompanied by tests (if relevant)- [ ] You've updated any relevant documentation (if relevant)- [ ] You've versioned the core OpenLineage model or facets according to SchemaVer (if relevant)- [ ] You've added a header to source files (if relevant)SPDX-License-Identifier: Apache-2.0
Copyright 2018-2023 contributors to the OpenLineage project