Beispiel #1
0
 def test_load_job_constants__no_file(self):
     file_path = [
         "src",
         "biokbase",
         "narrative",
         "tests",
         "data",
         "job_constants",
         "does_not_exist.json",
     ]
     with self.assertRaises(FileNotFoundError):
         load_job_constants(file_path)
Beispiel #2
0
 def test_load_job_constants__missing_value(self):
     file_path = [
         "src",
         "biokbase",
         "narrative",
         "tests",
         "data",
         "job_constants",
         "job_config-missing-item.json",
     ]
     with self.assertRaisesRegex(
             ValueError,
             "job_config.json is missing the following values for params: BATCH_ID, JOB_ID",
     ):
         load_job_constants(file_path)
Beispiel #3
0
 def test_load_job_constants__missing_section(self):
     file_path = [
         "src",
         "biokbase",
         "narrative",
         "tests",
         "data",
         "job_constants",
         "job_config-missing-datatype.json",
     ]
     with self.assertRaisesRegex(
             ValueError,
             "job_config.json is missing the 'message_types' config section"
     ):
         load_job_constants(file_path)
Beispiel #4
0
 def test_load_job_constants__valid(self):
     # the live file!
     (params, message_types) = load_job_constants()
     for item in ["BATCH_ID", "JOB_ID"]:
         self.assertIn(item, params)
     for item in ["STATUS", "RETRY", "INFO", "ERROR"]:
         self.assertIn(item, message_types)
Beispiel #5
0
import copy
import threading
from typing import List, Union
from ipykernel.comm import Comm
from biokbase.narrative.jobs.util import load_job_constants
from biokbase.narrative.jobs.jobmanager import JobManager
from biokbase.narrative.exception_util import NarrativeException, JobRequestException
from biokbase.narrative.common import kblogging


(PARAM, MESSAGE_TYPE) = load_job_constants()

UNKNOWN_REASON = "Unknown reason"

JOB_NOT_PROVIDED_ERR = "job_id not provided"
JOBS_NOT_PROVIDED_ERR = "job_id_list not provided"
CELLS_NOT_PROVIDED_ERR = "cell_id_list not provided"
BATCH_NOT_PROVIDED_ERR = "batch_id not provided"
ONE_INPUT_TYPE_ONLY_ERR = "Please provide one of job_id, job_id_list, or batch_id"

INVALID_REQUEST_ERR = "Improperly formatted job channel message!"
MISSING_REQUEST_TYPE_ERR = "Missing request type in job channel message!"

LOOKUP_TIMER_INTERVAL = 5


class JobRequest(object):
    """
    A small wrapper for job comm channel request data.
    This generally comes in the form of a packet from the kernel Comm object.
    It's expected to be a dict of the format: