Esempio n. 1
0
    def __init__(self, hawc2_path, hawc2_cmd, htc_file, exe_dir, input_files, output_files, queue='workq', walltime='00:10:00'):
        self.hawc2_path = hawc2_path
        self.hawc2_cmd = hawc2_cmd
        self.htc_file = htc_file
        self.exe_dir = exe_dir
        self.queue = queue
        self.walltime = walltime

        if not os.path.isabs(htc_file):
            htc_file = pjoin(exe_dir, htc_file)
        else:
            htc_file = htc_file.replace("\\", "/")

        if htc_file not in input_files:
            input_files.append(htc_file)
        self.input_files = [abspath((pjoin(exe_dir, f), abspath(f))[os.path.isabs(f)])
                            for f in input_files]
        self.htc_file = relpath(htc_file, exe_dir)

        self.output_files = [abspath((pjoin(exe_dir, f), abspath(f))[os.path.isabs(f)])
                             for f in output_files]

        self.model_path = abspath(pjoin(exe_dir, relpath(os.path.commonprefix(
            self.input_files + self.output_files).rpartition("/")[0], exe_dir)))
        self.model_name = os.path.basename(abspath(self.model_path))
        self.jobname = os.path.splitext(os.path.basename(htc_file))[0]

        PBSFile.__init__(self, self.model_path, self.jobname, self.commands, queue, walltime=walltime)
Esempio n. 2
0
def test_pbs_file():
    if x is None:
        pytest.xfail("Password missing")
    pbsfile = PBSFile("/home/mmpe/tmp", "test",
                      '''python -c "print('hello world')"''', 'workq')
    ssh = SSHClient("jess.dtu.dk", 'mmpe', x.mmpe)
    pbs_job = SSHPBSJob(ssh)
    pbs_job.submit(pbsfile, "./tmp")
    with pbs_job.ssh:
        start = time.time()
        while time.time() < start + 10:
            time.sleep(.1)
            if pbs_job.status == DONE:
                break
        else:
            raise Exception("job not finished within 10 s")
        _, out, _ = ssh.execute('cat ./tmp/stdout/test.out')
    assert "hello world" in out
Esempio n. 3
0
def test_pbs_file_str():
    pbsfile = PBSFile('/home/user/tmp', "test",
                      '''python -c "print('hello world')"''', 'workq')
    ref = """### Jobid
#PBS -N test
### Standard Output
#PBS -o /home/user/tmp/stdout/test.out
### merge stderr into stdout
#PBS -j oe
#PBS -W umask=0003
### Maximum wallclock time format HOURS:MINUTES:SECONDS
#PBS -l walltime=00:10:00
#PBS -l nodes=1:ppn=1
### Queue name
#PBS -q workq
cd "/home/user/tmp"
mkdir -p "stdout"
if [ -z "$PBS_JOBID" ]; then echo "Run using qsub"; exit ; fi
pwd
python -c "print('hello world')"
exit
"""
    assert str(pbsfile) == ref
Esempio n. 4
0
def test_pbs_walltime(i, s):
    pbsfile = PBSFile("./tmp", "test", '', 'workq', walltime=i)
    assert pbsfile.walltime == s