dml_util.runners.base#

Runner base class for executing code in different environments.

This module defines the base RunnerBase class for executing code in different environments. Runners are used to execute tasks in various environments, such as local, container, or remote environments. They provide a consistent interface for task execution with state management and logging.

Classes

RunnerBase(config, input)

Base Runner class for executing code in different environments.

class dml_util.runners.base.RunnerBase(config, input)[source]#

Bases: object

Base Runner class for executing code in different environments.

This class provides a framework for running tasks with state management and logging. Subclasses must implement specific methods and adhere to the defined interface.

Notes

Subclasses must implement one or more of the following methods: - run: Executes the primary task logic (e.g., WrappedRunner, SshRunner). - update: Updates the state and handles task execution (e.g., ScriptRunner).

The difference being tha tthe run method will handle all of the locking and state management for you, so if you override it, you should not call self.put_state or self.state.get directly.

Examples

>>> class MyRunner(RunnerBase):
...
...     def run(self):
...         print("Running task:", self.task_name)
Parameters:
property clsname#
config: EnvConfig#
gc(state)[source]#

Clean up any resources.

input: InputConfig#
property prefix#
put_state(state)[source]#
run()[source]#

Run the task and return the result.

This method handles acquiring the job lock, updating the state, and returning the response and message. The main logic of the task is implemented in the update method, which must be defined by subclasses.

state: State#
state_class#

alias of LocalState

update(state)[source]#

Update the state and return the new state, message, and response.

The gc method is called if and only if the returned state is None.