启动模板的python api未知名称找不到字段

2024-10-02 08:18:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经创建并运行了一个DataPrep作业,并尝试在appengine上使用python中的模板。 我可以用

gcloud dataflow jobs run 
    --parameters "inputLocations={\"location1\":\"gs://bucket/folder/*\"},
outputLocations={\"location1\":\"project:dataset.table\"},
customGcsTempLocation=gs://bucket/DataPrep-beta/temp"
--gcs-location gs://bucket/DataPrep-beta/temp/cloud-dataprep-templatename_template

但是尝试在app引擎上使用python

^{pr2}$

我回来了

"Invalid JSON payload received. Unknown name "location1" at 
  'launch_parameters.parameters[1].value': Cannot find field.
Invalid JSON payload received. Unknown name "location1" at 
  'launch_parameters.parameters[2].value': Cannot find field."

我所做的一切似乎都不支持通过口述或json.dumps文件()或str()到“inputLocations”或“outputLocations”。在


Tags: namegsjsonbuckettempunknownbetapayload
2条回答

问题在于您传递的input1output1的格式。 它们必须在引号之间,如下所示:

input1 = '{"location1":"' + input + '" }'
output1 = '{"location1":"' + output + '" }'

我尝试过用与你相同的方式发送请求,但失败了。如果我稍后将其解析回string或json,它也会失败,因为它无法正确解析引号。在

当然,格式和你的问题有关。我有相同的用例需要解决,但是输出的是文件,而不是googlebigquery数据集。对我来说,具有以下BODY参数的代码正在启动google数据流管道:

BODY = {
        "jobName": "{jobname}".format(jobname=JOBNAME),
        "parameters": {
            "inputLocations" : "{{\"location1\":\"gs://{bucket}/employee/input/patient.json\"}}".format(bucket=BUCKET),
            "outputLocations": "{{\"location1\":\"gs://{bucket}/employee/employees.json/file\",\"location2\":\"gs://{bucket}/jobrun/employees_314804/.profiler/profilerTypeCheckHistograms.json/file\",\"location3\":\"gs://{bucket}/jobrun/employees_314804/.profiler/profilerValidValueHistograms.json/file\"}}".format(bucket=BUCKET)
         },
         "environment": {
            "tempLocation": "gs://{bucket}/employee/temp".format(bucket=BUCKET),
            "zone": "us-central1-f"
         }
    }

相关问题 更多 >

    热门问题