Advertise filters param in discovery doc.
[arvados.git] / doc / _includes / _run_md5sum_py.liquid
1 #!/usr/bin/env python
2
3 import arvados
4
5 arvados.job_setup.one_task_per_input_file(if_sequence=0, and_end_task=True)
6 this_task = arvados.current_task()
7
8 # Get the input collection for this task
9 this_task_input = this_task['parameters']['input']
10
11 # Create a CollectionReader to access the collection
12 input_collection = arvados.CollectionReader(this_task_input)
13
14 # Get the name of the first file in the collection
15 input_file = list(input_collection.all_files())[0].name()
16
17 # Extract the file to a temporary directory
18 # Returns the directory that the file was written to
19 input_dir = arvados.util.collection_extract(this_task_input,
20         'tmp',
21         files=[input_file],
22         decompress=False)
23
24 # Run the external 'md5sum' program on the input file, with the current working
25 # directory set to the location the input file was extracted to.
26 stdoutdata, stderrdata = arvados.util.run_command(
27         ['md5sum', input_file],
28         cwd=input_dir)
29
30 # Save the standard output (stdoutdata) "md5sum.txt" in the output collection
31 out = arvados.CollectionWriter()
32 out.set_current_file_name("md5sum.txt")
33 out.write(stdoutdata)
34
35 this_task.set_output(out.finish())