pendulum.tz.timezone("UTC") TypeError: 'module' object is not callable
Asked Answered
C

2

11

I am facing a issue wherein it is not able to import the airflow modules properly giving the below error. Could someone please help me understand it

10:39:36  ERROR: FileIngestion.test_download_file_mercury (unittest.loader._FailedTest.FileIngestion.test_download_file_mercury)
10:39:36  ----------------------------------------------------------------------
10:39:36  ImportError: Failed to import test module: FileIngestion.test_download_file_mercury
10:39:36  Traceback (most recent call last):
10:39:36    File "/opt/managed-artifacts/python/3.11.6/lib/python3.11/unittest/loader.py", line 419, in _find_test_path
10:39:36      module = self._get_module_from_name(name)
10:39:36               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10:39:36    File "/opt/managed-artifacts/python/3.11.6/lib/python3.11/unittest/loader.py", line 362, in _get_module_from_name
10:39:36      __import__(name)
10:39:36    File "/jenkins/workspace/dataaws-1417_web_proxy_migration/PythonUtils/test/FileIngestion/test_download_file_mercury.py", line 6, in <module>
10:39:36      from PythonUtils.src.FileIngestion import download_file_mercury
10:39:36    File "/jenkins/workspace/dataaws-1417_web_proxy_migration/PythonUtils/src/FileIngestion/download_file_mercury.py", line 2, in <module>
10:39:36      from PythonUtils.src.common.hooks.audit_service import AuditServiceHook
10:39:36    File "/jenkins/workspace/dataaws-1417_web_proxy_migration/PythonUtils/src/common/hooks/audit_service.py", line 6, in <module>
10:39:36      from airflow.utils.log.logging_mixin import LoggingMixin
10:39:36    File "/jenkins/python/lib/python3.11/site-packages/airflow/__init__.py", line 52, in <module>
10:39:36      from airflow import configuration
10:39:36    File "/jenkins/python/lib/python3.11/site-packages/airflow/configuration.py", line 1815, in <module>
10:39:36      secrets_backend_list = initialize_secrets_backends()
10:39:36                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10:39:36    File "/jenkins/python/lib/python3.11/site-packages/airflow/configuration.py", line 1743, in initialize_secrets_backends
10:39:36      secrets_backend_cls = import_string(class_name)
10:39:36                            ^^^^^^^^^^^^^^^^^^^^^^^^^
10:39:36    File "/jenkins/python/lib/python3.11/site-packages/airflow/utils/module_loading.py", line 36, in import_string
10:39:36      module = import_module(module_path)
10:39:36               ^^^^^^^^^^^^^^^^^^^^^^^^^^
10:39:36    File "/opt/managed-artifacts/python/3.11.6/lib/python3.11/importlib/__init__.py", line 126, in import_module
10:39:36      return _bootstrap._gcd_import(name[level:], package, level)
10:39:36             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10:39:36    File "/jenkins/python/lib/python3.11/site-packages/airflow/secrets/metastore.py", line 28, in <module>
10:39:36      from airflow.utils.session import NEW_SESSION, provide_session
10:39:36    File "/jenkins/python/lib/python3.11/site-packages/airflow/utils/session.py", line 24, in <module>
10:39:36      from airflow import settings
10:39:36    File "/jenkins/python/lib/python3.11/site-packages/airflow/settings.py", line 51, in <module>
10:39:36      TIMEZONE = pendulum.tz.timezone("UTC")
10:39:36                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
10:39:36  TypeError: 'module' object is not callable

I tried updating the airflow version but same error is coming. Currently i am using airflow version 2.5.3

Centistere answered 22/12, 2023 at 12:22 Comment(3)
I could replicate issue in apache-airflow==2.5.3 but it seems to be solved in apache-airflow==2.8.0Fundament
What is your pendulum version?Hexylresorcinol
Related discussion of the future of Pendulum in Airflow.Sprayberry
H
14

In pendulum-3.0.0 :

pendulum.tz.timezone is removed.

You can use:

pendulum.timezone("UTC")

Or you downngrade your pendulum to 2.0.0

In pendulum 3 (beta) there is no access to pendulum.tz.timezone anymore otherwise we should call pendulum.timezone for convert string/integer to pendulum timezones

https://www.mail-archive.com/[email protected]/msg299265.html

Hexylresorcinol answered 22/12, 2023 at 17:25 Comment(2)
The thing is i am using airflow which is using this pendulum internally. So how do i manually specify pendulum version?Centistere
@shivaniwadkar Just specify in requirements.txt that no one can go up to 3.0: "pendulum~=2.0.0".Trunks
A
8

The main goal for everyone who use Apache Airflow is follow Installation from PyPI for avoid surprises when upstream package is updated and breaks some critical part of the Airflow, for more detail you could check mail [Reminder] How to reproducibly install Airflow from the users mailing list.

Presumably pendulum 3 support will be added in Airflow 2.8.1, but not sooner. There is no guarantee that 2.8.1 would have this support, so better check Airflow's Release Notes when new version of Airflow would be released.

Update: 2024-01-19

Airflow 2.8.1 just released, pendulum v3 now is a target version, support of pendulum 2.1.2 keep for a while presumably until Airflow 2.9.

Anniceannie answered 24/12, 2023 at 13:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.