Airflow end_date error AttributeError: 'tuple' object has no attribute 'utcoffset'
Airflow end_date error AttributeError: 'tuple' object has no attribute 'utcoffset'
我想向我的 DAG 添加一个 end_date,但是,当我 运行 特定的 DAG 时,我得到了上述错误。这看起来很奇怪,因为我可以用相同的格式更新开始日期,但不能更新结束日期。
下面是我的代码示例。
default_args = base_args.copy()
default_args['end_date'] = datetime(2020, 5, 5)
dag = DAG(
dag_name,
catchup=True,
default_args=default_args,
schedule_interval=schedule_interval
)
with dag:
extract = BashOperator(
task_id=dag_name
)
这是回溯
Traceback (most recent call last):
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/models/__init__.py", line 413, in process_file
m = imp.load_source(mod_name, filepath)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py", line 171, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/stevepak/Desktop/airflow/Dags/braintree/braintree_transactions_v3.py", line 40, in <module>
schedule_interval=schedule_interval
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/models/__init__.py", line 3087, in __init__
timezone.convert_to_utc(self.default_args['end_date'])
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/utils/timezone.py", line 92, in convert_to_utc
if not is_localized(value):
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/utils/timezone.py", line 38, in is_localized
return value.utcoffset() is not None
AttributeError: 'tuple' object has no attribute 'utcoffset'
Traceback (most recent call last):
File "/Users/steve/.virtualenvs/airflow/bin/airflow", line 32, in <module>
args.func(args)
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/utils/cli.py", line 74, in wrapper
return f(*args, **kwargs)
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/bin/cli.py", line 647, in test
dag = dag or get_dag(args)
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/bin/cli.py", line 145, in get_dag
'parse.'.format(args.dag_id))
代码中一些额外的逗号创建了这个。特别是在以下行中:
修正前:
import pendulum
local_tz = pendulum.timezone("America/Los_Angeles")
date = datetime(2021, 8, 3, tzinfo=local_tz),
有类似的问题。造成问题的是额外的“,”。
修复后:
import pendulum
local_tz = pendulum.timezone("America/Los_Angeles")
date = datetime(2021, 8, 3, tzinfo=local_tz)
我想向我的 DAG 添加一个 end_date,但是,当我 运行 特定的 DAG 时,我得到了上述错误。这看起来很奇怪,因为我可以用相同的格式更新开始日期,但不能更新结束日期。
下面是我的代码示例。
default_args = base_args.copy()
default_args['end_date'] = datetime(2020, 5, 5)
dag = DAG(
dag_name,
catchup=True,
default_args=default_args,
schedule_interval=schedule_interval
)
with dag:
extract = BashOperator(
task_id=dag_name
)
这是回溯
Traceback (most recent call last):
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/models/__init__.py", line 413, in process_file
m = imp.load_source(mod_name, filepath)
File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py", line 171, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/stevepak/Desktop/airflow/Dags/braintree/braintree_transactions_v3.py", line 40, in <module>
schedule_interval=schedule_interval
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/models/__init__.py", line 3087, in __init__
timezone.convert_to_utc(self.default_args['end_date'])
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/utils/timezone.py", line 92, in convert_to_utc
if not is_localized(value):
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/utils/timezone.py", line 38, in is_localized
return value.utcoffset() is not None
AttributeError: 'tuple' object has no attribute 'utcoffset'
Traceback (most recent call last):
File "/Users/steve/.virtualenvs/airflow/bin/airflow", line 32, in <module>
args.func(args)
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/utils/cli.py", line 74, in wrapper
return f(*args, **kwargs)
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/bin/cli.py", line 647, in test
dag = dag or get_dag(args)
File "/Users/steve/.virtualenvs/airflow/lib/python3.7/site-packages/airflow/bin/cli.py", line 145, in get_dag
'parse.'.format(args.dag_id))
代码中一些额外的逗号创建了这个。特别是在以下行中:
修正前:
import pendulum
local_tz = pendulum.timezone("America/Los_Angeles")
date = datetime(2021, 8, 3, tzinfo=local_tz),
有类似的问题。造成问题的是额外的“,”。
修复后:
import pendulum
local_tz = pendulum.timezone("America/Los_Angeles")
date = datetime(2021, 8, 3, tzinfo=local_tz)