fix(office): 延迟导入业务模块并补充 .airflowignore 及 __main__ 保护以解决 DagBag 导入超时

This commit is contained in:
王文艳
2026-10-19 09:38:44 +08:00
parent 0b7caf6a9f
commit fb8f6400be
6 changed files with 68 additions and 37 deletions
+11 -10
View File
@@ -101,17 +101,18 @@ def calc(city, year_month):
log.info(f"均价补充完毕!")
yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
if __name__ == "__main__":
yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
if yearmonth == '':
date = dateutils.add_months(datetime.today(), months=-1)
yearmonth = int(dateutils.format_date(date, '%Y%m'))
try:
if type(yearmonth) is str:
yearmonth = int(yearmonth)
calc(None, yearmonth)
except Exception as e:
log.error(e)
if yearmonth == '':
date = dateutils.add_months(datetime.today(), months=-1)
yearmonth = int(dateutils.format_date(date, '%Y%m'))
try:
if type(yearmonth) is str:
yearmonth = int(yearmonth)
calc(None, yearmonth)
except Exception as e:
log.error(e)
# # 初始化从2024年9月
# 创建从2024年9月到2024年12月的日期范围
+12 -11
View File
@@ -80,18 +80,19 @@ def calc(city, year_month):
office_sell_stat_conn.bulk_write(actions)
log.info(f"{city} {year_month} 均价计算完毕!")
yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
if __name__ == "__main__":
yearmonth = sys.argv[1] if len(sys.argv) > 1 else ''
if yearmonth == '':
date = dateutils.add_months(datetime.today(), months=-1)
yearmonth = int(dateutils.format_date(date, '%Y%m'))
try:
if type(yearmonth) is str:
yearmonth = int(yearmonth)
for city in areautils.get_all_cities():
calc(city, yearmonth)
except Exception as e:
log.error(e)
if yearmonth == '':
date = dateutils.add_months(datetime.today(), months=-1)
yearmonth = int(dateutils.format_date(date, '%Y%m'))
try:
if type(yearmonth) is str:
yearmonth = int(yearmonth)
for city in areautils.get_all_cities():
calc(city, yearmonth)
except Exception as e:
log.error(e)
# # 初始化从2024年9月
# 创建从2024年9月到2024年12月的日期范围