Skip to content

Commit 6f0949a

Browse files
authored
patch: adds host arg (#15)
1 parent 4be35c6 commit 6f0949a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/aind_airflow_jobs/alert_handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def send_log_message(
8282
job_info: Dict[str, Any],
8383
message: Optional[str] = None,
8484
log_level: str = "INFO",
85+
loki_host: Optional[str] = None,
8586
) -> None:
8687
"""
8788
Sends a log message given the job information.
@@ -90,6 +91,8 @@ def send_log_message(
9091
job_info : Dict[str, Any]
9192
message : str | None
9293
log_level : str
94+
loki_host : str | None
95+
Optional override of loki host
9396
9497
Returns
9598
-------
@@ -100,7 +103,7 @@ def send_log_message(
100103
job_name = job_info["job_name"]
101104
run_id = job_info["run_id"]
102105
task_id = job_info["task_id"]
103-
handler = LokiLoggerHook().get_conn()
106+
handler = LokiLoggerHook(host=loki_host).get_conn()
104107
logging_message = (
105108
f"{job_name} on {run_id} and {task_id}"
106109
if message is None

tests/test_alert_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def test_send_log_message(
8585
mock_logger.return_value.log = mock_log
8686
send_log_message(job_info=job_info, log_level="DEBUG", message="Hello")
8787

88-
mock_loki.assert_has_calls([call(), call().get_conn()])
88+
mock_loki.assert_has_calls([call(host=None), call().get_conn()])
8989
mock_logger.assert_has_calls([call("aind_airflow_jobs.alert_handler")])
9090
mock_log.assert_called_once_with(
9191
10,

0 commit comments

Comments
 (0)