Skip to content

Commit

Permalink
Merge pull request #24 from PanDAWMS/snakemake_workflows
Browse files Browse the repository at this point in the history
Snakemake workflows
  • Loading branch information
tmaeno authored Mar 23, 2023
2 parents b5ef868 + 9117074 commit c9c3c99
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions pandaclient/PchainScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,28 @@ def main():
group_build = optP.add_group('build', 'build/compile the package and env setup')
group_check = optP.add_group('check', 'check workflow description')


optP.add_helpGroup()

group_config.add_argument('--version', action='store_const', const=True, dest='version', default=False,
help='Displays version')
group_config.add_argument('-v', action='store_const', const=True, dest='verbose', default=False,
help='Verbose')
group_check.add_argument('--check', action='store_const', const=True, dest='checkOnly', default=False,
help='Check workflow description locally')
help='Check workflow description locally')
group_check.add_argument('--debug', action='store_const', const=True, dest='debugCheck', default=False,
help='verbose mode when checking workflow description locally')
help='verbose mode when checking workflow description locally')

group_output.add_argument('--cwl', action='store', dest='cwl', default=None,
help='Name of the main CWL file to describe the workflow')
group_output.add_argument('--yaml', action='store', dest='yaml', default=None,
help='Name of the yaml file for workflow parameters')
group_output.add_argument('--snakefile', action='store', dest='snakefile', default=None,
help='Name of the main Snakefile to describe the workflow')

group_build.add_argument('--useAthenaPackages', action='store_const', const=True, dest='useAthenaPackages',
default=False,
help='One or more tasks in the workflow uses locally-built Athena packages')
group_build.add_argument('--vo', action='store', dest='vo', default=None,
group_build.add_argument('--vo', action='store', dest='vo', default=None,
help="virtual organization name")
group_build.add_argument('--extFile', action='store', dest='extFile', default='',
help='root or large files under WORKDIR are not sent to WNs by default. '
Expand All @@ -85,7 +86,7 @@ def main():
help='Suppress email notification')
group_submit.add_argument('--prodSourceLabel', action='store', dest='prodSourceLabel', default='',
help="set prodSourceLabel")
group_submit.add_argument('--workingGroup', action='store', dest='workingGroup', default=None,
group_submit.add_argument('--workingGroup', action='store', dest='workingGroup', default=None,
help="set workingGroup")

group_expert.add_argument('--intrSrv', action='store_const', const=True, dest='intrSrv', default=False,
Expand All @@ -105,10 +106,23 @@ def main():
options = optP.parse_args()

# check
for arg_name in ['cwl', 'yaml', 'outDS']:
if options.cwl:
workflow_language = 'cwl'
workflow_file = options.cwl
workflow_input = options.yaml
args_to_check = ['yaml', 'outDS']
elif options.snakefile:
workflow_language = 'snakemake'
workflow_file = options.snakefile
workflow_input = ''
args_to_check = ['outDS']
else:
tmpLog.error('argument --cwl or --snakefile is required')
sys.exit(1)

for arg_name in args_to_check:
if not getattr(options, arg_name):
tmpStr = "argument --{0} is required".format(arg_name)
tmpLog.error(tmpStr)
tmpLog.error('argument --{0} is required'.format(arg_name))
sys.exit(1)

# check grid-proxy
Expand Down Expand Up @@ -139,8 +153,9 @@ def _onExit(dir, del_command):
archiveName = 'jobO.%s.tar.gz' % MiscUtils.wrappedUuidGen()
archiveFullName = os.path.join(tmpDir, archiveName)
extensions = ['cwl', 'yaml', 'json']
find_opt = ' -o '.join(['-name "*.{0}"'.format(e) for e in extensions])
tmpOut = MiscUtils.commands_get_output('find . {0} | tar cvfz {1} --files-from - '.format(find_opt, archiveFullName))
find_opt = ' -o '.join(['-name "*.{0}"'.format(e) for e in extensions] + ['-name "Snakefile"'])
tmpOut = MiscUtils.commands_get_output(
'find . {0} | tar cvfz {1} --files-from - '.format(find_opt, archiveFullName))

if options.verbose:
print(tmpOut + '\n')
Expand Down Expand Up @@ -177,9 +192,9 @@ def _onExit(dir, del_command):
params = {'taskParams': {},
'sourceURL': sourceURL,
'sandbox': archiveName,
'workflowSpecFile': options.cwl,
'workflowInputFile': options.yaml,
'language': 'cwl',
'workflowSpecFile': workflow_file,
'workflowInputFile': workflow_input,
'language': workflow_language,
'outDS': options.outDS,
'base_platform': os.environ.get('ALRB_USER_PLATFORM', 'centos7')
}
Expand Down

0 comments on commit c9c3c99

Please sign in to comment.