setup for rework of monitor/handler/conductor interactions
This commit is contained in:
@ -8,7 +8,7 @@ Author(s): David Marchant
|
||||
|
||||
from typing import Any, Tuple, Dict
|
||||
|
||||
from meow_base.core.vars import VALID_CONDUCTOR_NAME_CHARS, \
|
||||
from meow_base.core.vars import VALID_CONDUCTOR_NAME_CHARS, VALID_CHANNELS, \
|
||||
get_drt_imp_msg
|
||||
from meow_base.functionality.validation import check_implementation, \
|
||||
valid_string
|
||||
@ -19,6 +19,10 @@ class BaseConductor:
|
||||
# An identifier for a conductor within the runner. Can be manually set in
|
||||
# the constructor, or autogenerated if no name provided.
|
||||
name:str
|
||||
# A channel for sending messages to the runner. Note that this will be
|
||||
# overridden by a MeowRunner, if a conductor instance is passed to it, and
|
||||
# so does not need to be initialised within the conductor itself.
|
||||
to_runner: VALID_CHANNELS
|
||||
# Directory where queued jobs are initially written to. Note that this
|
||||
# will be overridden by a MeowRunner, if a handler instance is passed to
|
||||
# it, and so does not need to be initialised within the handler itself.
|
||||
@ -32,6 +36,7 @@ class BaseConductor:
|
||||
from it implements its validation functions."""
|
||||
check_implementation(type(self).execute, BaseConductor)
|
||||
check_implementation(type(self).valid_execute_criteria, BaseConductor)
|
||||
check_implementation(type(self).prompt_runner_for_job, BaseConductor)
|
||||
if not name:
|
||||
name = generate_conductor_id()
|
||||
self._is_valid_name(name)
|
||||
@ -51,6 +56,21 @@ class BaseConductor:
|
||||
overridden by child classes."""
|
||||
valid_string(name, VALID_CONDUCTOR_NAME_CHARS)
|
||||
|
||||
def prompt_runner_for_job(self):
|
||||
pass
|
||||
|
||||
def start(self)->None:
|
||||
"""Function to start the conductor as an ongoing process/thread. May be
|
||||
overidden by any child process. Note that by default this will raise an
|
||||
execption that is automatically handled within a runner instance."""
|
||||
raise NotImplementedError
|
||||
|
||||
def stop(self)->None:
|
||||
"""Function to stop the conductor as an ongoing process/thread. May be
|
||||
overidden by any child process. Note that by default this will raise an
|
||||
execption that is automatically handled within a runner instance."""
|
||||
raise NotImplementedError
|
||||
|
||||
def valid_execute_criteria(self, job:Dict[str,Any])->Tuple[bool,str]:
|
||||
"""Function to determine given an job defintion, if this conductor can
|
||||
process it or not. Must be implemented by any child process."""
|
||||
|
Reference in New Issue
Block a user