romtools.hpc.dispatchers.base_dispatcher#
Classes
|
Shared configuration, logging, and public API for the dispatchers. |
- class romtools.hpc.dispatchers.base_dispatcher.BaseDispatcher(campaign_directory='hpctools', logger=None, config=None)[source]#
Bases:
ABCShared configuration, logging, and public API for the dispatchers.
The public methods here are a flat facade over composed helpers, so that workflows and models depend on one stable interface rather than on how the work is split up internally. Subclasses install the local or remote implementation of each helper, and only override a method when the behavior genuinely differs.
- Parameters:
campaign_directory (str)
logger (Logger)
- call(target, *args, run_directory=None, **kwargs)[source]#
Run a Python callable named as “module:qualname” (e.g. “my_model:evaluate”) and return its result, forwarding the remaining arguments to it.
Modules staged in run_directory are importable; it defaults to the dispatcher’s own default directory.
- Parameters:
target (str)
run_directory (str)
- collect_results()[source]#
Bring a finished job’s output back to the local machine. Work that ran here leaves its results in place, so only remote dispatchers act.
- Return type:
None
- abstractmethod run(cmd, run_directory=None)[source]#
Run a command directly on the execution host.
A command that exits non-zero is reported, not raised: check
result.okorresult.exit_code. Every dispatcher behaves this way, so a model can be moved between them unchanged.Returns a Result object (with stdout, stderr, exit_code, ok)
- Parameters:
cmd (str)
run_directory (str)
- Return type:
- submit_job(cmd=None, run_directory=None)[source]#
Submit work to SLURM, wait for it to finish, and read back its output.
cmd runs from run_directory, which defaults to the campaign directory; omit cmd only when a configured SLURM script carries the command itself.
Returns a Result object (with stdout, stderr, exit_code, ok)
- Parameters:
cmd (str)
run_directory (str)
- Return type: