コード例 #1
0
def expire_and_dispose_hits(client: MTurkClient,
                            hits: List[Dict[str, Any]],
                            quiet: bool = False) -> List[Dict[str, Any]]:
    """
    Loops over attempting to expire and dispose any hits in the hits list that can be disposed
    Returns any HITs that could not be disposed of
    """
    non_disposed_hits = []
    for h in tqdm(hits, disable=quiet):
        try:
            client.delete_hit(HITId=h["HITId"])
        except Exception as e:
            client.update_expiration_for_hit(HITId=h["HITId"],
                                             ExpireAt=datetime(2015, 1, 1))
            h["dispose_exception"] = e
            non_disposed_hits.append(h)
    return non_disposed_hits
コード例 #2
0
ファイル: mturk_utils.py プロジェクト: wade3han/Mephisto
def expire_and_dispose_hits(
        client: MTurkClient, hits: List[Dict[str,
                                             Any]]) -> List[Dict[str, Any]]:
    """
    Loops over attempting to expire and dispose any hits in the hits list that can be disposed

    Returns any HITs that could not be disposed of
    """
    non_disposed_hits = []
    for h in hits:
        try:
            client.delete_hit(HITId=h["HITId"])
        except:
            client.update_expiration_for_hit(HITId=h["HITId"],
                                             ExpireAt=datetime(2015, 1, 1))
            non_disposed_hits.append(h)
    return non_disposed_hits
コード例 #3
0
def expire_hit(client: MTurkClient, hit_id: str):
    # Update expiration to a time in the past, the HIT expires instantly
    past_time = datetime(2015, 1, 1)
    client.update_expiration_for_hit(HITId=hit_id, ExpireAt=past_time)