From 8c1940445503fd6678d0961600f2be81622793a2 Mon Sep 17 00:00:00 2001 From: Max Nanis Date: Tue, 24 Feb 2026 17:26:15 -0500 Subject: Extensive use of type checking. Movement of pytest conf towards handling managers (for db agnostic unittest). Starting to organize pytests. --- jb/flow/tasks.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'jb/flow/tasks.py') diff --git a/jb/flow/tasks.py b/jb/flow/tasks.py index e7c64b9..808c8f7 100644 --- a/jb/flow/tasks.py +++ b/jb/flow/tasks.py @@ -1,5 +1,6 @@ import logging import time +from typing import TypedDict, cast from generalresearchutils.config import is_debug @@ -15,6 +16,11 @@ logger = logging.getLogger() logger.setLevel(logging.INFO) +class HitRow(TypedDict): + amt_hit_id: str + amt_hit_type_id: str + + def check_stale_hits(): # Check live hits that haven't been modified in a long time. They may not # be expired yet, but maybe something is wrong? @@ -28,7 +34,7 @@ def check_stale_hits(): LIMIT 100;""", params={"status": HitStatus.Assignable.value}, ) - for hit in res: + for hit in cast(list[HitRow], res): logging.info(f"check_stale_hits: {hit["amt_hit_id"]}") check_hit_status( amt_hit_id=hit["amt_hit_id"], @@ -49,7 +55,7 @@ def check_expired_hits(): LIMIT 100;""", params={"status": HitStatus.Assignable.value}, ) - for hit in res: + for hit in cast(list[HitRow], res): logging.info(f"check_expired_hits: {hit["amt_hit_id"]}") check_hit_status( amt_hit_id=hit["amt_hit_id"], @@ -74,8 +80,12 @@ def create_hit_from_hittype(hit_type: HitType) -> Hit: def refill_hits() -> None: + for hit_type in HTM.filter_active(): - active_count = HM.get_active_count(hit_type.id) + assert hit_type.id + assert hit_type.amt_hit_type_id + + active_count = HM.get_active_count(hit_type_id=hit_type.id) logging.info( f"HitType: {hit_type.amt_hit_type_id}, {hit_type.min_active=}, active_count={active_count}" ) -- cgit v1.2.3