Example #1
0
 def _create_runscript(self):
     """Utility method to create runscript"""
     runscript = Script(
         directory=self.directory,
         prefix="sge_",
         suffix=".script",
         stem=str(uuid.uuid1().int),
     )
     runscript.append(self.__class__.SCRIPT_DIRECTIVE + " -V")
     runscript.append(self.__class__.SCRIPT_DIRECTIVE + " -w e")
     runscript.append(self.__class__.SCRIPT_DIRECTIVE + " -j yes")
     runscript.append(self.__class__.SCRIPT_DIRECTIVE + f" -N {self.name}")
     if self.dependency:
         cmd = f'-hold_jid {",".join(map(str, self.dependency))}'
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.priority:
         cmd = f"-p {self.priority}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.queue:
         cmd = f"-q {self.queue}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.runtime:
         cmd = f"-l h_rt={self.get_time(self.runtime)}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.shell:
         cmd = f"-S {self.shell}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.nprocesses and self.environment:
         cmd = f"-pe {self.environment} {self.nprocesses}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.directory:
         cmd = f"-wd {self.directory}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.extra:
         cmd = " ".join(map(str, self.extra))
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if len(self.script) > 1:
         logf = runscript.path.replace(".script", ".log")
         jobsf = runscript.path.replace(".script", ".jobs")
         with open(jobsf, "w") as f_out:
             f_out.write("\n".join(self.script))
         cmd = f"-t 1-{len(self.script)} -tc {self.max_array_size}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + f" -o {logf}")
         runscript.extend(self.get_array_bash_extension(jobsf, 0))
     else:
         runscript.append(self.__class__.SCRIPT_DIRECTIVE +
                          f" -o {self.log[0]}")
         runscript.append(self.script[0])
     return runscript
Example #2
0
 def _create_runscript(self):
     """Utility method to create runscript"""
     runscript = Script(
         directory=self.directory,
         prefix="lsf_",
         suffix=".script",
         stem=str(uuid.uuid1().int),
     )
     if self.dependency:
         cmd = "-w {}".format(" && ".join(
             [f"deps({d})" for d in self.dependency]))
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.directory:
         cmd = f"-cwd {self.directory}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.priority:
         cmd = f"-sp {self.priority}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.queue:
         cmd = f"-q {self.queue}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.runtime:
         cmd = f"-W {self.runtime}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.shell:
         cmd = f"-L {self.shell}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.nprocesses:
         cmd = f'-R "span[ptile={self.nprocesses}]"'
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.extra:
         cmd = " ".join(map(str, self.extra))
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if len(self.script) > 1:
         logf = runscript.path.replace(".script", ".log")
         jobsf = runscript.path.replace(".script", ".jobs")
         with open(jobsf, "w") as f_out:
             f_out.write("\n".join(self.script))
         cmd = f"-J {self.name}[1-{len(self.script)}]%{self.max_array_size}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + f" -o {logf}")
         runscript.extend(self.get_array_bash_extension(jobsf, 1))
     else:
         runscript.append(self.__class__.SCRIPT_DIRECTIVE +
                          f" -J {self.name}")
         runscript.append(self.__class__.SCRIPT_DIRECTIVE +
                          f" -o {self.log[0]}")
         runscript.append(self.script[0])
     return runscript
Example #3
0
def get_py_script(i, target):
    script = Script(
        shebang="#!{}".format(sys.executable),
        prefix="pyjob",
        stem="test{}".format(i),
        suffix=".py",
    )
    script.extend(inspect.getsource(fibonacci).splitlines())
    script.pop(0)  # remove decorator
    script.extend([
        "if __name__ == '__main__':",
        "\ttarget = {}".format(target),
        "\tprint('{}th fib is: {}'.format(target, fibonacci(target)))",
    ])
    return script
Example #4
0
 def _create_runscript(self):
     """Utility method to create runscript"""
     runscript = Script(
         directory=self.directory,
         prefix="slurm_",
         suffix=".script",
         stem=str(uuid.uuid1().int),
     )
     runscript.append(self.__class__.SCRIPT_DIRECTIVE + " --export=ALL")
     runscript.append(self.__class__.SCRIPT_DIRECTIVE +
                      f" --job-name={self.name}")
     if self.dependency:
         cmd = f'--depend=afterok:{":".join(map(str, self.dependency))}'
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.queue:
         cmd = f"-p {self.queue}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.nprocesses:
         cmd = f"-n {self.nprocesses}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.directory:
         cmd = f"--workdir={self.directory}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.runtime:
         cmd = f"-t {self.runtime}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if self.extra:
         cmd = " ".join(map(str, self.extra))
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
     if len(self.script) > 1:
         logf = runscript.path.replace(".script", ".log")
         jobsf = runscript.path.replace(".script", ".jobs")
         with open(jobsf, "w") as f_out:
             f_out.write("\n".join(self.script))
         cmd = f"--array=1-{len(self.script)}%{self.max_array_size}"
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + " " + cmd)
         runscript.append(self.__class__.SCRIPT_DIRECTIVE + f" -o {logf}")
         runscript.extend(self.get_array_bash_extension(jobsf, 0))
     else:
         runscript.append(self.__class__.SCRIPT_DIRECTIVE +
                          f" -o {self.log[0]}")
         runscript.append(self.script[0])
     return runscript