API¶
Kliko contains various helper functions to validate Kliko files, parameter files based on a kliko definition, generate command line interfaces and django forms from Kliko definitions.
Validation¶
Kliko and parameter validation related functions.
-
kliko.validate.
convert_to_parameters_schema
(kliko)¶ Convert a kliko schema into a validator for the parameters generated with a kliko schema.
Parameters: kliko (str) – a kliko definition Returns: A structure for a pykwalify validator
-
kliko.validate.
validate
(kliko_file=False, paramaters_file=False)¶ Validate the kliko and paramaters file and parse the parameters file. Should be run inside the Kliko container.
Parameters: - kliko_file (str) – Path to a kliko file
- paramaters_file (str) – path to a parameters file
Returns: The validated and parsed paramaters file
-
kliko.validate.
validate_kliko
(kliko, version=3)¶ validate a kliko yaml string
Parameters: kliko – a parsed kliko object Returns: a (nested) kliko structure Return type: dict Raises: an exception if the string can’t be parsed or is not in the following the Kliko schema
-
kliko.validate.
validate_parameters
(parameters, kliko)¶ validate a set of parameters given a kliko definition
Parameters: - parameters (dict) – A structure that should follow the given kliko structure
- kliko (dict) – A nested dict which defines the valid parameters in Kliko format
Returns: the parsed parameters
Return type: str
Raises: an exception if the string can’t be parsed or is not in the defining valid parameters
Command line interface generation¶
Command line utilities for Kliko
-
kliko.cli.
directory_exists
(path)¶ check if a directory exists
-
kliko.cli.
file_exists
(path)¶ check if a file exists
-
kliko.cli.
first_parser
(argv)¶ This is only used when script in invoked with 0 or 1 args (should be kliko image name).
-
kliko.cli.
generate_kliko_cli_parser
(kliko_data, parent_parser=None)¶ Generate a command line parser from a Kliko structure.
Parameters: kliko_data (dict) – A nested kliko structure Returns: a configured argument parser Return type: argparse.ArgumentParser
-
kliko.cli.
kliko_runner
(argv)¶
-
kliko.cli.
prepare_io
(parameters, io, input_path=False, output_path=False, work_path=False, param_files_path=False)¶ Parameters: - parameters – A dict containing the parameters
- io (str) – split or join
- input_path – input path, defaults to $(pwd)/input
- output_path – output path, defaults to $(pwd)/output
- work_path – work path, defaults to $(pwd)/work
- param_files_path – param_files_path path, defaults to $(pwd)/input
Returns: (path to parameters file, input, output, work, param_files)
Return type: tuple
-
kliko.cli.
second_parser
(argv, kliko_data)¶ Used when kliko image is known, so we can extract the parameters.
Docker¶
Helper functions for using Kliko in combinaton with Docker
-
kliko.docker.
extract_params
(docker_client, image_name)¶ Parameters: - docker_client (docker.docker.Client) – a docker client object
- image_name (str) – name of the image to use for kliko.yml extraction
Returns: content of the param schema
Return type: str