Skip to content

Support using envvar in config YAML#236

Merged
tatiana merged 2 commits into
mainfrom
support-yaml-envvar
Oct 11, 2024
Merged

Support using envvar in config YAML#236
tatiana merged 2 commits into
mainfrom
support-yaml-envvar

Conversation

@tatiana
Copy link
Copy Markdown
Collaborator

@tatiana tatiana commented Oct 10, 2024

This PR introduces support for DAG Factory YAML configuration files to support referencing environment variables, such as $SOME_PATH. Now DAG Factory resolves this during DAG parsing time.

Motivation

Troubleshooting DAG Factory, for example, was difficult because DAGs had all hard-coded paths based on the Dockerfile.

The following commands failed to run because of the hard-coded paths:

PYTHONPATH=`pwd`:`pwd`/examples AIRFLOW_HOME=`pwd` airflow dags test example_breadfast
PYTHONPATH=`pwd`:`pwd`/examples AIRFLOW_HOME=`pwd` airflow dags test test_expand

Alternatives

Since DAG Factory expected absolute paths, using relative paths was not an option.

What changes

By setting the environment variable CONFIG_ROOT_DIR to reference the root directory where DAG Factory example DAGs configs are, anyone should be able to run DAG Factory locally using the airflow dags test command:

CONFIG_ROOT_DIR=`pwd`"/dags" PYTHONPATH=`pwd`:`pwd`/examples AIRFLOW_HOME=`pwd` airflow dags test test_expand      

Copy link
Copy Markdown
Contributor

@pankajkoti pankajkoti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for this great addition @tatiana :)

@tatiana tatiana merged commit 0f853e4 into main Oct 11, 2024
@tatiana tatiana mentioned this pull request Oct 17, 2024
tatiana added a commit that referenced this pull request Oct 17, 2024
The test was modifying a fixture, and this fixture is not in .gitignore.
The consequence is that if there were errors, the fixture was changed and developers would potentially commit an invalid fixture due to this.
This PR leverages the previous change introduced in #236 to use envvars for templating YML filepaths
tatiana added a commit that referenced this pull request Oct 17, 2024
A Pytest fixture modified a DAG YAML file, which is not in .gitignore.

The consequence is that if there were errors, the fixture was changed
and developers would potentially commit an invalid fixture - that would
be invalid in the CI.

This PR leverages the previous change introduced in #236 to use envvars
for templating YML filepaths..
tatiana added a commit that referenced this pull request Oct 22, 2024
### Added
- Support using envvar in config YAML by @tatiana in #236
- **Callback improvements**
- Support installed code via python callable string by @john-drews in
#221
- Add `callback_file` & `callback_name` to `default_args` DAG level by
@subbota19 in #218
- Cast callbacks to functions when set with `default_args` on TaskGroups
by @baraldo and @pankajastro in #235

- **Telemetry**
- For more information, please, read the [Privacy
Notice](https://github.com/astronomer/dag-factory/blob/main/PRIVACY_NOTICE.md#collection-of-data).
  - Add scarf to readme for website analytics by @cmarteepants in #219
- Support telemetry during DAG parsing emitting data to Scarf by
@tatiana in #250.

### Fixed
- Build DAGs when tehre is an invalid YAML in the DAGs folder by @quydx
and @tatiana in #184

### Others
- Development tools
  - Fix make docker-run by @pankajkoti in #249
  - Add vim dot files to .gitignore by @tatiana in #228
  - Use Hatchling to modern package building by @kaxil in #208
- CI
  - Fix static check failures in PR #218 by @pankajkoti in #251
  - Fix pre-commit checks by @tatiana in #247
  - Remove tox and corresponding build jobs in CI by @pankajkoti in #248
- Install Airflow with different versions in the CI by @pankajkoti in
#237
  - Run pre-commit hooks on all existing files by @pankajkoti in #245
  - Add Python 3.11 and 3.12 to CI test pipeline by @pankajkoti in #229
- Tests
  - Fix duplicate test name by @pankajastro in #234
  - Add static check by @pankajastro in #231
  - Fix running tests locally (outside the CI) by @tatiana in #227
  - Add the task_2 back to dataset example by @cmarteepants in #204
  - Remove unnecessary config line by @jlaneve in #202
- Documentation
  - Update the license from MIT to Apache 2.0 by @pankajastro in #191
- Add registration icon and links to Airflow references by @cmarteepants
in #190
  - Update quickstart and add feature examples by @cmarteepants #189

### Breaking changes
- Removed support for Python 3.7
- The license was changed from MIT to Apache 2.0

Closes: #217
pankajastro pushed a commit that referenced this pull request Jun 27, 2025
`expandvars` was initially added to `get_python_callable` to avoid the
hard coded path for Py files
#116. Then env var support
is added to the entire YAML content
#236. This makes
`expandvars` no longer needed in the `get_python_callable` function,
hence this PR removes it for better performance.

Co-authored-by: Young Li <gyli@uber.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants