我的Aitflow流程有以下结构:
dags/mainDag.py
dags/BigQuery/deleteData.py
dags/BigQuery/insertData.py
dags/support/gcp.json
dags/support/__init__py
我的mainDag.py
正在调用deleteData.py
和insertData.py
,这很有效!但我的问题是:在这两个文件中,我使用的gcp.json
如下:
credentialsPath = "~/airflow/dags/support/gqp.json"
bigqueryClient = bigquery.Client.from_service_account_json(credentialsPath)
在Airflow Web服务器中,我有一个错误:
FileNotFoundError: [Errno 2] No such file or directory: '~/airflow/dags/support/gqp.json'
但是我可以使用此路径成功地在bash上对文件内容进行cat。 我在书堆里读了这两个问题,[airflow: how can i put the method for read a json file in a local library和[Airflow - Python file NOT in the same DAG folder,但这两个问题都不起作用! 有人知道如何解决这个问题吗
如果您尝试:
您将看到输出为} 函数执行此操作:
False
。这是因为python不会将~
扩展到用户主目录。可以使用^{现在,这将输出
True
,因为您的文件路径已使用主目录展开相关问题 更多 >
编程相关推荐