Python 如何使用boto3客户端删除仍然可用的点击
我有一些已发表的作品可供工人使用。现在我想删除他们,虽然他们还没有完成的工人。根据本文件,不可能: 只能删除处于可查看状态的点击 但使用命令行界面似乎是可行的:Python 如何使用boto3客户端删除仍然可用的点击,python,boto3,mechanicalturk,Python,Boto3,Mechanicalturk,我有一些已发表的作品可供工人使用。现在我想删除他们,虽然他们还没有完成的工人。根据本文件,不可能: 只能删除处于可查看状态的点击 但使用命令行界面似乎是可行的: 我的问题是,我是否可以使用boto3客户端以某种方式完成删除不可查看点击的命令行行为?部分解决方案是将“可分配”点击设置为立即过期。我使用此脚本清理Mechanical Turk沙箱: import boto3 from datetime import datetime # Get the MTurk client mturk=bot
我的问题是,我是否可以使用boto3客户端以某种方式完成删除不可查看点击的命令行行为?部分解决方案是将“可分配”点击设置为立即过期。我使用此脚本清理Mechanical Turk沙箱:
import boto3
from datetime import datetime
# Get the MTurk client
mturk=boto3.client('mturk',
aws_access_key_id="aws_access_key_id",
aws_secret_access_key="aws_secret_access_key",
region_name='us-east-1',
endpoint_url="https://mturk-requester-sandbox.us-east-1.amazonaws.com",
)
# Delete HITs
for item in mturk.list_hits()['HITs']:
hit_id=item['HITId']
print('HITId:', hit_id)
# Get HIT status
status=mturk.get_hit(HITId=hit_id)['HIT']['HITStatus']
print('HITStatus:', status)
# If HIT is active then set it to expire immediately
if status=='Assignable':
response = mturk.update_expiration_for_hit(
HITId=hit_id,
ExpireAt=datetime(2015, 1, 1)
)
# Delete the HIT
try:
mturk.delete_hit(HITId=hit_id)
except:
print('Not deleted')
else:
print('Deleted')
部分解决方案是将“可分配”命中设置为立即过期。我使用此脚本清理Mechanical Turk沙箱:
import boto3
from datetime import datetime
# Get the MTurk client
mturk=boto3.client('mturk',
aws_access_key_id="aws_access_key_id",
aws_secret_access_key="aws_secret_access_key",
region_name='us-east-1',
endpoint_url="https://mturk-requester-sandbox.us-east-1.amazonaws.com",
)
# Delete HITs
for item in mturk.list_hits()['HITs']:
hit_id=item['HITId']
print('HITId:', hit_id)
# Get HIT status
status=mturk.get_hit(HITId=hit_id)['HIT']['HITStatus']
print('HITStatus:', status)
# If HIT is active then set it to expire immediately
if status=='Assignable':
response = mturk.update_expiration_for_hit(
HITId=hit_id,
ExpireAt=datetime(2015, 1, 1)
)
# Delete the HIT
try:
mturk.delete_hit(HITId=hit_id)
except:
print('Not deleted')
else:
print('Deleted')
啊,所以你需要更新过期时间并删除它。这就是我遗漏的一点。谢谢。啊,所以你需要更新过期时间并将其删除。这就是我遗漏的一点。谢谢