Airflow 如何实现气流中任务的动态生成
基本上,我想实现这样的目标 我不知道如何确保可以一致地调用任务id。我用蟒蛇机试着打电话给kwargs 我的一个功能是:Airflow 如何实现气流中任务的动态生成,airflow,Airflow,基本上,我想实现这样的目标 我不知道如何确保可以一致地调用任务id。我用蟒蛇机试着打电话给kwargs 我的一个功能是: def Dynamic_Structure(log_type, callableFunction, context, args): # dyn_value = "{{ task_instance.xcom_pull(task_ids='Extract_{}_test'.format(log_type)) }}" structure_logs = Struc
def Dynamic_Structure(log_type, callableFunction, context, args):
# dyn_value = "{{ task_instance.xcom_pull(task_ids='Extract_{}_test'.format(log_type)) }}"
structure_logs = StrucFile(
task_id = 'Struc_{}_test'.format(log_type),
provide_context = True,
format_location = config.DATASET_FORMAT,
struc_location = config.DATASET_STR,
# log_key_hash_dict_location = dl_config.EXEC_WINDOWS_MIDDLE_KEY_HASH_DICT,
log_key_hash_dict_location = dl_config.DL_MODEL_DATASET/log_type/dl_config.EXEC_MIDDLE_KEY_HASH_DICT,
data_type = 'test',
xcom_push=True,
dag = dag,
op_kwargs=args,
log_sort = log_type,
python_callable = eval(callableFunction),
# the following parameters depend on the format of raw log
regex = config.STRUCTURE_REGEX[log_type],
log_format = config.STRUCTURE_LOG_FORMAT[log_type],
columns = config.STRUCTURE_COLUMNS[log_type]
)
return structure_logs
然后我把它叫做:
for log_type in log_types:
...
structure_logs_task = Dynamic_Structure(log_type, 'values_function', {'previous_task_id': 'Extract_{}_test'.format(log_type)})
但是我不能得到像图表那样的表现
我不知道如何调用以前的任务id。Xcom\u pull和Xcom\u push会有帮助,但我不知道如何在PythonOperator中使用它。问题不在于代码 我试图从.env中读取日志类型的环境。但我并没有找到在docker图像中读取环境变量的正确方法 应该是: 在docker-compose.yml中
version: "x"
services:
xxx:
build:
# there is the space between context and .
context: .
dockerfile: ./Dockerfile
args:
- PORT=${PORT}
volumes:
...
在Dockerfile中
FROM xx
ARG PORT
ENV PORT "$PORT"
EXPOSE ${PORT}
...
在根文件夹中,您可以在.env.中定义参数。检查我认为这不是我的情况。我需要多重配对。这只是一个工作流行。@Newt它没有太大区别(单个“工作流行”或多个“行”,设置方法与之无关)。快速给出几个线索。然后这是非常有用的。希望它能解决你的问题。@y2k shubham。谢谢这真的很有帮助。我要试一试。