diff options
| author | stuppie | 2026-11-04 12:11:03 -0600 |
|---|---|---|
| committer | stuppie | 2026-11-04 12:11:03 -0600 |
| commit | 671a7b1b02503cfa5c9aecd40c27a0c2729a285b (patch) | |
| tree | 6cb1bd7c33e3e1d243ee5ae74decc57faaa5742d /jb/models/event.py | |
| parent | e99ec6b7e38113a2237dc1ff402d8f4337c651d5 (diff) | |
| download | amt-jb-671a7b1b02503cfa5c9aecd40c27a0c2729a285b.tar.gz amt-jb-671a7b1b02503cfa5c9aecd40c27a0c2729a285b.zip | |
strip out AMT
Diffstat (limited to 'jb/models/event.py')
| -rw-r--r-- | jb/models/event.py | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/jb/models/event.py b/jb/models/event.py deleted file mode 100644 index fb5735b..0000000 --- a/jb/models/event.py +++ /dev/null @@ -1,48 +0,0 @@ -from typing import Any - -from generalresearch.models.custom_types import AwareDatetimeISO -from mypy_boto3_mturk.literals import EventTypeType -from pydantic import BaseModel, Field - -from jb.models.custom_types import AMTBoto3ID - - -class MTurkEvent(BaseModel): - """ - What AWS SNS will POST to our mturk_notifications endpoint (inside the request body) - """ - - event_type: EventTypeType = Field( - json_schema_extra={"example": "AssignmentSubmitted"} - ) - event_timestamp: AwareDatetimeISO = Field( - json_schema_extra={"example": "2025-10-16T18:45:51Z"} - ) - amt_hit_id: AMTBoto3ID = Field( - json_schema_extra={"example": "12345678901234567890"} - ) - amt_assignment_id: str = Field( - max_length=64, - json_schema_extra={"example": "1234567890123456789012345678901234567890"}, - ) - amt_hit_type_id: AMTBoto3ID = Field( - json_schema_extra={"example": "09876543210987654321"} - ) - - @classmethod - def from_sns(cls, data: dict[str, Any]): - return cls.model_validate( - { - "event_type": data["EventType"], - "event_timestamp": cls.fix_mturk_timestamp(data["EventTimestamp"]), - "amt_hit_id": data["HITId"], - "amt_assignment_id": data["AssignmentId"], - "amt_hit_type_id": data["HITTypeId"], - } - ) - - @staticmethod - def fix_mturk_timestamp(ts: str) -> str: - if ts.endswith("Z") and "." not in ts: - ts = ts[:-1] + ".000Z" - return ts |
