23 lines
804 B
Python
23 lines
804 B
Python
from airflow.providers.docker.operators.docker import DockerOperator
|
|
import pendulum
|
|
from airflow import DAG
|
|
|
|
with DAG(
|
|
dag_id="comm_add_dag",
|
|
schedule_interval=None,
|
|
start_date=pendulum.datetime(2023, 5, 8, tz="Asia/Shanghai"),
|
|
catchup=True,
|
|
description="小区自动化入库"
|
|
) as dag:
|
|
t1 = DockerOperator(
|
|
# 刚才定义的conn id
|
|
docker_conn_id="docker_repo",
|
|
api_version="auto",
|
|
image='192.168.0.19:9012/comm-add:1.0.1',
|
|
# 临沂为我们的传参,python代码中, 镜像中部分代码
|
|
# @ click.command()
|
|
# @ click.option('--city', default="all", help='要计算的城市')
|
|
command='python main.py --city {{dag_run.conf["city"] if "city" in dag_run.conf}} else all',
|
|
task_id='comm_add'
|
|
)
|
|
t1 |