使用 boto3 创建粘合作业时指定作业类型

Specify job type when creating glue job with boto3

我正在尝试创建 glue etl 作业。我正在使用 boto3。我正在使用下面的脚本。我想将其创建为 type=Spark,但下面的脚本创建了一个 type=Python Shell。它也不会禁用书签。有谁知道我需要添加什么才能使其成为 Spark 类型并禁用书签?

脚本:

response = glue_assumed_client.create_job(
    Name='mlxxxx',
    Role='Awsxxxx',
    Command={
        'Name': 'mlxxxx',
        'ScriptLocation': 's3://aws-glue-scripts-xxxxx-us-west-2/xxxx',
        'PythonVersion': '3'
    },

    Connections={
        'Connections': [
            'sxxxx',
'spxxxxxx',
        ]
    },

    Timeout=2880,
    MaxCapacity=10
)

参见documentation

Command (dict) -- [REQUIRED] The JobCommand that executes this job.

Name (string) -- The name of the job command. For an Apache Spark ETL job, this must be glueetl . For a Python shell job, it must be pythonshell .

您可以使用功能重置书签

client.reset_job_bookmark(
    JobName='string',
    RunId='string'
)

其中 JobName 是必需的。可以从命令create_job()

response['Name']中获取

要创建 Spark 作业,您必须将命令名称称为“glueetl”,如下所述,如果您不是 运行 python shell 作业,您不需要在命令参数

中指定python版本
response = client.create_job(
    Name='mlxxxyu',
    Role='Awsxxxx',
    Command={
        'Name': 'glueetl',     # <——   mention the name as glueetl to create spark job
        'ScriptLocation': 's3://aws-glue-scripts-xxxxx-us-west-2/xxxx'
    },
    Connections={
        'Connections': [
            'sxxxx',
'spxxxxxx',
        ]
    },

    Timeout=2880,
    MaxCapacity=10
)

关于职位书签,默认情况下职位书签是禁用的,因此如果您没有为职位书签指定参数,那么创建的职位将禁用书签。

如果您想明确禁用书签,那么您可以在默认参数[1]中指定相同的内容,如下所示。

response = client.create_job(
    Name='mlxxxyu',
    Role='Awsxxxx',
    Command={
        'Name': 'glueetl',
        'ScriptLocation': ‘s3://aws-glue-scripts-xxxxx-us-west-2/xxxx'
    },
    DefaultArguments={
        '--job-bookmark-option': 'job-bookmark-disable'
    },
    Timeout=2880,
    MaxCapacity=10
)