Skip to content

Commit 0de31bd

Browse files
authored
Move provider dependencies to inside provider folders (#24672)
The ``setup.py`` had ALWAUS contained provider dependencies, but this is really a remnant of Airlfow 1.10 where providers were not separated out to subfolders of "providers". This change moves all the provider-specific dependencies to provider.yaml where they are kept together with all other provider meta-data. Later, when we move providers out, we can move them to provider specific setup.py files (or let provider-specific setup.py files read them from provider.yaml) but this is not something we want to do it now. The dependencies.json is now renamed to provider_dependencies.json and moved to "airflow" so tha it can be kept as part of the sources needed for sdist package to provide extras. Pre-commit still generates the file as needed and it contains now both: * cross-provider-deps information which providers depend on each other * deps - information what regular dependencies are needed for each provider On top of preparing to splitting providers it has the advantage, that there will be no more case where adding a dependency change for provider will not run tests for that provider.
1 parent 41aa9ab commit 0de31bd

File tree

108 files changed

+2433
-1343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+2433
-1343
lines changed

β€Ž.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@
7474
!setup.cfg
7575
!setup.py
7676
!manifests
77+
!generated
7778
# Now - ignore unnecessary files inside allowed directories
7879
# This goes after the allowed directories
7980

8081
# Git version is dynamically generated
8182
airflow/git_version
82-
8383
# Exclude static www files generated by NPM
8484
airflow/www/static/coverage
8585
airflow/www/static/dist

β€Ž.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
840840
if: always()
841841

842842
prepare-test-provider-packages-sdist:
843-
timeout-minutes: 40
843+
timeout-minutes: 80
844844
name: "Build and test provider packages sdist"
845845
runs-on: ${{ fromJson(needs.build-info.outputs.runsOn) }}
846846
needs: [build-info, wait-for-ci-images]

β€Ž.pre-commit-config.yaml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,11 @@ repos:
363363
pass_filenames: false
364364
- id: update-providers-dependencies
365365
name: Update cross-dependencies for providers packages
366-
entry: ./scripts/ci/pre_commit/pre_commit_build_providers_dependencies.sh
366+
entry: ./scripts/ci/pre_commit/pre_commit_build_providers_dependencies.py
367367
language: python
368-
files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$
368+
files: ^airflow/providers/.*\.py$|^tests/providers/.*\.py$|^tests/system/providers/.*\.py$|$airflow/providers/.*/provider.yaml$
369369
pass_filenames: false
370-
additional_dependencies: ['setuptools']
370+
additional_dependencies: ['setuptools', 'rich>=12.4.4', 'pyyaml']
371371
- id: update-extras
372372
name: Update extras in documentation
373373
entry: ./scripts/ci/pre_commit/pre_commit_insert_extras.py
@@ -620,14 +620,6 @@ repos:
620620
additional_dependencies: ['pyyaml', 'jinja2', 'black==22.3.0', 'tabulate', 'rich>=12.4.4']
621621
require_serial: true
622622
pass_filenames: false
623-
- id: check-airflow-providers-have-extras
624-
name: Checks providers available when declared by extras in setup.py
625-
language: python
626-
entry: ./scripts/ci/pre_commit/pre_commit_check_extras_have_providers.py
627-
files: ^setup\.py$|^airflow/providers/.*\.py$
628-
pass_filenames: false
629-
require_serial: true
630-
additional_dependencies: ['rich>=12.4.4']
631623
- id: update-breeze-readme-config-hash
632624
name: Update Breeze README.md with config files hash
633625
language: python
@@ -863,5 +855,5 @@ repos:
863855
entry: ./scripts/ci/pre_commit/pre_commit_migration_reference.py
864856
pass_filenames: false
865857
files: ^airflow/migrations/versions/.*\.py$|^docs/apache-airflow/migrations-ref\.rst$
866-
additional_dependencies: ['rich>=12.4.4', 'inputimeout']
858+
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'markdown-it-py']
867859
## ONLY ADD PRE-COMMITS HERE THAT REQUIRE CI IMAGE

β€ŽCONTRIBUTING.rst

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,23 @@ Provider packages
637637
Airflow 2.0 is split into core and providers. They are delivered as separate packages:
638638

639639
* ``apache-airflow`` - core of Apache Airflow
640-
* ``apache-airflow-providers-*`` - More than 50 provider packages to communicate with external services
640+
* ``apache-airflow-providers-*`` - More than 70 provider packages to communicate with external services
641+
642+
The information/meta-data about the providers is kept in ``provider.yaml`` file in the right sub-directory
643+
of ``airflow\providers``. This file contains:
644+
645+
* package name (``apache-airflow-provider-*``)
646+
* user-facing name of the provider package
647+
* description of the package that is available in the documentation
648+
* list of versions of package that have been released so far
649+
* list of dependencies of the provider package
650+
* list of additional-extras that the provider package provides (together with dependencies of those extras)
651+
* list of integrations, operators, hooks, sensors, transfers provided by the provider (useful for documentation generation)
652+
* list of connection types, extra-links, secret backends, auth backends, and logging handlers (useful to both
653+
register them as they are needed by Airflow and to include them in documentation automatically).
654+
655+
If you want to add dependencies to the provider, you should add them to the corresponding ``provider.yaml``
656+
and Airflow pre-commits and package generation commands will use them when preparing package information.
641657

642658
In Airflow 1.10 all those providers were installed together within one single package and when you installed
643659
airflow locally, from sources, they were also installed. In Airflow 2.0, providers are separated out,
@@ -656,7 +672,7 @@ in this airflow folder - the providers package is importable.
656672
Some of the packages have cross-dependencies with other providers packages. This typically happens for
657673
transfer operators where operators use hooks from the other providers in case they are transferring
658674
data between the providers. The list of dependencies is maintained (automatically with pre-commits)
659-
in the ``airflow/providers/dependencies.json``. Pre-commits are also used to generate dependencies.
675+
in the ``generated/provider_dependencies.json``. Pre-commits are also used to generate dependencies.
660676
The dependency list is automatically used during PyPI packages generation.
661677

662678
Cross-dependencies between provider packages are converted into extras - if you need functionality from
@@ -666,49 +682,8 @@ the other provider package you can install it adding [extra] after the
666682
transfer operators from Amazon ECS.
667683

668684
If you add a new dependency between different providers packages, it will be detected automatically during
669-
pre-commit phase and pre-commit will fail - and add entry in dependencies.json so that the package extra
670-
dependencies are properly added when package is installed.
671-
672-
You can regenerate the whole list of provider dependencies by running this command (you need to have
673-
``pre-commits`` installed).
674-
675-
.. code-block:: bash
676-
677-
pre-commit run build-providers-dependencies
678-
679-
680-
Here is the list of packages and their extras:
681-
682-
683-
.. START PACKAGE DEPENDENCIES HERE
684-
685-
========================== ===========================
686-
Package Extras
687-
========================== ===========================
688-
airbyte http
689-
amazon apache.hive,cncf.kubernetes,exasol,ftp,google,imap,mongo,salesforce,ssh
690-
apache.beam google
691-
apache.druid apache.hive
692-
apache.hive amazon,microsoft.mssql,mysql,presto,samba,vertica
693-
apache.livy http
694-
dbt.cloud http
695-
dingding http
696-
discord http
697-
google amazon,apache.beam,apache.cassandra,cncf.kubernetes,facebook,microsoft.azure,microsoft.mssql,mysql,oracle,postgres,presto,salesforce,sftp,ssh,trino
698-
hashicorp google
699-
microsoft.azure google,oracle,sftp
700-
mysql amazon,presto,trino,vertica
701-
postgres amazon
702-
presto google,slack
703-
salesforce tableau
704-
sftp ssh
705-
slack http
706-
snowflake slack
707-
trino google
708-
========================== ===========================
709-
710-
.. END PACKAGE DEPENDENCIES HERE
711-
685+
and pre-commit will generate new entry in ``generated/provider_dependencies.json`` so that
686+
the package extra dependencies are properly handled when package is installed.
712687

713688
Developing community managed provider packages
714689
----------------------------------------------

β€ŽDockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,8 +1321,8 @@ RUN REMOVE_ARTIFACTS="false" BUILD_TYPE="build" bash /scripts/docker/compile_www
13211321
# So in case setup.py changes we can install latest dependencies required.
13221322
COPY setup.py ${AIRFLOW_SOURCES}/setup.py
13231323
COPY setup.cfg ${AIRFLOW_SOURCES}/setup.cfg
1324-
13251324
COPY airflow/__init__.py ${AIRFLOW_SOURCES}/airflow/
1325+
COPY generated/provider_dependencies.json ${AIRFLOW_SOURCES}/generated/
13261326

13271327
COPY --from=scripts install_airflow.sh /scripts/docker/
13281328

β€ŽMANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ include airflow/customized_form_field_behaviours.schema.json
3838
include airflow/serialization/schema.json
3939
include airflow/utils/python_virtualenv_script.jinja2
4040
include airflow/utils/context.pyi
41+
include generated

β€ŽSTATIC_CODE_CHECKS.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ require Breeze Docker image to be build locally.
140140
+--------------------------------------------------------+------------------------------------------------------------------+---------+
141141
| check-airflow-config-yaml-consistent | Checks for consistency between config.yml and default_config.cfg | |
142142
+--------------------------------------------------------+------------------------------------------------------------------+---------+
143-
| check-airflow-providers-have-extras | Checks providers available when declared by extras in setup.py | |
144-
+--------------------------------------------------------+------------------------------------------------------------------+---------+
145143
| check-apache-license-rat | Check if licenses are OK for Apache | |
146144
+--------------------------------------------------------+------------------------------------------------------------------+---------+
147145
| check-base-operator-partial-arguments | Check BaseOperator and partial() arguments | |

0 commit comments

Comments
 (0)