fix(office): 延迟导入业务模块并补充 .airflowignore 及 __main__ 保护以解决 DagBag 导入超时
This commit is contained in:
@@ -3,11 +3,15 @@
|
||||
"""
|
||||
from airflow.providers.standard.operators.bash import BashOperator
|
||||
from airflow.operators.python import PythonOperator, BranchPythonOperator
|
||||
from office.rent.base_price import calc
|
||||
import pendulum
|
||||
from airflow import DAG
|
||||
|
||||
|
||||
def run_base_rent_calc(**kwargs):
|
||||
from office.rent.base_price import calc
|
||||
return calc(**kwargs)
|
||||
|
||||
|
||||
def choose_task(**context):
|
||||
"""根据 dag_run.conf 决定执行哪个任务"""
|
||||
conf = context['dag_run'].conf or {}
|
||||
@@ -50,7 +54,7 @@ with DAG(
|
||||
# 任务2:写字楼租金计算
|
||||
t2 = PythonOperator(
|
||||
task_id='office_base_rent_calc',
|
||||
python_callable=calc,
|
||||
python_callable=run_base_rent_calc,
|
||||
# 🛡️ 已移除 provide_context=True,防止 Airflow 3.3.0 报错崩溃
|
||||
)
|
||||
branch_task >> [t1, t2]
|
||||
Reference in New Issue
Block a user