spmi.core.manageables package

Contents

spmi.core.manageables package#

Subpackages#

Submodules#

spmi.core.manageables.task module#

Provides TaskManageable.

exception spmi.core.manageables.task.BackendException#

Bases: TaskManageableException

class spmi.core.manageables.task.TaskManageable(*args, data=None, meta=None, **kwargs)#

Bases: Manageable

Manageable which handles a single command.

Basic descriptor in TOML format:

[task]                  # type of manageable
id = "toml_task"        # ID of manageable

[task.backend]          # backend section
type = "screen"         # type of backend

[task.wrapper]          # wrapper section
type = "default"        # type of wrapper
command = "sleep 10"    # command to execute
class Backend#

Bases: object

Provides an interface to process manager.

Any realisation should be defined in spmi.core.manageables.task_.backends package in own file. Its name should be written in PascalCase and ended with “Backend”.

class MetaDataHelper(meta=None, data=None, metadata=None, mutable=True, copy=False)#

Bases: MetaDataNode

Provides access to data.

Parameters:
  • meta (Union[dict, None]) – Meta dictionary. Empty if None.

  • data (Union[dict, None]) – Data dictionary. Empty if None.

  • metadata (Union[dict, MetaDataNode]) – MetaDataNode object.

  • mutable (bool) – Mutable flag.

  • copy (bool) – Copy flag. If True, deepcopies meta, data and metadata.

Note

You can set meta and data or metadata flags at once

Raises:
property command#

Start command.

Raises:
Type:

str

property id#

ID of backend proces.

Raises:
Type:

str

property log_path#

Path to backend log file. None if there is no backend log file.

Raises:
Type:

Union[pathlib.Path, None]

reset()#
property type#

str. Backend type.

static get_backend_class(metadata)#

Returns wrapper class by metadata

abstract is_active(task_metadata)#

Returns True, if job is active.

Parameters:

task_metadata (TaskManageable.MetaDataHelper) – Metadata.

Returns:

bool.

Raises:
abstract kill(task_metadata)#

Kills wrapper process.

Parameters:

task_metadata (TaskManageable.MetaDataHelper) – Metadata.

Raises:
abstract submit(task_metadata)#

Submits command.

Parameters:

task_metadata (TaskManageable.MetaDataHelper) – Metadata.

Returns:

str. ID of submitted task.

Raises:
abstract term(task_metadata)#

Terminates wrapper process.

Parameters:

task_metadata (TaskManageable.MetaDataHelper) – Metadata.

Raises:
class Cli#

Bases: object

CLI for wrapper.

static command(task_metadata)#

Start command.

Parameters:

task_metadata (TaskManageable.MetaDataHelper) – Metadata.

Returns:

str.

Raises:
  • TypeError

  • ValueError

static from_args()#

Load metadata from start command.

class MetaDataHelper(data=None, meta=None, mutable=True, metadata=None, copy=True)#

Bases: MetaDataHelper

Parameters:
  • meta (Union[dict, pathlib.Path, None]) – Meta dictionary. Empty dict if None.

  • data (Union[dict, pathlib.Path, None]) – Data dictionary. Empty dict if None.

  • metadata (Union[dict, MetaData]) – MetaData object.

  • mutable (bool) – Mutable flag.

  • copy (bool) – Copy flag. If True, deepcopies meta, data and metadata.

Note

You can set meta and data or metadata flags at once

Raises:
property backend#

Backend data.

Raises:

ValueError

Type:

TaskManageable.Backend.MetaDataHelper

property common_backend#
property common_wrapper#
reset()#

Resets some values in case of restart.

Raises:

MetaDataError

property wrapper#

Wrapper data.

Raises:

ValueError

Type:

TaskManageable.Wrapper.MetaDataHelper

class Wrapper(metadata=None)#

Bases: object

Class which handles a command execution.

Any realisation should be defined in spmi.core.manageables.task_.wrappers package in own file. Its name should be written in PascalCase and ended with “Wrapper”.

class MetaDataHelper(meta=None, data=None, metadata=None, mutable=True, copy=False)#

Bases: MetaDataNode

Parameters:
  • meta (Union[dict, None]) – Meta dictionary. Empty if None.

  • data (Union[dict, None]) – Data dictionary. Empty if None.

  • metadata (Union[dict, MetaDataNode]) – MetaDataNode object.

  • mutable (bool) – Mutable flag.

  • copy (bool) – Copy flag. If True, deepcopies meta, data and metadata.

Note

You can set meta and data or metadata flags at once

Raises:
property command#

Wrapper type.

Type:

str

property exit_code#

Exit code of wrapped process. None if process hasn’t finished.

Raises:
Type:

Union[int, None]

property mixed_stdout#

True if stdout and stderr are one file.

Raises:
Type:

bool

property process_pid#

PID of wrapped process. None if process hasn’t started.

Raises:
Type:

Union[int, None]

reset()#
property stderr_path#

Path to wrapper stderr file. None if there is no wrapper stderr file.

Raises:
Type:

Union[pathlib.Path, None]

property stdin_path#

Path to wrapper stdin file. None if there is no wrapper stdin file.

Raises:
Type:

Union[pathlib.Path, None]

property stdout_path#

Path to backend stdout file. None if there is no backend stdout file.

Raises:
Type:

Union[pathlib.Path, None]

property type: str#

Wrapper type.

Type:

str

static get_wrapper_class(metadata)#

Returns wrapper class by metadata

abstract on_signal(signum, frame)#

Called on signal.

abstract start()#

Start wrapper.

destruct()#

Free all resources (filesystem too).

Raises:

ManageableException

kill()#

Kill this manageable.

Raises:

ManageableException

start()#

Starts this manageable.

Raises:

ManageableException

property status#

Status of manageable.

Type:

ManageableStatus

status_string(align=0)#

Returns status string of this manageable.

Parameters:

align (int) – Align.

term()#

Terminate this manageable.

Raises:

ManageableException

exception spmi.core.manageables.task.TaskManageableException#

Bases: ManageableException

exception spmi.core.manageables.task.WrapperException#

Bases: TaskManageableException

spmi.core.manageables.task.set_signal_handlers(wrapper)#

Sets signal handlers.

Module contents#