fix(office): 延迟导入业务模块并补充 .airflowignore 及 __main__ 保护以解决 DagBag 导入超时
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
from airflow.providers.standard.operators.bash import BashOperator
|
||||
from airflow.operators.python import PythonOperator, BranchPythonOperator
|
||||
from airflow.operators.empty import EmptyOperator
|
||||
from office.sell.base_price import calc
|
||||
from office.sell.fill_base_price import fill_base_price
|
||||
import pendulum
|
||||
|
||||
from airflow import DAG
|
||||
|
||||
|
||||
def run_base_price_calc(**kwargs):
|
||||
from office.sell.base_price import calc
|
||||
return calc(**kwargs)
|
||||
|
||||
|
||||
def run_fill_base_price(**kwargs):
|
||||
from office.sell.fill_base_price import fill_base_price
|
||||
return fill_base_price(**kwargs)
|
||||
|
||||
|
||||
def choose_task(**context):
|
||||
"""根据 dag_run.conf 决定执行哪个任务"""
|
||||
conf = context['dag_run'].conf or {}
|
||||
@@ -56,14 +64,14 @@ with DAG(
|
||||
# 任务1: 写字楼出售基础价格计算
|
||||
t1 = PythonOperator(
|
||||
task_id='office_sell_base_price_calc',
|
||||
python_callable=calc,
|
||||
python_callable=run_base_price_calc,
|
||||
# 🛡️ 已安全移除 provide_context=True
|
||||
)
|
||||
|
||||
# 任务2: 无样本写字楼出售基础价格填充
|
||||
t2 = PythonOperator(
|
||||
task_id='office_no_sample_sell_base_price_calc',
|
||||
python_callable=fill_base_price,
|
||||
python_callable=run_fill_base_price,
|
||||
# 🛡️ 已安全移除 provide_context=True
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user