gpt4 book ai didi

azure - 批处理错误异常 : The specified operation is not valid for the current state of the resource

转载 作者:行者123 更新时间:2023-12-03 03:56:57 25 4
gpt4 key购买 nike

场景:我有一个针对池的 azure 批处理创建的作业。现在,我创建了另一个池,并希望将我的工作指向新创建的池。我使用azure-batch SDK编写了以下代码

import azure.batch.batch_service_client as batch
batch_service_client = batch.BatchServiceClient(credentials, batch_url = account_url)

job_id="LinuxTrainingJob"
pool_id="linux-e6a63ad4-9e52-4b9a-8b09-2a0249802981"

pool_info = batch.models.PoolInformation(pool_id=pool_id)
job_patch_param = batch.models.JobPatchParameter(pool_info=pool_info)
batch_service_client.job.patch(job_id, job_patch_param)

这给了我以下错误

BatchErrorException                       Traceback (most recent call last)
<ipython-input-104-ada32b24d6a0> in <module>
2 pool_info = batch.models.PoolInformation(pool_id=pool_id)
3 job_patch_param = batch.models.JobPatchParameter(pool_info=pool_info)
----> 4 batch_service_client.job.patch(job_id, job_patch_param)

~/anaconda3/lib/python3.8/site-packages/azure/batch/operations/job_operations.py in patch(self, job_id, job_patch_parameter, job_patch_options, custom_headers, raw, **operation_config)
452
453 if response.status_code not in [200]:
--> 454 raise models.BatchErrorException(self._deserialize, response)
455
456 if raw:

BatchErrorException: {'additional_properties': {}, 'lang': 'en-US', 'value': 'The specified operation is not valid for the current state of the resource.\nRequestId:46074112-9a99-4569-a078-30a7f4ad2b91\nTime:2020-10-06T17:52:43.6924378Z'}

凭据在上面设置,并且工作正常,因为我能够使用同一客户端创建池和作业。

环境详情

azure-batch==9.0.0
python 3.8.3
Ubuntu 18.04

最佳答案

要将作业分配给另一个池,您必须调用 disableJob用于从池中耗尽当前正在运行的任务的 API。那么您可以调用updateJob分配一个新的 poolId 来运行。更新后您可以调用enableJob继续执行作业。

关于azure - 批处理错误异常 : The specified operation is not valid for the current state of the resource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64231408/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com