Skip to content

Commit

Permalink
Move first provider (airbyte) to a separate project
Browse files Browse the repository at this point in the history
This is the first step to move providers to separate
projects inside our monorepo.

Airbyte is a first provider that is separated out to a
project under "providers/<PROVIDER_ID>" directory. This has
the nice property that all files belonging to the same provider
are under a single directory that is part of the Airflow
workspace. For now the code is more complex because we are
handling providers being in either "old" or "new" structure, but
once we move old providers to the new structure, a lot of code
could be removed and simplified.

The new structure for provider code is:

```
providers
        |- PROVIDER_ID
        |            |- src
        |            |    |-airflow
        |            |            |- providers
        |            |                       |- PROVIDER_ID
        |            |- tests
        |            |      |- providers
        |            |                 |- PROVIDER_ID
        |            |- docs
        |            |     |- .latest-doc-only-changes.txt
        |            |- pyproject.toml
        |            |- CHANGELOG.rst
        |            |- provider.yaml
        |            |- README.rst
        |- PROVIDER_ID2
        ...

```
  • Loading branch information
potiuk committed Jan 2, 2025
1 parent f236ab1 commit a8e5708
Show file tree
Hide file tree
Showing 64 changed files with 1,450 additions and 302 deletions.
7 changes: 3 additions & 4 deletions .github/boring-cyborg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@

labelPRBasedOnFilePath:
provider:airbyte:
- providers/src/airflow/providers/airbyte/**/*
- docs/apache-airflow-providers-airbyte/**/*
- providers/tests/airbyte/**/*
- providers/tests/system/airbyte/**/*
- providers/airbyte/src/airflow/providers/airbyte/**/*
- providers/airbyte/docs/**/*
- providers/airbyte/tests/**/*

provider:alibaba:
- providers/src/airflow/providers/alibaba/**/*
Expand Down
12 changes: 8 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,12 @@ repos:
entry: ./scripts/ci/pre_commit/update_providers_init.py
language: python
pass_filenames: true
files: ^providers/[^\/]*/__init__.py$|^providers/[^\/]*/[^\/]*/__init__.py$|^providers/.*/provider.yaml$|^airflow_breeze/templates/PROVIDER__INIT__PY_TEMPLATE.py.jinja2^
files: |
(?x)
^providers/[^\/]*/__init__.py$|
^providers/[^\/]*/[^\/]*/__init__.py$|
^providers/.*/provider.yaml$|
^airflow_breeze/templates/PROVIDER__INIT__PY_TEMPLATE.py.jinja2$
additional_dependencies: ['rich>=12.4.4','requests']
require_serial: true
- id: ruff
Expand Down Expand Up @@ -692,8 +697,7 @@ repos:
^airflow/decorators/.*$|
^airflow/hooks/.*$|
^airflow/operators/.*$|
^providers/src/airflow/providers/.*$|
^providers/src/airflow/providers/standard/sensors/.*$|
^providers/.*$|
^dev/provider_packages/.*$
- id: check-base-operator-usage
language: pygrep
Expand Down Expand Up @@ -1367,7 +1371,7 @@ repos:
name: Validate provider.yaml files
entry: ./scripts/ci/pre_commit/check_provider_yaml_files.py
language: python
files: ^providers/src/airflow/providers/.*/provider\.yaml$
files: ^providers/src/airflow/providers/.*/provider\.yaml$|^providers/.*/src/provider\.yaml$
additional_dependencies: ['rich>=12.4.4']
require_serial: true
- id: check-template-fields-valid
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ function install_airflow() {
local installation_command_flags
if [[ ${AIRFLOW_INSTALLATION_METHOD} == "." ]]; then
# When installing from sources - we always use `--editable` mode
# TODO(potiuk) when we move all providers to new structure, we will be able to remove all that and
# Use `uv sync` rather than `uv pip install` rather than finding all pyproject toml / projects here
installation_command_flags="--editable .[${AIRFLOW_EXTRAS}]${AIRFLOW_VERSION_SPECIFICATION} --editable ./task_sdk"
while IFS= read -r -d '' pyproject_toml_file; do
project_folder=$(dirname ${pyproject_toml_file})
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ function install_airflow() {
local installation_command_flags
if [[ ${AIRFLOW_INSTALLATION_METHOD} == "." ]]; then
# When installing from sources - we always use `--editable` mode
# TODO(potiuk) when we move all providers to new structure, we will be able to remove all that and
# Use `uv sync` rather than `uv pip install` rather than finding all pyproject toml / projects here
installation_command_flags="--editable .[${AIRFLOW_EXTRAS}]${AIRFLOW_VERSION_SPECIFICATION} --editable ./task_sdk"
while IFS= read -r -d '' pyproject_toml_file; do
project_folder=$(dirname ${pyproject_toml_file})
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/abstractoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
if TYPE_CHECKING:
from collections.abc import Mapping

import jinja2 # Slow import.
import jinja2 # Slow imports.
from sqlalchemy.orm import Session

from airflow.models.baseoperatorlink import BaseOperatorLink
Expand Down
Loading

0 comments on commit a8e5708

Please sign in to comment.