question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Circular package imports in Airflow 2.0

See original GitHub issue

Apache Airflow version: 2.0.0

Kubernetes version (if you are using kubernetes) (use kubectl version): N/A

Environment:

  • Cloud provider or hardware configuration: N/A
  • OS (e.g. from /etc/os-release): OSX
  • Kernel (e.g. uname -a): Darwin Jonathons-MacBook-Pro-16-inch-2019 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64 x86_64
  • Install tools: Bazel ?
  • Others:

What happened:

A user of bazelbuild/rules_python had trouble installing apache-airflow==2.0.0 with the Bazel build system reporting a “cycle in dependency graph” error.

Investigating the issue, I found the following in setup.py which does not seem accurate.

# Those providers are pre-installed always when airflow is installed.
# Those providers do not have dependency on airflow2.0 because that would lead to circular dependencies.
# This is not a problem for PIP but some tools (pipdeptree) show those as a warning.
PREINSTALLED_PROVIDERS = [
    'ftp',
    'http',
    'imap',
    'sqlite',
] 

Specifically this claim:

Those providers do not have dependency on airflow2.0

I appears they do have this dependency, and it does lead to circular dependencies:

.-> @py_deps//pypi__apache_airflow:pypi__apache_airflow
|   @py_deps//pypi__apache_airflow_providers_sqlite:pypi__apache_airflow_providers_sqlite
`-- @py_deps//pypi__apache_airflow:pypi__apache_airflow

In that same Github issue a colleague provides further investigation of the Airflow 2.0 wheel: https://github.com/bazelbuild/rules_python/issues/411#issuecomment-772306099

What you expected to happen:

apache-airflow==2.0.0 would not have circular deps and thus could be importable in build systems that do not allow circular dependencies (eg. Bazel)

How to reproduce it:

Issue https://github.com/bazelbuild/rules_python/issues/411 contains a reproduction repository: https://github.com/gvacaliuc/rules_python_airflow2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
thekyzcommented, Mar 31, 2021

Thanks for the links, definitely appreciated!

I managed to make it work by depending directly on the providers + apache-airflow, since then the dependency on the extras is not expressed.

For reference if somebody is encountering the same issue as me, this:

apache-airflow-providers-cncf-kubernetes==1.0.2
apache-airflow-providers-postgres==1.0.1
apache-airflow[statsd]==2.0.1

instead of this:

apache-airflow[statsd,postgres,kubernetes]==2.0.1

Thanks again @potiuk for the support!

0reactions
potiukcommented, Mar 31, 2021

And here is explanation about airflow’s extras http://airflow.apache.org/docs/apache-airflow/stable/extra-packages-ref.html - it’s rather straightforward and helpful I think

Read more comments on GitHub >

github_iconTop Results From Across the Web

Provider packages — apache-airflow-providers Documentation
From the point of view of the community, Airflow is delivered in multiple, separate packages. The core of Airflow scheduling system is delivered...
Read more >
Modules Management — Airflow Documentation
The relative imports are counter-intuitive, and depending on how you start your python code, they can behave differently. In Airflow the same DAG...
Read more >
Release Notes — Airflow Documentation
The 2.0 release of the Airflow is a significant upgrade, and includes substantial major changes, and some of them may be breaking. Existing...
Read more >
Source code for airflow.models.dag
The ASF licenses this file # to you under the Apache License, Version 2.0 (the ... from airflow.models.baseoperator import BaseOperator # Avoid circular...
Read more >
Source code for airflow.models.dag
The ASF licenses this file # to you under the Apache License, Version 2.0 (the ... airflow.operators.subdag import SubDagOperator # Avoid circular import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found