API reference¶
Utility functions that make it easier to write a Resolwe process.
-
class
resolwe_runtime_utils.
OutputType
¶ An enumeration.
-
resolwe_runtime_utils.
command
(name, data)¶ Create a command from command name and payload.
-
resolwe_runtime_utils.
send_message
(data, header_size=8)¶ Send data over socket.
-
resolwe_runtime_utils.
collect_entry
(entry, references)¶ Get the size of the entry and its references and upload them.
The entry and its references are uploaded to the chosen storage connector.
NOTE: This process may take considerable amount of time.
Args entry: file or directory that is being collected. Args references: references belonging to the entry.
-
resolwe_runtime_utils.
save_list
(key, *values)¶ Construct save_list command.
-
resolwe_runtime_utils.
annotate_entity
(key, value)¶ Construct annotate entity command.
-
resolwe_runtime_utils.
save
(key, value)¶ Construct save command.
-
resolwe_runtime_utils.
save_file
(key, file_path, *refs)¶ Construct save file command.
Data is of the form: { key: {“file”: file_path, “size”: file_size, “total_size”: total_size }}
with added references
“refs”: [refs[0], refs[1], … ]
when applicable.
-
resolwe_runtime_utils.
save_file_list
(key, *files_refs)¶ Construct the save files command.
Each parameter is a file-refs specification of the form: <file-path>:<reference1>,<reference2>, …, where the colon ‘:’ and the list of references are optional.
Data 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)¶ Construct save dir command.
Data 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)¶ Construct save dirs command.
Each parameter is a dir-refs specification of the form: <dir-path>:<reference1>,<reference2>, …, where the colon ‘:’ and the list of references are optional.
Data object is of the form: { key: {“dir”: dir_path}}, or { key: {“dir”: dir_path, “refs”: [refs[0], refs[1], … ]}}
-
resolwe_runtime_utils.
info
(value)¶ Construct info command.
-
resolwe_runtime_utils.
warning
(value)¶ Construct warning command.
-
resolwe_runtime_utils.
error
(value)¶ Construct error command.
-
resolwe_runtime_utils.
progress
(progress)¶ Construct progress command.
Progress is reported as float between 0 and 1 and sent to listener as int between 0 and 100.
-
resolwe_runtime_utils.
checkrc
(rc, *args)¶ Check if
rc
(return code) meets requirements.Check if
rc
is 0 or is inargs
list that contains acceptable return codes. Last argument ofargs
can optionally be error message that is printed ifrc
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)¶ Construct export command.
-
resolwe_runtime_utils.
run
(process_slug, run)¶ Run process with the given slug with the given inputs.
The argument run must be a valid JSON string representing the inputs.
-
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)