API reference

Utility functions that make it easier to write a Resolwe process.

resolwe_runtime_utils.save(key, value)

Convert the given parameters to a JSON object.

JSON object is of the form: { key: value }, where value can represent any JSON object.

resolwe_runtime_utils.save_list(key, *values)

Convert the given list of parameters to a JSON object.

JSON object is of the form: { key: [values[0], values[1], … ] }, where values represent the given list of parameters.

resolwe_runtime_utils.save_file(key, file_path, *refs)

Convert the given parameters to a special JSON object.

JSON object is of the form: { key: {“file”: file_path}}, or { key: {“file”: file_path, “refs”: [refs[0], refs[1], … ]}}

resolwe_runtime_utils.save_file_list(key, *files_refs)

Convert the given parameters to a special JSON object.

Each parameter is a file-refs specification of the form: <file-path>:<reference1>,<reference2>, …, where the colon ‘:’ and the list of references are optional.

JSON object is of the form: { key: {“file”: file_path}}, or { key: {“file”: file_path, “refs”: [refs[0], refs[1], … ]}}

resolwe_runtime_utils.save_dir(key, dir_path, *refs)

Convert the given parameters to a special JSON object.

JSON object is of the form: { key: {“dir”: dir_path}}, or { key: {“dir”: dir_path, “refs”: [refs[0], refs[1], … ]}}

resolwe_runtime_utils.save_dir_list(key, *dirs_refs)

Convert the given parameters to a special JSON object.

Each parameter is a dir-refs specification of the form: <dir-path>:<reference1>,<reference2>, …, where the colon ‘:’ and the list of references are optional.

JSON object is of the form: { key: {“dir”: dir_path}}, or { key: {“dir”: dir_path, “refs”: [refs[0], refs[1], … ]}}

resolwe_runtime_utils.info(value)

Call save function with “proc.info” as key.

resolwe_runtime_utils.warning(value)

Call save function with “proc.warning” as key.

resolwe_runtime_utils.error(value)

Call save function with “proc.error” as key.

resolwe_runtime_utils.progress(progress)

Convert given progress to a JSON object.

Check that progress can be represented as float between 0 and 1 and return it in JSON of the form:

{“proc.progress”: progress}
resolwe_runtime_utils.checkrc(rc, *args)

Check if rc (return code) meets requirements.

Check if rc is 0 or is in args list that contains acceptable return codes. Last argument of args can optionally be error message that is printed if rc doesn’t meet requirements.

Output is JSON of the form:

{“proc.rc”: <rc>,
“proc.error”: “<error_msg>”},

where “proc.error” entry is omitted if empty.

resolwe_runtime_utils.export_file(file_path)

Prepend the given parameter with export

class resolwe_runtime_utils.ImportedFormat

Import destination file format.

resolwe_runtime_utils.import_file(src, file_name, imported_format='both', progress_from=0.0, progress_to=None)

Import file to working directory.

Parameters:
  • src – Source file path or URL
  • file_name – Source file name
  • imported_format – Import file format (extracted, compressed or both)
  • progress_from – Initial progress value
  • progress_to – Final progress value
Returns:

Destination file path (if extracted and compressed, extracted path given)