Skip to content

Commit

Permalink
use basename of input JSON as default string label (-s, --str-label)
Browse files Browse the repository at this point in the history
  • Loading branch information
leepc12 committed Jun 25, 2019
1 parent a302921 commit ace9777
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
31 changes: 6 additions & 25 deletions caper/caper.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class Caper(object):
RE_PATTERN_WDL_COMMENT_DOCKER = r'^\s*\#\s*CAPER\s+docker\s(.+)'
RE_PATTERN_WDL_COMMENT_SINGULARITY = \
r'^\s*\#\s*CAPER\s+singularity\s(.+)'
RE_PATTERN_VALID_STR_LABEL = r'^[A-Za-z0-9\-\_]+$'
RE_PATTERN_STARTED_WORKFLOW_ID = \
r'started WorkflowActor-(\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b)'
RE_PATTERN_FINISHED_WORKFLOW_ID = \
Expand Down Expand Up @@ -191,18 +190,9 @@ def run(self):
"""Run a workflow using Cromwell run mode
"""
timestamp = Caper.__get_time_str()
if self._str_label is not None:
# check if str label is valid
r = re.findall(Caper.RE_PATTERN_VALID_STR_LABEL,
self._str_label)
if len(r) != 1:
raise ValueError('Invalid str_label.')
suffix = os.path.join(
self._str_label, timestamp)
else:
# otherwise, use WDL basename
suffix = os.path.join(
self.__get_wdl_basename_wo_ext(), timestamp)
# otherwise, use WDL basename
suffix = os.path.join(
self.__get_wdl_basename_wo_ext(), timestamp)
tmp_dir = self.__mkdir_tmp_dir(suffix)

# all input files
Expand Down Expand Up @@ -346,18 +336,9 @@ def submit(self):
"""Submit a workflow to Cromwell server
"""
timestamp = Caper.__get_time_str()
if self._str_label is not None:
# check if label is valid
r = re.findall(Caper.RE_PATTERN_VALID_STR_LABEL,
self._str_label)
if len(r) != 1:
raise ValueError('Invalid str_label.')
suffix = os.path.join(
self._str_label, timestamp)
else:
# otherwise, use WDL basename
suffix = os.path.join(
self.__get_wdl_basename_wo_ext(), timestamp)
# otherwise, use WDL basename
suffix = os.path.join(
self.__get_wdl_basename_wo_ext(), timestamp)
tmp_dir = self.__mkdir_tmp_dir(suffix)

# all input files
Expand Down
5 changes: 5 additions & 0 deletions caper/caper_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,9 @@ def parse_caper_arguments():
args_d['singularity_cachedir'] = singularity_cachedir
os.makedirs(singularity_cachedir, exist_ok=True)

if args_d.get('str_label') is None:
if args_d.get('inputs') is not None:
basename = os.path.basename(args_d['inputs'])
args_d['str_label'] = os.path.splitext(basename)[0]

return args_d

0 comments on commit ace9777

Please sign in to comment.