diff --git a/ep3-runner b/ep3-runner index be8f201..7c8e7e2 100755 --- a/ep3-runner +++ b/ep3-runner @@ -67,6 +67,7 @@ end if $0 == __FILE__ extensions = [] + compute_checksum = true loglevel = Normal keep_tmpdir_level = nil @@ -101,6 +102,9 @@ if $0 == __FILE__ parser.on('--veryverbose', 'more verbose output') { loglevel = VeryVerbose } + parser.on('--[no-]compute-checksum', 'compute (or do not compute) checksum of contents (default: --compute-checksum)') { |cs| + compute_checksum = cs + } parser.on('--extension=EXT', 'specify extension') { |ext| extensions.push ext } @@ -178,7 +182,13 @@ if $0 == __FILE__ exit ret_run.fetch('return', 1) end - ret_list = run_cmd("#{basedir}/ep3 list #{target_arg} --copy #{dst_arg}", loglevel) + copt = if compute_checksum + '--compute-checksum' + else + '--no-compute-checksum' + end + + ret_list = run_cmd("#{basedir}/ep3 list #{target_arg} #{copt} --copy #{dst_arg}", loglevel) if ret_list['success'] tmpdir_will_be_removed = true unless keep_tmpdir_level == LeaveAlways exit 0 diff --git a/lib/ep3/ep3-list.rb b/lib/ep3/ep3-list.rb index 64660bc..c817399 100755 --- a/lib/ep3/ep3-list.rb +++ b/lib/ep3/ep3-list.rb @@ -7,11 +7,15 @@ require_relative 'runtime/stage-in' def ep3_list(args) + compute_checksum = true parser = OptionParser.new parser.banner = "Usage: ep3 list [options]" parser.on('--target-dir=DIR') parser.on('--copy') parser.on('--destination=DST') + parser.on('--[no-]compute-checksum') { |cs| + compute_checksum = cs + } opts = parser.getopts(args) unless args.empty? @@ -44,7 +48,7 @@ def ep3_list(args) v.nil? } puts JSON.dump(stagein(to_be_skipped, {}, output, dst, - opts.include?('copy'))) + opts.include?('copy'), compute_checksum)) 0 end diff --git a/lib/ep3/runtime/stage-in.rb b/lib/ep3/runtime/stage-in.rb index cf4dac4..dc72a18 100755 --- a/lib/ep3/runtime/stage-in.rb +++ b/lib/ep3/runtime/stage-in.rb @@ -7,19 +7,19 @@ require 'securerandom' require_relative 'inspector' -def stagein(to_be_skipped, staged_inputs, job, outdir, force_stagein = false) +def stagein(to_be_skipped, staged_inputs, job, outdir, force_stagein = false, compute_checksum = false) Hash[job.each.map{ |k, v| if to_be_skipped.call(k, v) nil elsif staged_inputs.include?(k) [k, staged_inputs[k].to_h] else - [k, stagein_(v, outdir, force_stagein).to_h] + [k, stagein_(v, outdir, force_stagein, compute_checksum).to_h] end }.compact] end -def stagein_(obj, outdir, force_stagein = false) +def stagein_(obj, outdir, force_stagein = false, compute_checksum = false) case obj when CWLFile if force_stagein or need_staging(obj) @@ -38,9 +38,9 @@ def stagein_(obj, outdir, force_stagein = false) end ret.location = 'file://'+ret.path ret.secondaryFiles = obj.secondaryFiles.map{ |sec| - stagein_(sec, outdir, true) + stagein_(sec, outdir, true, compute_checksum) } - ret.evaluate(nil) + ret.evaluate(nil, false, compute_checksum) else obj end @@ -52,21 +52,21 @@ def stagein_(obj, outdir, force_stagein = false) ret.location = 'file://'+ret.path FileUtils.mkdir_p ret.path ret.listing = obj.listing.map{ |lst| - stagein_(lst, ret.path, true) + stagein_(lst, ret.path, true, compute_checksum) } - ret.evaluate(nil) + ret.evaluate(nil, false, compute_checksum) else obj end when CWLRecordValue obj.fields.transform_values{ |v| - stagein_(v, outdir, force_stagein).to_h + stagein_(v, outdir, force_stagein, compute_checksum).to_h } when CWLUnionValue - stagein_(obj.value, outdir, force_stagein) + stagein_(obj.value, outdir, force_stagein, compute_checksum) when Array obj.map{ |o| - stagein_(o, outdir, force_stagein).to_h + stagein_(o, outdir, force_stagein, compute_checksum).to_h } else obj