python-3.x - 列出所有地面标记作业 Boto3-Python
问题描述
我正在尝试使用boto3
and sagemaker
with ' list_labeling_jobs
' 功能获得所有真实标签工作。但是,即使我有一个' NextToken
',每次运行它时我都会得到不同的结果。我不确定是什么导致了这种行为。(注意-我尝试了节流错误的异常)
这是我的代码,
sg_mkr_client = boto3.client('sagemaker')
sample = []
tries = 0
nextToken = None
try:
while True:
print("Token value", nextToken)
# Pagintae labeling jobs, so we can access all labeling jobs
paginator = sg_mkr_client.get_paginator('list_labeling_jobs')
one_submitted_jobs = paginator.paginate(
CreationTimeAfter=datetime.datetime(2020, 2, 10),
CreationTimeBefore=datetime.datetime(2020, 8, 24),
LastModifiedTimeAfter=datetime.datetime(2020, 2, 10),
LastModifiedTimeBefore=datetime.datetime(2020, 8, 24),
SortBy='CreationTime',
SortOrder='Descending',
StatusEquals='Completed',
PaginationConfig={
# 'MaxItems': 200,
# 'PageSize': 100,
'NextToken': nextToken
}
)
for m in one_submitted_jobs:
for index, i in enumerate(m['LabelingJobSummaryList']):
# print(index)
sample.append([i['LabelingJobName'], i['LabelingJobArn'], i['CreationTime'], i['LastModifiedTime']])
nextToken = m['NextToken']
print('getting next token')
except ClientError as exception_obj:
if exception_obj.response['Error']['Code'] == 'ThrottlingException':
print("Throttling Exception Occured.")
print("Retrying.....")
print("Attempt No.: " + str(tries))
time.sleep(3)
tries +=1
else:
raise
任何通过 truncate 和 nexttoken 挑战的帮助都会很棒。
解决方案
推荐阅读
- android - Kotlin中字符串之间的异或操作
- java - 在 Solr childDocTransformer 中使用多个 childFilter
- laravel - 在 laravel 升级后搜索索引属性 mongodb 没有返回结果
- firebase - 使用哈希 (sha1) 作为 Firestore 文档的 id 是个好主意吗?
- java - 结果不一致
- java - 在 Gradle 中使用 SWT 无法解决所有依赖项
- c++ - 二叉搜索树,仅打印出用于递归插入的“重复”警报 - C++
- html - 在移动设备上悬停图像
- javascript - 如何在 React Native 中创建引导式用户输入?
- python - Python OOP:为什么对象在打印中没有正确显示?