我正在尝试通过pycharm在docker中运行气流。运行单元测试时,一切正常。但是,当我尝试执行cli命令时,似乎正在解释我的参数……很奇怪。
这是我通过pycharm在命令行中传递给气流的内容:
trigger_dag etl_pipeline --conf '{"client":"popsicle"}'
脚本路径指的是气流本身,因此这等效于调用:
airflow <above command>
当气流增加时,它会引发以下踪迹:
Traceback (most recent call last):
File "/opt/.pycharm_helpers/pydev/pydevd.py", line 1668, in <module>
main()
File "/opt/.pycharm_helpers/pydev/pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/opt/.pycharm_helpers/pydev/pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/opt/.pycharm_helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/opt/project/venv/bin/airflow", line 27, in <module>
args.func(args)
File "/usr/local/lib/python3.6/site-packages/airflow/bin/cli.py", line 199, in trigger_dag
execution_date=args.exec_date)
File "/usr/local/lib/python3.6/site-packages/airflow/api/client/local_client.py", line 27, in trigger_dag
execution_date=execution_date)
File "/usr/local/lib/python3.6/site-packages/airflow/api/common/experimental/trigger_dag.py", line 49, in trigger_dag
run_conf = json.loads(conf)
File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
当我在中断点设置调试器时,我看到字符串看起来像这样:
s = {str} '\\'{client:quest_providence_health_services_2018_07_31}\\''
请注意,以上是pycharm呈现变量的方式。返回s
将返回:
'\\'{client:quest_providence_health_services_2018_07_31}\\''
我敢肯定那里有太多的引号,但是我不清楚在命令行中只提供两个引号时为什么会有两组单引号。我尝试了完全不使用引号,但这只是给了我一个不同的解析错误。
答案 0 :(得分:1)
引号需要转义:
test/perfdat/$HOSTNAME