Python utils for writing gamayun job scripts
Project description
Python utilities for Gamayun
This is a package containing python utilities for writing Gamayun jobs. Main Gamayun repository can be found here.
Contents
Getting the package
Install the package with the following command:
pip3 install gamayun-utils
This package depends on gprcio, which needs C/C++ compilers installed on the system. Needed dependencies on Alpine are:
apk add --no-cache python3 \
&& apk add --no-cache gcc \
&& apk add --no-cache g++ \
&& apk add --no-cache libc-dev \
&& apk add --no-cache linux-headers \
&& apk add --no-cache python3-dev
Note that suggested way of using Gamayun is with Docker, so you don't have to install these dependencies locally. If you are using Docker, there is an image containing Gamayun and Gamayun Python utilities here.
See Gamayun main repo for more information and see example usage here.
Usage
This part documents the package API
Reporting results and errors
Functions for reporting results or errors from the script are following:
def report_result(results)
def report_error(error)
report_result
receives a list of strings which represent results and report_error
receives a string which represents the error.
Note that once result or error is reported for the script/gamayun-job, Gamayun will stop listening for results/errors for that job, so in entire job there should be only one call to report_result
or report_error
.
Executing the script logic
There is a function with the following signature in this package:
def run_gamayun_script_logic(callback)
All the script logic should be placed in some function and that function should be given to run_gamayun_script_logic
as argument as this will ensure that all uncought exceptions are caught and reported as errors to Gamayun.
So, a job script file should look something like this:
from gamayun_utils import report_result
from gamayun_utils import report_error
from gamayun_utils import run_gamayun_script_logic
def script_logic():
# place the script logic here
if OK:
report_result(results)
else:
report_error(error)
run_gamayun_script_logic(script_logic)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gamayun_utils-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 402437a54dfb793b90128b5debd589ec5d72cd32763d272e8351288307c54732 |
|
MD5 | 5d5864169af099b11b3d092bb42fb236 |
|
BLAKE2b-256 | c2d223a7c84cdb278ab0928ebc3b8e06c2a84052f65f15d2f71a12be42447be2 |