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

2024-10-04 09:28:52 发布

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

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

脚本:

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
)

Tags: name脚本类型responsetype作业etlshell
2条回答

要创建Spark作业,必须将命令的名称命名为“glueetl”,如下所述,如果没有运行pythonshell作业,则不需要在命令参数中指定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
)

参见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']获得

相关问题 更多 >