aboutsummaryrefslogtreecommitdiff
path: root/gn_libs/scripts/worker.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-03-25 12:52:48 -0500
committerFrederick Muriuki Muriithi2025-03-25 12:56:05 -0500
commit7a7e6a6a52517b035152093429c9c551844e563d (patch)
treec1c5a9f1050030e72e8ed5b7656e18afa2014b11 /gn_libs/scripts/worker.py
parentd4b7312423d5aef91b264bb21429e79ec65cec7c (diff)
downloadgn-libs-7a7e6a6a52517b035152093429c9c551844e563d.tar.gz
Rename manager/launcher script and implement the management logic.
Give the launcher a better name, and implement the logic to actually launch the job and do basic management of the process(es).
Diffstat (limited to 'gn_libs/scripts/worker.py')
-rw-r--r--gn_libs/scripts/worker.py49
1 files changed, 0 insertions, 49 deletions
diff --git a/gn_libs/scripts/worker.py b/gn_libs/scripts/worker.py
deleted file mode 100644
index 2479aef..0000000
--- a/gn_libs/scripts/worker.py
+++ /dev/null
@@ -1,49 +0,0 @@
-import sys
-import shlex
-import argparse
-import traceback
-
-from gn_libs import jobs, sqlite3
-
-
-def run_job(conn, job_id):
- """Run the job."""
- try:
- pass
- except:
- jobs.update_metadata(conn, args.job_id, "status", "error")
- jobs.push_to_stream(conn, args.job_id, "stderr", traceback.format_exc())
- return 4
-
-
-def parse_args():
- """Define and parse CLI args."""
- parser = argparse.ArgumentParser(
- prog="GN-Libs Worker",
- description = (
- "Generic worker to launch and manage jobs defined with gn-libs"))
- parser.add_argument(
- "jobs_db_uri",
- help="The URI to the SQLite3 database holding the jobs' details")
- parser.add_argument("job_id", help="The id of the job being processed")
- return parser.parse_args()
-
-def main():
- """Entry-point to this program."""
- args = parse_args()
- with (sqlite3.connection(args.jobs_db_uri) as conn,
- sqlite3.cursor(conn) as cursor):
- job = jobs.job(conn, args.job_id)
- if job:
- return run_job(conn, args.job_id)
-
- jobs.update_metadata(conn, args.job_id, "status", "error")
- jobs.push_to_stream(conn, args.job_id, "stderr", "Job not found!")
- return 2
-
- return 3
-
-
-
-if __name__ == "__main__":
- sys.exit(main())