romtools.hpc.components#
Focused helpers that the dispatchers compose.
- class romtools.hpc.components.BaseCaller(*, config=None, logger=None)[source]#
Bases:
Component,ABCExecutes a Python callable named by a “module:qualname” target string.
Arguments and return values may contain numpy arrays, tuples, lists, and dictionaries thereof.
- Parameters:
config (dict)
logger (Logger)
- class romtools.hpc.components.BaseFileManager(*, config=None, logger=None)[source]#
Bases:
Component,ABCReads and writes files on whichever machine a dispatcher runs work on.
- Parameters:
config (dict)
logger (Logger)
- class romtools.hpc.components.BaseTransferManager(*, files, config=None, logger=None, campaign_directory=None)[source]#
Bases:
CampaignComponentStages the files a campaign needs into its run directory, and brings its results back afterwards.
Nothing moves by default: a dispatcher whose work already runs against the files in place needs neither half. Subclasses override whichever half genuinely has work to do.
- Parameters:
files (BaseFileManager) – The file manager whose resolve_path decides what paths mean
campaign_directory (str) – The campaign directory results are gathered into
config (dict) – The dispatcher’s configuration dictionary
logger (Logger) – An instance of the Logger class for logging
- Raises:
ValueError – if the configured collect or upload patterns are invalid.
- class romtools.hpc.components.Component(*, config=None, logger=None)[source]#
Bases:
objectBase for the dispatcher’s helpers: each carries the dispatcher’s configuration and logger, and stands alone with defaults for both.
- Parameters:
config (dict) – The dispatcher’s configuration dictionary
logger (Logger) – An instance of the Logger class for logging
- class romtools.hpc.components.LocalCaller(*, files, config=None, logger=None)[source]#
Bases:
BaseCallerImports and runs the target in the current process.
A configured python_setup or python_command names an interpreter other than this one - a Python provided by a module, or a wrapper such as srun - so the call is staged out to a subprocess instead of imported here.
- Parameters:
files (LocalFileManager) – The local file manager used to stage inputs and read results back
config (dict)
logger (Logger)
- class romtools.hpc.components.LocalFileManager(*, config=None, logger=None)[source]#
Bases:
BaseFileManagerOperates directly on the local filesystem.
- Parameters:
config (dict)
logger (Logger)
- get(remote_path, local_path)[source]#
Local ‘get’ is just a copy from remote_path to local_path.
- Parameters:
remote_path (str)
local_path (str)
- Return type:
None
- np_savez(path, **arrays)[source]#
Write multiple arrays to a .npz file. The .npz file is written directly to the specified path.
- Parameters:
path (str)
- Return type:
None
- put(local_path, remote_path)[source]#
Local ‘put’ is just a copy from local_path to remote_path.
- Parameters:
local_path (str)
remote_path (str)
- Return type:
None
- read_text(path)[source]#
Return the contents of a text file.
- Parameters:
path (str)
- Return type:
str
- class romtools.hpc.components.LocalTransferManager(*, files, config=None, logger=None, campaign_directory=None)[source]#
Bases:
BaseTransferManagerCopies the configured upload patterns from the current directory into the run directory.
The work runs on this machine against these same files, so there is nothing to pack up and nothing to bring back: only upload does anything.
- Parameters:
files (BaseFileManager)
config (dict)
logger (Logger)
campaign_directory (str)
- class romtools.hpc.components.RemoteCaller(connection, *, files, config=None, logger=None)[source]#
Bases:
StagedCallerRuns the target on a remote host over an SSH connection.
- Parameters:
connection (Connection) – An established Connection to the remote host
files (RemoteFileManager) – The remote file manager used to stage inputs and read results back
config (dict)
logger (Logger)
- class romtools.hpc.components.RemoteFileManager(connection, *, config=None, logger=None)[source]#
Bases:
BaseFileManagerOperates on the remote filesystem over an SSH connection.
Relative paths are resolved against the configured remote root.
- Parameters:
connection (Connection) – An established Connection to the remote host
config (dict) – The dispatcher’s configuration dictionary
logger (Logger) – An instance of the Logger class for logging
- np_savez(path, **arrays)[source]#
Write multiple arrays to a .npz file, staged locally then uploaded.
- Parameters:
path (str)
- Return type:
None
- read_text(path)[source]#
Return the contents of a remote text file.
- Parameters:
path (str)
- Return type:
str
- class romtools.hpc.components.RemoteTransferManager(connection, *, files, config=None, logger=None, campaign_directory=None)[source]#
Bases:
BaseTransferManagerMoves the files a campaign needs onto the remote host, and its results back, in both directions through a single tar.gz archive.
- Parameters:
connection (Connection) – An established Connection to the remote host
campaign_directory (str) – The campaign directory, mirrored locally and remotely
files (RemoteFileManager) – The remote file manager, whose resolve_path decides what paths mean
config (dict)
logger (Logger)
- class romtools.hpc.components.SlurmJobManager(run_cmd, *, files, config=None, logger=None, campaign_directory=None)[source]#
Bases:
CampaignComponentGenerates and submits SLURM scripts, then polls the job until it finishes.
Serves both dispatchers, since sbatch/squeue/sacct are the same wherever they are issued.
- Parameters:
run_cmd (Callable[[str], Result]) – Runs a shell command where the scheduler lives and returns a Result. Connection.run for a remote host, run_local_bash for this one.
campaign_directory (str) – The directory jobs run in when no run_directory is given
files (BaseFileManager) – The file manager for the machine the job runs on
config (dict)
logger (Logger)
- class romtools.hpc.components.StagedCaller(run_cmd, *, files, config=None, logger=None)[source]#
Bases:
BaseCallerRuns the target under a separate interpreter, through a runner script staged in a scratch directory beside the run directory.
Arguments and results travel as a JSON + .npz pair, so that interpreter needs no access to romtools; run_cmd and files decide which machine it lives on.
- Parameters:
run_cmd – Callable that issues a shell command on the execution host
files (BaseFileManager) – The file manager used to stage inputs and read results back
config (dict)
logger (Logger)
Modules
The wire contract behind dispatcher.call(): resolving a "module:qualname" target, packing arguments and results into a JSON + .npz pair, and building the standalone runner script that executes the target under a remote interpreter. |
|
Shared construction for the helpers that the dispatchers compose. |
|
File operations for the dispatchers, in local and remote flavors. |
|
SLURM job submission and monitoring for the dispatchers. |
|
Moving a campaign's input files to where it runs, and its results back. |