fix(office): 延迟导入业务模块并补充 .airflowignore 及 __main__ 保护以解决 DagBag 导入超时
This commit is contained in:
@@ -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
@@ -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月的日期范围
|
||||
|
||||
Reference in New Issue
Block a user