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 5, 2025
1 parent c692b08 commit a93fb43
Show file tree
Hide file tree
Showing 82 changed files with 1,903 additions and 386 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
21 changes: 14 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,19 @@ repos:
pass_filenames: true
files: ^providers/src/airflow/providers/.*/(operators|transfers|sensors)/.*\.py$
additional_dependencies: [ 'rich>=12.4.4' ]
- id: update-providers-init-py
name: Update providers __init__.py files
entry: ./scripts/ci/pre_commit/update_providers_init.py
- id: update-providers-build-files
name: Update providers build files files
entry: ./scripts/ci/pre_commit/update_providers_build_files.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/[^\/]*/src/airflow/providers/[^\/]*/__init__.py$|
^providers/[^\/]*/[^\/]*/src/airflow/providers/[^\/]*/[^\/]*/__init__.py$|
^providers/.*/provider.yaml$|
^airflow_breeze/templates/PROVIDER__INIT__PY_TEMPLATE.py.jinja2$
^airflow_breeze/templates/get_provider_info_TEMPLATE.py.jinja2$
^airflow_breeze/templates/PROVIDER_README_TEMPLATE.rst.jinja2$
additional_dependencies: ['rich>=12.4.4','requests']
require_serial: true
- id: ruff
Expand Down Expand Up @@ -692,8 +699,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 @@ -772,6 +778,7 @@ repos:
entry: ./scripts/ci/pre_commit/check_license.py
language: python
files: ^.*LICENSE.*$|^.*LICENCE.*$
exclude: ^providers/.*/src/.*/LICENSE$
pass_filenames: false
- id: check-aiobotocore-optional
name: Check if aiobotocore is an optional dependency only
Expand Down Expand Up @@ -1367,7 +1374,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 a93fb43

Please sign in to comment.