sbatch¶
Module containing classes representing a Slurm batch script and corresponding JSON encoder and decoder
-
class
pyssub.sbatch.
SBatchScript
(executable: str, arguments: str = '')¶ Slurm batch script
Represents a single-task Slurm batch script. Additionally, a simple file transfer mechanism between node and shared file systems is realized.
-
executable
¶ Path to executable
Type: str
-
arguments
¶ Arguments that will be passed to executable
Type: str
-
options
¶ Mapping of sbatch options to objects (string-) representing values
Type: dict(str, object)
-
transfer_executable
¶ Transfer executable to node.
Type: bool
-
transfer_input_files
¶ Sequence of input files that are copied to the node before executing executable
Type: list(str)
-
transfer_output_files
¶ Sequence of output files that are moved after executing executable
Type: list(str)
-
-
class
pyssub.sbatch.
SBatchScriptDecoder
¶ JSON decoder for Slurm batch script
This callable class can be used as an object_hook when loading a JSON object from disk. All objects that represent a Slurm batch script, with or without macros, are decoded into the corresponding Python type.
-
decode
(description: Dict[str, Any]) → pyssub.sbatch.SBatchScript¶ Decode Slurm batch script.
Parameters: description (dict(str, object)) – Script’s JSON-compatible representation Returns: Slurm batch script Return type: SBatchScript
-
decode_macro
(description: Dict[str, Any]) → pyssub.sbatch.SBatchScriptMacro¶ Decode Slurm batch script containing macros.
If
script
points to a string, it is interpreted as a path to a JSON-encoded Slurm batch script on disk that will be loaded and decoded.Parameters: description (dict(str, object)) – Script’s JSON-compatible representation Returns: Slurm batch script Return type: SBatchScriptMacro
-
-
class
pyssub.sbatch.
SBatchScriptEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶ JSON encoder for Slurm batch script
This class provides a JSON-compatible representation of a Slurm batch script; both SBatchScript and SBatchScriptMacro are supported.
-
default
(o: Any) → Dict[str, Any]¶ Try to encode the given object.
-
-
class
pyssub.sbatch.
SBatchScriptMacro
(script: pyssub.sbatch.SBatchScript, macros: Dict[str, Any])¶ Slurm batch script with macro support
The macro support allows to put variables (macros) into the script and to reuse it for different values. The macro support is based on Python’s format specification mini-language.
-
script
¶ Slurm batch script containing macros
Type: SBatchScript
-
macros
¶ Macro values that are inserted into the script when the script’s string representation is called
Type: dict(str, object)
Examples
Create a script with one macro.
>>> skeleton = SBatchScript("echo", "'{macros[mg]}'") >>> script = SBatchScriptMacro(skeleton, {"msg": "Hello World!"})
-