bout_runners.submitter.local_submitter¶
Contains the local submitter class.
Classes
|
Submits a command. |
-
class
bout_runners.submitter.local_submitter.
LocalSubmitter
(run_path: Optional[pathlib.Path] = None, processor_split: Optional[bout_runners.submitter.processor_split.ProcessorSplit] = None)[source]¶ Submits a command.
Examples
>>> submitter = LocalSubmitter() >>> submitter.submit_command('ls') >>> submitter.wait_until_completed() >>> print(submitter.std_out) __init__.py test_local_submitter.py test_processor_split.py test_submitter_factory.py
- Attributes
- __processNone or Popen
The Popen process if it has been created
- run_pathPath or str
Directory to run the command from
Methods
_wait_for_std_out_and_std_err()
Wait until the process completes, populate return_code, std_out and std_err
submit_command(command)
Submit a subprocess
completed()
Return the completed status
raise_error(self)
Raise and error from the subprocess in a clean way
Set the path from where the calls are made from.
- Parameters
- run_pathPath or str or None
Directory to run the command from If None, the calling directory will be used
- processor_splitProcessorSplit or None
Object containing the processor split If None, default values will be used
- Attributes
job_id
Return the process id.
return_code
Return the return code.
std_err
Return the standard error.
std_out
Return the standard output.
Methods
Return the completed status.
errored
([raise_error])Return True if the process errored.
Raise and error from the subprocess in a clean way.
reset
()Reset the submitter.
submit_command
(command)Submit a subprocess.
wait_until_completed
([raise_error])Wait until the process has completed.
write_python_script
(path, function[, args, …])Write python function to file.
-
completed
() → bool[source]¶ Return the completed status.
Communicate the process has completed.
- Returns
- bool
True if the process has completed
-
errored
(raise_error: bool = False) → bool¶ Return True if the process errored.
- Parameters
- raise_errorbool
Whether or not to raise errors
- Returns
- bool
True if the process returned a non-zero code
-
property
job_id
¶ Return the process id.
- Returns
- self._status[“job_id”]int or None
The process id if a process has been called, else None
-
reset
() → None¶ Reset the submitter.
-
property
return_code
¶ Return the return code.
-
property
std_err
¶ Return the standard error.
- Returns
- self._status[“std_err”]str or None
The standard error None if the process has not completed
-
property
std_out
¶ Return the standard output.
- Returns
- self._status[“std_out”]str or None
The standard output None if the process has not completed
-
submit_command
(command: str) → None[source]¶ Submit a subprocess.
- Parameters
- commandstr
The command to run
-
wait_until_completed
(raise_error: bool = True) → None¶ Wait until the process has completed.
- Parameters
- raise_errorbool
Whether or not to raise errors
-
static
write_python_script
(path: pathlib.Path, function: Callable, args: Optional[Tuple[Any, …]] = None, kwargs: Optional[Dict[str, Any]] = None) → None¶ Write python function to file.
- Parameters
- pathPath
Absolute path to store the python file which holds the function and its arguments
- functionfunction
The function to call
- argstuple
The positional arguments
- kwargsdict
The keyword arguments