aboutsummaryrefslogtreecommitdiff
path: root/jb/flow/tasks.py
diff options
context:
space:
mode:
Diffstat (limited to 'jb/flow/tasks.py')
-rw-r--r--jb/flow/tasks.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/jb/flow/tasks.py b/jb/flow/tasks.py
index 24e96d4..c555021 100644
--- a/jb/flow/tasks.py
+++ b/jb/flow/tasks.py
@@ -1,19 +1,14 @@
-import logging
import time
from typing import TypedDict, cast
from generalresearch.config import is_debug
-from jb.decorators import AMTM, HM, HQM, HTM, pg_config
+from jb.decorators import AMTM, HM, HQM, HTM, LOG, pg_config
from jb.flow.maintenance import check_hit_status
from jb.flow.monitoring import emit_hit_event, write_hit_gauge
from jb.models.definitions import HitStatus
from jb.models.hit import Hit, HitQuestion, HitType
-logging.basicConfig()
-logger = logging.getLogger()
-logger.setLevel(logging.INFO)
-
class HitRow(TypedDict):
amt_hit_id: str
@@ -34,7 +29,7 @@ def check_stale_hits():
params={"status": HitStatus.Assignable.value},
)
for hit in cast(list[HitRow], res):
- logging.info(f"check_stale_hits: {hit["amt_hit_id"]}")
+ LOG.info(f"check_stale_hits: {hit["amt_hit_id"]}")
check_hit_status(
amtm=AMTM,
amt_hit_id=hit["amt_hit_id"],
@@ -56,7 +51,7 @@ def check_expired_hits():
params={"status": HitStatus.Assignable.value},
)
for hit in cast(list[HitRow], res):
- logging.info(f"check_expired_hits: {hit["amt_hit_id"]}")
+ LOG.info(f"check_expired_hits: {hit["amt_hit_id"]}")
check_hit_status(
amtm=AMTM,
amt_hit_id=hit["amt_hit_id"],
@@ -87,7 +82,7 @@ def refill_hits() -> None:
assert hit_type.amt_hit_type_id
active_count = HM.get_active_count(hit_type_id=hit_type.id)
- logging.info(
+ LOG.info(
f"HitType: {hit_type.amt_hit_type_id}, {hit_type.min_active=}, active_count={active_count}"
)
write_hit_gauge(
@@ -97,7 +92,7 @@ def refill_hits() -> None:
)
if active_count < hit_type.min_active:
cnt_todo = hit_type.min_active - active_count
- logging.info(f"Refilling {cnt_todo} hits")
+ LOG.info(f"Refilling {cnt_todo} hits")
for _ in range(cnt_todo):
create_hit_from_hittype(hit_type)
@@ -109,6 +104,6 @@ def refill_hits_task():
check_stale_hits()
refill_hits()
except Exception as e:
- logging.exception(e)
+ LOG.exception(e)
finally:
time.sleep(5 * 60)