diff options
| author | Max Nanis | 2026-09-10 01:00:39 -0700 |
|---|---|---|
| committer | Max Nanis | 2026-09-10 01:00:39 -0700 |
| commit | 4dca7296742b607e74f16e2f6484c51163a41ace (patch) | |
| tree | 0839c16d0905deb587d3ee25ff93fd3ccf7eeeb6 /jb/managers/amt.py | |
| parent | 832aecaddce80e312095ecdb572d7756eb9df5e9 (diff) | |
| download | amt-jb-4dca7296742b607e74f16e2f6484c51163a41ace.tar.gz amt-jb-4dca7296742b607e74f16e2f6484c51163a41ace.zip | |
using model_validator on GRLSettings. Allows null default values, then to asser them on load. Required so pydantic_settings can be loaded in tests without params
Diffstat (limited to 'jb/managers/amt.py')
| -rw-r--r-- | jb/managers/amt.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/jb/managers/amt.py b/jb/managers/amt.py index e2c7e90..2411080 100644 --- a/jb/managers/amt.py +++ b/jb/managers/amt.py @@ -1,4 +1,3 @@ -import logging from datetime import datetime, timezone from typing import Any @@ -15,6 +14,7 @@ from mypy_boto3_mturk.type_defs import ( from pydantic import ValidationError from jb.config import TOPIC_ARN +from jb.decorators import LOG from jb.models import AMTAccount from jb.models.assignment import Assignment from jb.models.bonus import Bonus @@ -78,7 +78,7 @@ class AMTManager: return HitStatus.Disposed else: - logging.warning(msg) + LOG.warning(msg) return HitStatus.Unassignable return res.status @@ -137,7 +137,7 @@ class AMTManager: # Baddies have been known to submit assignments with purposely # malformed "answer" (xml) section, which will raise # a pydantic validation error. Try to parse again with no Answer. - logging.exception(e) + LOG.exception(e) ass_res["Answer"] = None # If it wasn't the Answer that caused the ValidationError, it'll raise again assignment = Assignment.from_amt_get_assignment(ass_res) @@ -152,7 +152,7 @@ class AMTManager: try: return self.get_assignment(amt_assignment_id=amt_assignment_id) except botocore.exceptions.ClientError as e: - logging.warning(e) + LOG.warning(e) error_code = e.response["Error"]["Code"] error_msg = e.response["Error"]["Message"] if error_code == "RequestError" and expected_err_msg in error_msg: @@ -170,7 +170,7 @@ class AMTManager: ) except botocore.exceptions.ClientError as e: - logging.warning(e) + LOG.warning(e) return None def approve_assignment_if_possible( @@ -189,7 +189,7 @@ class AMTManager: ) except botocore.exceptions.ClientError as e: - logging.warning(e) + LOG.warning(e) return None def update_hit_review_status(self, amt_hit_id: str, revert: bool = False) -> None: @@ -198,7 +198,7 @@ class AMTManager: self.amt_client.update_hit_review_status(HITId=amt_hit_id, Revert=revert) except botocore.exceptions.ClientError as e: - logging.warning(f"{amt_hit_id=}, {e}") + LOG.warning(f"{amt_hit_id=}, {e}") error_msg = e.response["Error"]["Message"] if "does not exist" in error_msg: @@ -225,7 +225,7 @@ class AMTManager: ) except botocore.exceptions.ClientError as e: - logging.warning(f"{amt_worker_id=} {amt_assignment_id=}, {e}") + LOG.warning(f"{amt_worker_id=} {amt_assignment_id=}, {e}") return None def get_bonus(self, amt_assignment_id: str, payout_event_id: str) -> Bonus | None: |
