优化动态安装
This commit is contained in:
@@ -1,9 +1,29 @@
|
|||||||
from airflow.operators.bash import BashOperator
|
from airflow.operators.bash import BashOperator
|
||||||
import pendulum
|
import pendulum
|
||||||
|
from airflow import DAG as AirflowDAG
|
||||||
|
from airflow.models import DagRun
|
||||||
|
from airflow.utils.dates import cron_presets, parse_execution_date
|
||||||
|
from airflow.configuration import conf
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
from .. import parent_dag
|
|
||||||
|
|
||||||
with parent_dag.DAG(
|
class DAG(AirflowDAG):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
if conf.getboolean('core', 'security') and 'install_dependencies' not in self.dag_id:
|
||||||
|
self._install_dependencies()
|
||||||
|
|
||||||
|
def _install_dependencies(self):
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip install elasticsearch==7.11.0 transbigdata==0.4.15 pykalman==0.9.5 -i https://repo.fangjia.com/repository/pypi-public/simple/",
|
||||||
|
"pip install -I goojia_utils -i https://repo.fangjia.com/repository/pypi-public/simple/"])
|
||||||
|
|
||||||
|
def run(self, *args, **kwargs):
|
||||||
|
self._install_dependencies()
|
||||||
|
super().run(*args, **kwargs)
|
||||||
|
|
||||||
|
with DAG(
|
||||||
"amap_key_generate_dag",
|
"amap_key_generate_dag",
|
||||||
# 每天运行
|
# 每天运行
|
||||||
schedule_interval="0 2 * * *",
|
schedule_interval="0 2 * * *",
|
||||||
|
|||||||
Reference in New Issue
Block a user