最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Azure Batch Python SDK - 5 - 10% Chance to encounter "CreateTasksErrorException" - Stack Overflow

programmeradmin1浏览0评论

I have a python service running that is starting azure batch pools and adds a single job + task on user requests. In ~90% of the time, everything works fine, but sometimes i get the following error message:

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'}

I assume the main culprit is this:

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

However, nowhere in the task creation do i use "additional_properties", nor do my tasks differ between different user calls. This is the relevant piece of code in the "add_simulation_task" function:

    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)

I have started the exact same task 2 or 3 times without success on the one day, with no issues on the second.

I would be happy for any idea why the interface is not working 100% of the time.

I have a python service running that is starting azure batch pools and adds a single job + task on user requests. In ~90% of the time, everything works fine, but sometimes i get the following error message:

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'}

I assume the main culprit is this:

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

However, nowhere in the task creation do i use "additional_properties", nor do my tasks differ between different user calls. This is the relevant piece of code in the "add_simulation_task" function:

    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)

I have started the exact same task 2 or 3 times without success on the one day, with no issues on the second.

I would be happy for any idea why the interface is not working 100% of the time.

Share Improve this question asked Mar 19 at 10:40 SebStaSebSta 4942 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You should inspect the BatchErrorDetail field to understand which property is invalid.

My guess is that you are exceeding the length/size limits of a property that is susceptible to such limits. Such properties include (but aren't limited to) ResourceFiles, CommandLine, or EnvironmentVariables.

发布评论

评论列表(0)

  1. 暂无评论