You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Batch Python SDK 偶发CreateTasksErrorException(InvalidPropertyValue)问题排查求助

Azure Batch Python SDK 偶发CreateTasksErrorException(InvalidPropertyValue)问题排查求助

我有一个Python服务,会根据用户请求启动Azure Batch池,然后添加单个作业和任务。大部分时候(大概90%的情况)都能正常运行,但偶尔会遇到下面的错误:

Traceback (most recent call last):
  [...]
azure.batch.custom.custom_errors.CreateTasksErrorException: Task with id `sim_07936` failed due to client error - InvalidPropertyValue::{'additional_properties': {}, 'lang': 'en-US', 'value': 'The value provided for one of the properties in the request body is invalid.\nRequestId:5a36d9fd-f230-46ba-ac7d-961d3572521f\nTime:2025-03-19T10:10:10.9862777Z'}

我觉得问题核心应该是这段错误信息:

InvalidPropertyValue::{'additional_properties': {}, 'lang': 'en-US', 'value': 'The value provided for one of the properties in the request body is invalid.

但奇怪的是,我在创建任务的代码里根本没用到additional_properties,而且不同用户请求生成的任务逻辑都是一样的。下面是add_simulation_task函数里的相关代码:

job_id = str("some_uuid4")
    number_cpus = 100
    tasks = []
    resource_files = [
        batchmodels.ResourceFile(somefile1),
        batchmodels.ResourceFile(somefile2)
    ]

    display_name = "some_name"

    random_tag = random.randrange(0, 10000)
    sim_id = f"sim_{random_tag:05d}"
    parameters = "something"

    command_string = (
        f"some_f_string_with_a_few_{parameters}"
    )

    command = (
        f"/bin/bash -c '{command_string}'"
    )
    tasks.append(batchmodels.TaskAddParameter(
        id=sim_id,
        display_name=display_name,
        command_line=command,
        resource_files=resource_files,
        environment_settings=[
            batchmodels.EnvironmentSetting(
                name="NODES",
                value="1"
            ),
            batchmodels.EnvironmentSetting(
                name="PPN",
                value=str(number_cpus)
            )
        ],
        multi_instance_settings=batchmodels.MultiInstanceSettings(
            coordination_command_line="/bin/bash -c env",
            number_of_instances=1,
            common_resource_files=[]
        ),
        user_identity=batchmodels.UserIdentity(
            auto_user=batchmodels.AutoUserSpecification(
                scope="pool",
                elevation_level="nonadmin"
            )
        )
    ))
    batch_service_client.task.add_collection(job_id, tasks)

我遇到过同一天里连续2-3次启动完全相同的任务都失败,但第二天再试又毫无问题的情况。

有没有大佬能帮忙分析下,为什么这个接口不能100%正常工作?

备注:内容来源于stack exchange,提问作者SebSta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 19:29:35