简体   繁体   English

AWS Glue:由于缺少元数据而无法启动作业运行

[英]AWS Glue: Failed to start job run due to missing metadata

In order to run a job using boto3, the documentation states only JobName is required.为了使用 boto3 运行作业, 文档说明只需要JobName However, my code:但是,我的代码:

    def start_job_run(self, name):
        print("The name of the job to be run via client is: {}".format(name))
        self.response_de_start_job = self.client.start_job_run(
            JobName=name
        )
        print(self.response_de_start_job)

and the client is:客户是:

    self.client = boto3.client(
            'glue',
            region_name='ap-south-1',
            aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'),
            aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY'),
        )

when executed via Python3, gives out an error:通过 Python3 执行时,会出现错误:

botocore.errorfactory.EntityNotFoundException: An error occurred (EntityNotFoundException) when calling the StartJobRun operation: Failed to start job run due to missing metadata

but when I do the same operation on the same job from UI and from the cli( aws glue start-job-run --job-name march15_9 ), it works all alright.但是当我从 UI 和 cli( aws glue start-job-run --job-name march15_9 )对同一个作业执行相同的操作时,它一切正常。

In my experience the error often means Can not find the job .根据我的经验,错误通常意味着找不到工作 As soon as jobs are bound to regions, a combination of name and region uniquely identifies a job, and errors in any of these (including trivial mistypes) will lead to the error you experience(d).一旦作业绑定到区域,名称和区域的组合将唯一标识作业,并且其中任何一个错误(包括琐碎的错误类型)都会导致您遇到的错误(d)。 As an example, a job I am using is in the us-east-1, thus the following statement executes successfully.例如,我正在使用的作业在 us-east-1 中,因此以下语句成功执行。

    glue_client = boto3.client('glue', region_name='us-east-1')
    response = glue_client.start_job_run(
        JobName = glue_job_name)

However, the snippet below will produce the same error as you have但是,下面的代码段将产生与您相同的错误

    glue_client = boto3.client('glue', region_name='us-west-1')
    response = glue_client.start_job_run(
        JobName = glue_job_name)

botocore.errorfactory.EntityNotFoundException: An error occurred (EntityNotFoundException) when calling the StartJobRun operation: Failed to start job run due to missing metadata botocore.errorfactory.EntityNotFoundException:调用 StartJobRun 操作时发生错误 (EntityNotFoundException):由于缺少元数据,无法启动作业运行

In the case above, it's relatively easy to check, by specifying running cli with --region parameter在上面的情况下,通过使用 --region 参数指定运行 cli 比较容易检查

It would be something like: aws glue start-job-run --job-name march15_9 --region ap-south-1它会是这样的:aws paste start-job-run --job-name March15_9 --region ap-south-1

If this runs successfully(thus the region is indeed ap-south-1), I'd explicitly set parameters in the code to remove unknown factors, and instead of passing them through environment variables you can temporary put string values in the code.如果这运行成功(因此该区域确实是 ap-south-1),我会在代码中明确设置参数以删除未知因素,而不是通过环境变量传递它们,您可以临时将字符串值放入代码中。

Once the code works with hardcoded values you may remove them one by one, thus finding one (or a few) that need to passed correctly.一旦代码处理了硬编码值,您就可以将它们一一删除,从而找到一个(或几个)需要正确传递的值。

All the best祝一切顺利

PS Indeed, the documentation is correct, only JobName needs to be set as a parameter, I have code that works this way PS确实,文档是正确的,只需要将JobName设置为参数,我有这样工作的代码

What glue error log indicating?什么胶水错误日志指示?

You may be using some parameters in glue job which you are not passing while calling job您可能在粘合作业中使用了一些参数,而这些参数在调用作业时并未传递

I too faced the same error, the problem is passing ARN of glue job as JobName.我也遇到了同样的错误,问题是将胶水作业的 ARN 作为 JobName 传递。 Resolved by passing only Name of the glue job.通过仅传递粘合作业的名称来解决。

response = client.start_job_run(
    JobName='Glue Job Name not ARN'
)

Check if the name of your glue job is correctly written.检查胶水作业的名称是否正确写入。 I had a similar case and I fixed it that way.我有一个类似的案例,我就是这样解决的。 (For example: Job_ 01 instead of Job_01) (例如:Job_01 而不是 Job_01)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM