aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-21 12:59:22 -0500
committerFrederick Muriuki Muriithi2025-04-21 12:59:22 -0500
commite51afd42981431977ce00b823cee24d710d4f83a (patch)
tree7b6c8c20825fc77b387c350b94b722ea4a94b52e
parent27425e6d57634106d2991ad17414d45c490c931c (diff)
downloadgn-libs-e51afd42981431977ce00b823cee24d710d4f83a.tar.gz
Add function to load standard stream outputs.
-rw-r--r--gn_libs/jobs/jobs.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/gn_libs/jobs/jobs.py b/gn_libs/jobs/jobs.py
index 38cd9c0..cf44bd0 100644
--- a/gn_libs/jobs/jobs.py
+++ b/gn_libs/jobs/jobs.py
@@ -7,6 +7,7 @@ import logging
import subprocess
from pathlib import Path
from functools import reduce
+from functools import partial
from typing import Union, Optional
from datetime import datetime, timezone, timedelta
@@ -29,6 +30,20 @@ def __job_metadata__(cursor: DbCursor, job_id: Union[str, uuid.UUID]) -> dict:
}
+def job_stdstream_outputs(conn, job_id, streamname: str):
+ """Fetch the standard-error output for the job."""
+ with _cursor(conn) as cursor:
+ cursor.execute(
+ "SELECT * FROM jobs_standard_outputs "
+ "WHERE job_id=? AND output_stream=?",
+ (str(job_id), streamname))
+ return dict(cursor.fetchone() or {}).get("value")
+
+
+job_stderr = partial(job_stdstream_outputs, streamname="stderr")
+job_stdout = partial(job_stdstream_outputs, streamname="stderr")
+
+
def job(conn: DbConnection, job_id: Union[str, uuid.UUID], fulldetails: bool = False) -> dict:
"""Fetch the job details for a job with a particular ID"""
with _cursor(conn) as cursor: