Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue on airflow 2.6.0 - airflow-db-cleanup.py - No module named 'airflow.jobs.base_job' #132

Open
ITJamie opened this issue May 3, 2023 · 5 comments

Comments

@ITJamie
Copy link

ITJamie commented May 3, 2023

error on import of airflow-db-cleanup.py

Broken DAG: [/opt/bitnami/airflow/dags/airflow-db-cleanup.py] Traceback (most recent call last):
  File "/opt/bitnami/airflow/dags/airflow-db-cleanup.py", line 17, in <module>
    from airflow.jobs import BaseJob
ImportError: cannot import name 'BaseJob' from 'airflow.jobs' (/opt/bitnami/airflow/venv/lib/python3.9/site-packages/airflow/jobs/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/opt/bitnami/airflow/dags/airflow-db-cleanup.py", line 19, in <module>
    from airflow.jobs.base_job import BaseJob
ModuleNotFoundError: No module named 'airflow.jobs.base_job'
@ITJamie ITJamie changed the title issue on airflow 3.6.0 - airflow-db-cleanup.py - No module named 'airflow.jobs.base_job' issue on airflow 2.6.0 - airflow-db-cleanup.py - No module named 'airflow.jobs.base_job' May 3, 2023
@ITJamie
Copy link
Author

ITJamie commented May 3, 2023

base_job.py is gone in airflow 2.6.0:
https://github.com/apache/airflow/tree/main/airflow/jobs

@darkag
Copy link

darkag commented May 4, 2023

I've replaced
try:
from airflow.jobs import BaseJob
except Exception as e:
from airflow.jobs.base_job import BaseJob

by

try:
from airflow.jobs.job import Job as BaseJob
except Exception as e:
try:
from airflow.jobs.base_job import BaseJob
except Exception as e:
from airflow.jobs import BaseJob

it seems to work (I changed the order of import since I'm in 2.6 and it's not useful to try import that will fail)

@ebdavison
Copy link

ebdavison commented Aug 28, 2023

watching; have same problem and the code update from darkag also fixed my import error

@jasminehung
Copy link

I've replaced try: from airflow.jobs import BaseJob except Exception as e: from airflow.jobs.base_job import BaseJob

by

try: from airflow.jobs.job import Job as BaseJob except Exception as e: try: from airflow.jobs.base_job import BaseJob except Exception as e: from airflow.jobs import BaseJob

it seems to work (I changed the order of import since I'm in 2.6 and it's not useful to try import that will fail)

Thanks, worked successfully on airflow 2.7

@camilo863
Copy link

#131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants