我一直在使用Dataprep构建数据流模板。
从https://console.cloud.google.com/dataflow/createjob运行它-没问题。它会提示您输入参数(区域端点,输入位置,输出位置,临时文件的自定义位置),而元数据文件基本上会为我提供答案。
当我开始使用REST API从Python运行自定义模板时,我将包括以下参数(很多引号转义)
BODY = {
"jobName": "{jobname}".format(jobname=JOBNAME),
"parameters": {
"customGcsTempLocation": "gs://{bucket}/dts/temp".format(bucket=BUCKET),
"inputLocations":"{{\"location1\": \"projectname:DATASET.table\",\"location2\": \"projectname:DATASET.table\",\"location3\": \"projectname:DATASET.table\",\"location4\": \"gs://bucket/filename.csv\",\"location5\":\"projectname:DATASET.table\",\"location6\":\"projectname:DATASET.table\",\"location7\":\"projectname:DATASET.table\",\"location8\":\"projectname:DATASET.table\",\"location9\": [\"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename\"]}}",
"outputLocations":"{{\"projectname:DATASET.table\"}}"
},
"environment": {
"tempLocation": "gs://{bucket}/dts/temp".format(bucket=BUCKET)
}
}
我得到的错误是“模板参数无效”,但没有更多细节;我不确定是否遗漏了某些东西,包括我不应该错过的东西,或者错误地转义了某些东西(诸如this之类的其他问题似乎表明后者并不少见)。任何建议表示赞赏,谢谢
答案 0 :(得分:1)
在过去的6到7个小时里,我一直遇到同样的问题,终于使它起作用。似乎导致此问题的参数是“ tempLocation”。同样,您似乎在输入和输出位置参数中还有一组{}。请尝试以下操作:
BODY = {
"jobName": "{jobname}".format(jobname=JOBNAME),
"parameters": {
"customGcsTempLocation": "gs://{bucket}/dts/temp".format(bucket=BUCKET),
"inputLocations":"{\"location1\": \"projectname:DATASET.table\",\"location2\": \"projectname:DATASET.table\",\"location3\": \"projectname:DATASET.table\",\"location4\": \"gs://bucket/filename.csv\",\"location5\":\"projectname:DATASET.table\",\"location6\":\"projectname:DATASET.table\",\"location7\":\"projectname:DATASET.table\",\"location8\":\"projectname:DATASET.table\",\"location9\": [\"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename.tsv\", \"gs://bucket/folder/filename\"]}",
"outputLocations":"{\"projectname:DATASET.table\"}"
}
}
让我知道这是否对您有用!
答案 1 :(得分:1)
克里斯蒂安(Cristian)是正确的,但我犯了另一个错误,以防在类似情况下对其他人有所帮助。
我应该对location9中的文件名进行不同的重命名,因为它们显然位于列表中(而不只是一个值)。下面显示了如何完成此操作:
\"location9\":\"[\\\"gs://bucket/folder/folder.tsv\\\",\\\"gs://bucket/folder/filename1122.tsv\\\",\\\"gs://bucket/folder/filename1123.tsv\\\",\\\"gs://bucket/folder/filename1124.tsv\\\",\\\"gs://bucket/folder/filename1125.tsv\\\",\\\"gs://bucket/folder/filename1126.tsv\\\",\\\"gs://bucket/folder/filename1127.tsv\\\",\\\"gs://bucket/folder/filename1128.tsv\\\",\\\"gs://bucket/folder/filename1129.tsv\\\",\\\"gs://bucket/folder/filename1201.tsv\\\",\\\"gs://bucket/folder/filename1202.tsv\\\",\\\"gs://bucket/folder/filename1203.tsv\\\",\\\"gs://bucket/folder/filename1204.tsv\\\",\\\"gs://bucket/folder/filename1205.tsv\\\",\\\"gs://bucket/folder/filename1206.tsv\\\",\\\"gs://bucket/folder/filename1207.tsv\\\",\\\"gs://bucket/folder/filename1208.tsv\\\",\\\"gs://bucket/folder/filename1209.tsv\\\",\\\"gs://bucket/folder/filename1210.tsv\\\",\\\"gs://bucket/folder/filename1211.tsv\\\",\\\"gs://bucket/folder/filename1212.tsv\\\"]\"