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 ifNone
.data (
Union[dict, None]
) – Data dictionary. Empty ifNone
.metadata (
Union[dict, MetaDataNode]
) –MetaDataNode
object.mutable (
bool
) – Mutable flag.copy (
bool
) – Copy flag. IfTrue
, deepcopiesmeta
,data
andmetadata
.
Note
You can set meta and data or metadata flags at once
- Raises:
TypeError –
ValueError –
- property command#
Start command.
- Raises:
TypeError –
- Type:
str
- property id#
ID of backend proces.
- Raises:
TypeError –
- Type:
str
- property log_path#
Path to backend log file.
None
if there is no backend log file.- Raises:
TypeError –
- 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:
TypeError –
- abstract kill(task_metadata)#
Kills wrapper process.
- Parameters:
task_metadata (
TaskManageable.MetaDataHelper
) – Metadata.- Raises:
TypeError –
- abstract submit(task_metadata)#
Submits command.
- Parameters:
task_metadata (
TaskManageable.MetaDataHelper
) – Metadata.- Returns:
str
. ID of submitted task.- Raises:
TypeError –
- abstract term(task_metadata)#
Terminates wrapper process.
- Parameters:
task_metadata (
TaskManageable.MetaDataHelper
) – Metadata.- Raises:
TypeError –
- 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. Emptydict
ifNone
.data (
Union[dict, pathlib.Path, None]
) – Data dictionary. Emptydict
ifNone
.metadata (
Union[dict, MetaData]
) –MetaData
object.mutable (
bool
) – Mutable flag.copy (
bool
) – Copy flag. IfTrue
, deepcopiesmeta
,data
andmetadata
.
Note
You can set meta and data or metadata flags at once
- Raises:
TypeError –
ValueError –
- property backend#
Backend data.
- Raises:
ValueError –
- Type:
- property common_backend#
- property common_wrapper#
- reset()#
Resets some values in case of restart.
- Raises:
- property wrapper#
Wrapper data.
- Raises:
ValueError –
- Type:
- 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 ifNone
.data (
Union[dict, None]
) – Data dictionary. Empty ifNone
.metadata (
Union[dict, MetaDataNode]
) –MetaDataNode
object.mutable (
bool
) – Mutable flag.copy (
bool
) – Copy flag. IfTrue
, deepcopiesmeta
,data
andmetadata
.
Note
You can set meta and data or metadata flags at once
- Raises:
TypeError –
ValueError –
- property command#
Wrapper type.
- Type:
str
- property exit_code#
Exit code of wrapped process.
None
if process hasn’t finished.- Raises:
TypeError –
- Type:
Union[int, None]
- property mixed_stdout#
True
if stdout and stderr are one file.- Raises:
TypeError –
- Type:
bool
- property process_pid#
PID of wrapped process.
None
if process hasn’t started.- Raises:
TypeError –
- Type:
Union[int, None]
- reset()#
- property stderr_path#
Path to wrapper stderr file.
None
if there is no wrapper stderr file.- Raises:
TypeError –
- Type:
Union[pathlib.Path, None]
- property stdin_path#
Path to wrapper stdin file.
None
if there is no wrapper stdin file.- Raises:
TypeError –
- Type:
Union[pathlib.Path, None]
- property stdout_path#
Path to backend stdout file.
None
if there is no backend stdout file.- Raises:
TypeError –
- 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:
- kill()#
Kill this manageable.
- Raises:
- start()#
Starts this manageable.
- Raises:
- 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:
- 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.