diff options
| author | Frederick Muriuki Muriithi | 2025-04-08 12:57:41 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2025-04-08 14:19:57 -0500 |
| commit | ada08644718e174aa05444db653dcd349118b08e (patch) | |
| tree | 448e11a7c93adf0129a0a56483e35ab209913920 | |
| parent | e0ee2ddf154bb21a487f92994e27d411a477d7e9 (diff) | |
| download | genenetwork3-ada08644718e174aa05444db653dcd349118b08e.tar.gz | |
Add a function to compute the job queue from the settings.
| -rw-r--r-- | gn3/commands.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gn3/commands.py b/gn3/commands.py index eba01b1..b4db447 100644 --- a/gn3/commands.py +++ b/gn3/commands.py @@ -18,7 +18,7 @@ from typing import Union from typing import Sequence from uuid import uuid4 -from flask import current_app +from flask import Flask, current_app from redis.client import Redis # Used only in type hinting from pymonad.either import Either, Left, Right @@ -174,6 +174,16 @@ def run_cmd(cmd: str, success_codes: Tuple = (0,), env: Optional[str] = None) -> current_app.logger.debug if current_app else logging.debug)(out) return {"code": results.returncode, "output": out} + +def compute_job_queue(app: Flask) -> str: + """Use the app configurations to compute the job queue""" + app_env = app.config["APPLICATION_ENVIRONMENT"] + job_queue = app.config["REDIS_JOB_QUEUE"] + if bool(app_env): + return f"{app_env}::{job_queue}" + return job_queue + + def run_async_cmd( conn: Redis, job_queue: str, cmd: Union[str, Sequence[str]], email: Optional[str] = None, log_level: str = "info", |
