-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from JaimeCernuda/master
Added support for PBS scheduler
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
""" | ||
This module provides methods to execute a process in parallel using the | ||
Message Passing Interface (MPI). This module assumes MPI is installed | ||
on the system. This class is intended to be called from Exec, | ||
not by general users. | ||
""" | ||
|
||
from jarvis_util.jutil_manager import JutilManager | ||
from jarvis_util.shell.local_exec import LocalExec | ||
from .exec_info import ExecInfo, ExecType | ||
|
||
|
||
class PbsExec(LocalExec): | ||
""" | ||
This class contains methods for executing a command | ||
through the PBS scheduler | ||
""" | ||
|
||
def __init__(self, cmd, exec_info): | ||
""" | ||
Execute a command through qsub | ||
:param cmd: A command (string) to execute | ||
:param exec_info: Information needed by qsub | ||
""" | ||
self.cmd = cmd | ||
self.interactive = exec_info.interactive | ||
self.nnodes = exec_info.nnodes | ||
self.system = exec_info.system | ||
self.filesystems = exec_info.filesystems | ||
self.walltime = exec_info.walltime | ||
self.account = exec_info.account | ||
self.queue = exec_info.queue | ||
super().__init__(self.pbscmd(), | ||
exec_info.mod(env=exec_info.basic_env)) | ||
|
||
def generate_qsub_command(self): | ||
cmd = 'qsub' | ||
|
||
if self.interactive: | ||
cmd += ' -I' | ||
|
||
options_map = { | ||
'filesystems': 'l filesystems', | ||
'walltime': 'l walltime', | ||
'account': 'A', | ||
'queue': 'q' | ||
} | ||
|
||
if self.nnodes and self.system: | ||
cmd += f' -l select={self.nnodes}:system={self.system}' | ||
elif self.nnodes: | ||
cmd += f' -l select={self.nnodes}' | ||
else: | ||
raise ValueError("System defined without select value.") | ||
|
||
for attr, option in options_map.items(): | ||
value = getattr(self, attr) | ||
if value is not None: | ||
cmd += f' -{option}={value}' | ||
|
||
cmd += f' {self.cmd}' | ||
return cmd | ||
|
||
def pbscmd(self): | ||
cmd = self.generate_qsub_command() | ||
jutil = JutilManager.get_instance() | ||
if jutil.debug_pbs: | ||
print(cmd) | ||
return cmd | ||
|
||
|
||
class PbsExecInfo(ExecInfo): | ||
def __init__(self, **kwargs): | ||
super().__init__(exec_type=ExecType.PBS, **kwargs) | ||
allowed_options = ['interactive', 'nnodes', 'system', 'filesystems', 'walltime', 'account', 'queue'] | ||
self.keys += allowed_options | ||
# We use output and error file from the base Exec Info | ||
for key in allowed_options: | ||
if key in kwargs: | ||
setattr(self, key, kwargs[key]) | ||
else: | ||
setattr(self, key, None) |