projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changes to permit keep_server containers to authenticate to api_server.
[arvados.git]
/
crunch_scripts
/
hash
diff --git
a/crunch_scripts/hash
b/crunch_scripts/hash
index 6d6c88f64d555aef6990340256bd4129b8d42c92..3c157163d12b7948c0c480ba49342ee799dc97e9 100755
(executable)
--- a/
crunch_scripts/hash
+++ b/
crunch_scripts/hash
@@
-2,7
+2,6
@@
import arvados
import hashlib
import arvados
import hashlib
-import re
arvados.job_setup.one_task_per_input_file(if_sequence=0, and_end_task=True)
arvados.job_setup.one_task_per_input_file(if_sequence=0, and_end_task=True)
@@
-11,22
+10,25
@@
this_task = arvados.current_task()
this_task_input = this_task['parameters']['input']
if 'algorithm' in this_job['script_parameters']:
this_task_input = this_task['parameters']['input']
if 'algorithm' in this_job['script_parameters']:
- alg = this_job['script_parameters']
+ alg = this_job['script_parameters']
['algorithm']
else:
alg = 'md5'
digestor = hashlib.new(alg)
else:
alg = 'md5'
digestor = hashlib.new(alg)
-input_
stream = arvados.DataReader(this_task_input)
+input_
file = list(arvados.CollectionReader(this_task_input).all_files())[0]
while True:
while True:
- buf = input_
stream
.read(2**20)
+ buf = input_
file
.read(2**20)
if len(buf) == 0:
break
digestor.update(buf)
hexdigest = digestor.hexdigest()
if len(buf) == 0:
break
digestor.update(buf)
hexdigest = digestor.hexdigest()
-file_name = re.sub(r'^[^/]+/', '', this_task_input)
-
input_stream.clos
e()
-
-
this_task.set_output("%s %s\n" % (hexdigest, file_name)
)
+
file_name = input_file.nam
e()
+if input_file.stream_name() != '.':
+
file_name = os.join(input_file.stream_name(), file_name
)
+out = arvados.CollectionWriter()
+out.set_current_file_name("md5sum.txt")
+out.write("%s %s\n" % (hexdigest, file_name))
+this_task.set_output(out.finish())