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.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/jb/flow/tasks.py b/jb/flow/tasks.py
index 77825d3..c555021 100644
--- a/jb/flow/tasks.py
+++ b/jb/flow/tasks.py
@@ -1,18 +1,13 @@
-import logging
import time
from typing import TypedDict, cast
-from generalresearchutils.config import is_debug
+from generalresearch.config import is_debug
-from jb.decorators import AMTM, HTM, HM, HQM, 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 write_hit_gauge, emit_hit_event
+from jb.flow.monitoring import emit_hit_event, write_hit_gauge
from jb.models.definitions import HitStatus
-from jb.models.hit import HitType, HitQuestion, Hit
-
-logging.basicConfig()
-logger = logging.getLogger()
-logger.setLevel(logging.INFO)
+from jb.models.hit import Hit, HitQuestion, HitType
class HitRow(TypedDict):
@@ -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)