Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ on:
pull_request_target: # Also run on pull requests originated from forks
branches: [main]
release:
types: ['published']
types: ["published"]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

Static-Check:
runs-on: ubuntu-latest
steps:
Expand All @@ -26,16 +25,17 @@ jobs:
python-version: "3.12"
architecture: "x64"

- run: pip3 install hatch
- run: uv tool install hatch
- run: hatch run tests.py3.12-2.10:static-check

Run-Unit-Tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
airflow-version: [ "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10" ]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
airflow-version:
["2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10"]
exclude:
- python-version: "3.11"
airflow-version: "2.3"
Expand Down Expand Up @@ -69,6 +69,7 @@ jobs:
- uses: actions/cache@v4
with:
path: |
~/.cache/uv
~/.cache/pip
.local/share/hatch/
key: unit-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('dagfactory/__init__.py') }}
Expand All @@ -80,8 +81,7 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install uv
uv pip install --system hatch
uv tool install hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze

- name: Test DAG Factory against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
Expand All @@ -100,8 +100,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
airflow-version: [ "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10" ]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
airflow-version:
["2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.9", "2.10"]
exclude:
- python-version: "3.11"
airflow-version: "2.3"
Expand Down Expand Up @@ -135,6 +136,7 @@ jobs:
- uses: actions/cache@v4
with:
path: |
~/.cache/uv
~/.cache/pip
.local/share/hatch/
key: integration-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('dagfactory/__init__.py') }}
Expand All @@ -146,8 +148,7 @@ jobs:

- name: Install packages and dependencies
run: |
python -m pip install uv
uv pip install --system hatch
uv tool install hatch
hatch -e tests.py${{ matrix.python-version }}-${{ matrix.airflow-version }} run pip freeze

- name: Test DAG Factory against Airflow ${{ matrix.airflow-version }} and Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -183,7 +184,7 @@ jobs:
python-version: "3.11"
- name: Install coverage
run: |
pip3 install coverage
uv tool install coverage
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -219,7 +220,7 @@ jobs:
architecture: "x64"

- name: Install packages and dependencies
run: pip install hatch
run: uv tool install hatch

- name: Deploy Docs
run: |
Expand Down Expand Up @@ -248,13 +249,9 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: 'x64'
python-version: "3.10"
architecture: "x64"
- name: Verify Git Tag and package version
run: python3 ./scripts/verify_tag_and_version.py
- run: pip3 install hatch
- run: hatch build
- run: hatch publish
env:
HATCH_INDEX_USER: __token__
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
- run: uv build --wheel --sdist
- run: uv publish --token ${{ secrets.PYPI_TOKEN }}
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ help:

.PHONY: setup
setup: ## Setup development environment
python -m venv venv
. venv/bin/activate && pip --no-cache-dir install ".[tests]"
uv venv venv
@echo "Installing dependencies with uv..."
uv pip install --python venv/bin/python -e ".[tests]"
@echo "To activate the virtual environment, run:"
@echo "source venv/bin/activate"

.PHONY: clean
clean: ## Removes build and test artifacts
@echo "==> Removing build and test artifacts"
@rm -rf *.egg *egg-info .cache .coverage .tox build bin include dist htmlcov lib .pytest_cache .venv
@rm -rf *.egg *egg-info .cache .coverage .tox build bin include dist htmlcov lib .pytest_cache .venv venv
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@find . -name '*~' -exec rm -f {} +
Expand All @@ -24,7 +25,7 @@ build-whl: ## Build installable whl file
rm -rf dev/include/*
rm -rf dist/*
mkdir -p dev/include
hatch build
uv build --wheel --sdist
cp dist/* dev/include/

.PHONY: docker-run
Expand Down
5 changes: 4 additions & 1 deletion dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ RUN apt-get update && apt-get install -y jq

USER astro

RUN pip install /usr/local/airflow/include/*.whl
# Install uv for faster package management
RUN pip install uv

RUN uv pip install --system /usr/local/airflow/include/*.whl
66 changes: 48 additions & 18 deletions docs/contributing/howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ To contribute to the DAG Factory project:
### Requirements

- [Git](https://git-scm.com/)
- [Python](https://www.python.org/) <= 3.12 (due to dependencies, such as ``google-re2`` not supporting Python 3.13 yet)
- [Hatch](https://hatch.pypa.io/latest/)
- [Python](https://www.python.org/) <= 3.12 (due to dependencies, such as `google-re2` not supporting Python 3.13 yet)
- [uv](https://docs.astral.sh/uv/) (for fast package management)
- [Hatch](https://hatch.pypa.io/latest/) (installed automatically via uv)

Clone the **DAG Factory** repository and change the current working directory to the repo's root directory:

Expand All @@ -46,20 +47,49 @@ After cloning the project, there are two options for setting up the local develo

### Using a Python virtual environment for local development

DAG Factory uses [uv](https://docs.astral.sh/uv/) for fast and reliable package management. The setup process is significantly faster than traditional pip-based installations.

1. Install the project dependencies:

```bash
make setup
```
**Recommended: uv setup (fast, reproducible builds)**

```bash
uv sync --dev
```

**Alternative: Traditional setup**

```bash
make setup
```

Both commands install all dependencies, including test dependencies. The uv option is significantly faster and uses the lockfile for reproducible builds.

2. Activate the local python environment:

```bash
source venv/bin/activate
```
**For uv setup:**

```bash
source .venv/bin/activate
```

**For traditional setup:**

```bash
source venv/bin/activate
```

### Additional uv Commands

Once you're set up with uv, you can use these helpful commands:

- `uv sync` - Sync dependencies from the lockfile
- `uv lock --upgrade` - Update the lockfile with latest dependency versions
- `uv add <package>` - Add a new dependency
- `uv remove <package>` - Remove a dependency

3. Set [Apache Airflow®](https://airflow.apache.org/) home to the ``dev/``, so you can see DAG Factory example DAGs.
Disable loading Airflow standard example DAGs:
3. Set [Apache Airflow®](https://airflow.apache.org/) home to the `dev/`, so you can see DAG Factory example DAGs.
Disable loading Airflow standard example DAGs:

```bash
export AIRFLOW_HOME=$(pwd)/dev/
Expand All @@ -68,15 +98,15 @@ export AIRFLOW__CORE__LOAD_EXAMPLES=false

Then, run Airflow in standalone mode; the command below will create a new user (if it does not exist) and run the necessary Airflow component (webserver, scheduler and triggered):

> Note: By default, Airflow will use sqlite as a database; you can override this by setting the variable ``AIRFLOW__DATABASE__SQL_ALCHEMY_CONN`` to the SQL connection string.
> Note: By default, Airflow will use sqlite as a database; you can override this by setting the variable `AIRFLOW__DATABASE__SQL_ALCHEMY_CONN` to the SQL connection string.

```bash
airflow standalone
```

After Airflow is running, you can access the Airflow UI at ``http://localhost:8080``.
After Airflow is running, you can access the Airflow UI at `http://localhost:8080`.

> Note: whenever you want to start the development server, you need to activate the ``virtualenv`` and set the ``environment variables``
> Note: whenever you want to start the development server, you need to activate the `virtualenv` and set the `environment variables`

### Use Docker for local development

Expand All @@ -86,7 +116,7 @@ It is also possible to build the development environment using [Docker](https://
make docker-run
```

After the sandbox is running, you can access the Airflow UI at ``http://localhost:8080``.
After the sandbox is running, you can access the Airflow UI at `http://localhost:8080`.

This approach builds a DAG Factory wheel, so if there are code changes, you must stop and restart the containers:

Expand Down Expand Up @@ -148,7 +178,7 @@ To run the checks manually, run the following:
pre-commit run --all-files
```

Pre-commit runs several static checks, including Black and Ruff. It is also possible to run them using ``hatch``:
Pre-commit runs several static checks, including Black and Ruff. It is also possible to run them using `hatch`:

```bash
hatch run tests.py3.9-2.9:static-check
Expand All @@ -174,7 +204,7 @@ hatch run docs:gh-release

## Releasing

We currently use [hatch](https://github.com/pypa/hatch) for building and distributing ``dag-factory``.
We currently use [hatch](https://github.com/pypa/hatch) for building and distributing `dag-factory`.

We use GitHub actions to create and deploy new releases. To create a new release, update the latest release version.

Expand All @@ -196,6 +226,6 @@ If you're a [project maintainer in PyPI](https://pypi.org/project/dag-factory/),
by authenticating to PyPI and running the commands:

```bash
hatch build
hatch publish
uv build --wheel --sdist
uv publish --token <your-pypi-token>
```
20 changes: 10 additions & 10 deletions docs/getting-started/quick-start-airflow-standalone.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ Install [Apache Airflow®](https://airflow.apache.org):

1. Create a directory for your project and navigate to it:

```commandline
mkdir dag-factory-quick-start && cd dag-factory-quick-start
```
```commandline
mkdir dag-factory-quick-start && cd dag-factory-quick-start
```

2. Set the `AIRFLOW_HOME` environment variable:

```commandline
export AIRFLOW_HOME=$(pwd)
export AIRFLOW__CORE__LOAD_EXAMPLES=False
```
```commandline
export AIRFLOW_HOME=$(pwd)
export AIRFLOW__CORE__LOAD_EXAMPLES=False
```

3. Install Apache Airflow:

```commandline
pip install apache-airflow
```
```commandline
pip install apache-airflow
```

## Step 3: Install DAG Factory

Expand Down
40 changes: 38 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Dynamically build Apache Airflow DAGs from YAML files"
authors = [{ name = "Astronomer", email = "humans@astronomer.io" }]
readme = "README.md"
license = "Apache-2.0"
license-files = { paths = ["LICENSE"] }
license-files = ["LICENSE"]
requires-python = ">=3.8"
keywords = ["airflow", "apache-airflow", "provider", "astronomer", "dag"]
classifiers = [
Expand All @@ -29,7 +29,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
dependencies = [
"apache-airflow>=2.3",
"apache-airflow>=2.3,<3.0",
Comment thread
jlaneve marked this conversation as resolved.
"apache-airflow-providers-http>=2.0.0",
"apache-airflow-providers-cncf-kubernetes",
"pyyaml",
Expand All @@ -45,6 +45,42 @@ tests = [
"pre-commit",
]

######################################
# UV CONFIGURATION
######################################

[tool.uv]
dev-dependencies = [
"dag-factory[tests]",
"pre-commit",
"pytest>=6.0",
"pytest-cov",
"apache-airflow-providers-slack",
"httpx>=0.25.0",
"pandas",
]

# Respect existing constraints for Airflow compatibility
constraint-dependencies = [
"apache-airflow>=2.3",
]

[tool.uv.workspace]
# Enable workspace mode for better dependency management
members = ["."]

[tool.uv.pip]
# Use more efficient resolution strategy
resolution = "highest"
# Respect existing pip-compatible behavior for scripts
system = false
# Optimize for CI/CD performance
compile-bytecode = true

[tool.uv.sources]
# Add custom package sources if needed in the future
# Example: custom-package = { url = "https://custom-repo.com/simple" }

######################################
# TESTING
######################################
Expand Down
Loading