Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
add a new option job_desc_extra
Browse files Browse the repository at this point in the history
  • Loading branch information
TaiSakuma committed Apr 22, 2017
1 parent 23b5317 commit d8bd76a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
7 changes: 6 additions & 1 deletion alphatwirl/concurrently/HTCondorJobSubmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

##__________________________________________________________________||
class HTCondorJobSubmitter(object):
def __init__(self):
def __init__(self, job_desc_extra = [ ]):

self.job_desc_template = """
Executable = {job_script}
Expand All @@ -47,6 +47,11 @@ def __init__(self):
"""
self.job_desc_template = textwrap.dedent(self.job_desc_template).strip()

if job_desc_extra:
job_desc_list = self.job_desc_template.split('\n')
job_desc_list[-1:-1] = job_desc_extra
self.job_desc_template = '\n'.join(job_desc_list)

self.clusterids_outstanding = [ ]
self.clusterids_finished = [ ]

Expand Down
48 changes: 47 additions & 1 deletion tests/unit/concurrently/test_HTCondorJobSubmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import tempfile
import shutil
import textwrap

from alphatwirl.concurrently import HTCondorJobSubmitter

Expand All @@ -21,6 +22,7 @@ def package_path(self, package_index):
##__________________________________________________________________||
class MockPopen(object):
def communicate(self, *args, **kwargs):
self.returncode = 0
return 'submitted to cluster 1012.', ''

##__________________________________________________________________||
Expand All @@ -35,6 +37,45 @@ def __init__(self):
def Popen(self, *args, **kwargs):
return MockPopen()

##__________________________________________________________________||
default_job_desc_template = """
Executable = {job_script}
output = {out}
error = {error}
log = {log}
{args}
should_transfer_files = YES
when_to_transfer_output = ON_EXIT
transfer_input_files = {input_files}
transfer_output_files = {output_files}
Universe = vanilla
notification = Error
# Initialdir = {initialdir}
getenv = True
queue 1
"""
default_job_desc_template = textwrap.dedent(default_job_desc_template).strip()

##__________________________________________________________________||
job_desc_template_with_extra = """
Executable = {job_script}
output = {out}
error = {error}
log = {log}
{args}
should_transfer_files = YES
when_to_transfer_output = ON_EXIT
transfer_input_files = {input_files}
transfer_output_files = {output_files}
Universe = vanilla
notification = Error
# Initialdir = {initialdir}
getenv = True
request_memory = 900
queue 1
"""
job_desc_template_with_extra = textwrap.dedent(job_desc_template_with_extra).strip()

##__________________________________________________________________||
class TestHTCondorJobSubmitter(unittest.TestCase):

Expand All @@ -53,9 +94,14 @@ def tearDown(self):

self.workingArea.close()

def test_init_job_desc_extra(self):
job_desc_extra = ['request_memory = 900']
obj = HTCondorJobSubmitter(job_desc_extra = job_desc_extra)
self.assertEqual(job_desc_template_with_extra, obj.job_desc_template)

def test_run(self):
obj = HTCondorJobSubmitter()
## obj.run(workingArea = self.workingArea, package_index = 0)
obj.run(workingArea = self.workingArea, package_index = 0)

##__________________________________________________________________||

0 comments on commit d8bd76a

Please sign in to comment.