Package: omnibenchmark
OmnibenchmarkGenerate and manage omnibenchmark modules for open and continuous benchmarking.
Each module represents a single building block of a benchmark, e.g., dataset, method, metric.
Omnibenchmark-py provides a structure to generate modules and automatically run them.InstallationYou can installomnibenchmarkfromPyPI:pipinstallomnibenchmarkThe module requires Python >= 3.8 andrenku >= 1.5.0.How to use omnibenchmarkFor detailed documentation and tutorials, check theomnibenchmark documentation.Quick startOmnibenchmark uses therenkuplatform to run open and continuous benchmarks. To contribute an independent module to one of the existing benchmarks please start by creating a newrenku project. Each module (= renkulab project) consists of a Docker image, which defines its software environment, a dataset to store outputs and metadata, a workflow that describes how to generate outputs and input and parameter datasets with input files and parameter definitions, if they are used. Thus, each module is an independent benchmark component and can be run, used and modified independently as such. Modules are connected by importing (result) datasets from other modules as input datasets and will automatically be updated according to them.All relevant information on how to run a specific module are stored asOmniObject.
The most convenient way to generate an instance of anOmniObjectis to build it from aconfig.yamlfile:## modulesfromomnibenchmark.utils.build_omni_objectimportget_omni_object_from_yaml## Load objectomni_obj=get_omni_object_from_yaml('src/config.yaml')Theconfig.yamldefines all module specific information as inputs, outputs, script to run the module, benchmark that the module belongs to and much more. A simpleconfig.yamlfile could look like this (seeThe config.yaml filefor more details):---
data:name:"module-name"title:"A new module"description:"A new module for omnibenchmark, e.g., a dataset, method, metric,..."keywords:["module-type-key"]script:"path/to/module_script"outputs:template:"data/${name}/${name}_${out_name}.${out_end}"files:counts:end:"mtx.gz"data_info:end:"json"meta:end:"json"benchmark_name:"an-omnibenchmark"Once you have an instance of anOmniObjectyou can check if it looks as you expected like this:## Check objectprint(omni_obj.__dict__)print(omni_obj.outputs.file_mapping)print(omni_obj.command.command_line)If all inputs, outputs and the command line call look as you expected you can run your module:## create output dataset that stores all result/output filesomni_obj.create_dataset()## Update inputs from other modulesomni_obj.update_obj()## Run your script with all defined inputs and outputs.## This also generates a workflow description (plan) and is tracked as activity.omni_obj.run_renku()## Link output files to output datasetomni_obj.update_result_dataset()## Save and commit to gitlabrenku_save()Once these steps ran successfully and your outputs were generated the module is ready to besubmitted to become a part of omnibenchmark.What is renku?Renkuis a platform and tools for reproducible and collaborative data analysis from theSwiss Data Science Centre. Besides other functionalities, renku provides a framework to create and run data analysis projects, which come with their own Docker container, datasets and workflows. By storing the metadata of projects and datasets on a knowledge graph, renku facilitates provenance tracking and project interactions. To do so renku combines a set of microservices:GitLab, for version control and project managementGitLFS, for file storageKubernetes/Docker, to manage containerized environmentsJupyter server, to provide interactive sessionsApache Jena, to generate, store and manage triplets and the triplet store (knowledge graph)Details on how to use renku can be found in theirDocumentation. Omnibenchmark uses renku to build and run collaborative and continuous benchmarks.Create a new renku projectOmnibenchmark modules are built as separate renku projects. Contributions to one of the existing benchmarks start by creating a new project using therenku platform. This can be done by registering directly or using a Github account, an ORCID or a Switch-EDU ID.
A new project can be created by a few clicks as describedhere. Templates can be chosen depending on the projects code or the Basic Python template. Project can then be populated/changed in an interactive renku session (see session tab of the project) or within the GitLab instance or clone of the project (Overview tab --> View in GitLab).Project requirementsProject requirements can be defined by adapting theDockerfileand specifying the all required R packages (with their versions) in theinstall.Rfile and all required python modules (with their versions) in therequirements.txtfile. The latter needs to contain at leastomnibenchmark. If you work in an interactive session, you need to save/commit your changes either by runningrenku saveorgit add/commit/pushand close and restart the session once the new Docker image has been built. The build of the docker image is triggered automatically after committing changes, but can take a while depending on the requirments (and the runner used).The config.yaml fileAll specific information about a benchmark component (= renkulab project) can be specified in aconfig.yamlfile. Below we show an example with all standard fields and explanations to them. Many fields are optional and do not apply to all modules. All unneccessary fields can be skipped. There are further optional fields for specfic edge cases, that are described in an extraconfig.yamlfile. In general, theconfig.yamlfile consists of a data, an input, an output and a parameter section as well as a few extra fields to define the main benchmark script and benchmark type. Except for the data section, the other sections are optional. Multiple values can be parsed as lists.# Data section to describe the object and the associated (result) datasetdata:# Name of the datasetname:"out_dataset"# Title of the dataset (Optional)title:"OutputofanexampleOmniObject"# Description of the dataset (Optional)description:"Thisdatasetissupposedtostoretheoutputfilesfromtheexampleomniobject"# Dataset keyword(s) to make this dataset reachable for other projects/benhcmark componentskeywords:["example_dataset"]# Script to be run by the workflow associated to the projectscript:"path/to/method/dataset/metric/script.py"# Interpreter to run the script (Optional, automatic detection)interpreter:"python"# Benchmark that the object is associated to.benchmark_name:"omni_celltype"# Orchestrator url of the benchmark (Optional, automatic detection)orchestrator:"https://www.orchestrator_url.com"# Input section to describe output file types. (Optional)inputs:# Keyword to find input datasets, that shall be importedkeywords:["import_this","import_that"]# Input file typesfiles:["count_file","dim_red_file"]# Prefix (part of the filename is sufficient) to automatically detect file types by their namesprefix:count_file:"counts"dim_red_file:["features","genes"]# Output section to describe output file types. (Optional)outputs:# Output filetypes and their endingsfiles:corrected_counts:end:".mtx.gz"meta:end:".json"# Parameter section to describe the parameter dataset, values and filter. (Optional)parameter:# Names of the parameter to usenames:["param1","param2"]# Keyword(s) used to import the parameter datasetkeywords:["param_dataset"]# Filter that specify limits, values or combinations to excludefilter:param1:upper:50lower:3exclude:12param2:"path/to/file/with/parameter/combinations/to/exclude.json"Below gives specific fields that are only relevant for edge cases. These fields have their counterparts in the generatedOmniObject.
Changes of the attributes of the OmniObject instance have the same effects, but come with the flexibility of running from python.# Command to generate the workflow with (Optional, automatic detection)command_line:"pythonpath/to/method/dataset/metric/script.py--count_filedata/import_this_dataset/...mtx.gz"inputs:# Datasets and manual file type specifications (automatic detection!)input_files:import_this_dataset:count_file:"data/import_this_dataset/import_this_dataset__counts.mtx.gz"dim_red_file:"data/import_this_dataset/import_this_dataset__dim_red_file.json"# (Dataset) name that default input files belong to (Optional, automatic detection)default:"import_this_dataset"# Input dataset names that should be ignored (even if they have one of the specified input keywords assciated)filter_names:["data1","data2"]outputs:# Template to automatically generate output filenames (Optional - recommended for advanced user only)template:"data/${name}/${name}_${unique_values}_${out_name}.${out_end}"# Variables used for automatic output filename generation (Optional - recommended for advanced user only)template_vars:vars1:"random"vars2:"variable"# Manual specification of mapping for output files and their corresponding input files and parameter values (automatic detection!)file_mapping:mapping1:output_files:corrected_counts:"data/out_dataset/out_dataset_import_this__param1_10__param2_test_corrected_counts.mtx.gz"meta:"data/out_dataset/out_dataset_import_this__param1_10__param2_test_meta.json"input_files:count_file:"data/import_this_dataset/import_this_dataset__counts.mtx.gz"dim_red_file:"data/import_this_dataset/import_this_dataset__dim_red_file.json"parameter:param1:10param2:"test"# Default output files (Optional, automatic detection)default:corrected_counts:"data/out_dataset/out_dataset_import_this__param1_10__param2_test_corrected_counts.mtx.gz"meta:"data/out_dataset/out_dataset_import_this__param1_10__param2_test_meta.json"parameter:default:param1:10param2:"test"Omnibenchmark classesClasses to manage omnibenchmark modules and their interactions. The main class is theOmniObject, that consolidates all relevant information and functions of a module. This object has further subclasses that define inputs, outputs, commands and the workflow.OmniObjectMain class to manage an omnibenchmark module.
It takes the following arguments:name (str): Module namekeyword (Optional[List[str]], optional): Keyword associated to the modules output dataset.title (Optional[str], optional): Title of the modules output dataset.description (Optional[str], optional): Description of the modules output dataset.script (Optional[PathLike], optional): Script to generate the modules workflow for.command (Optional[OmniCommand], optional): Workflow command - will be automatically generated if missing.inputs (Optional[OmniInput], optional): Definitions of the workflow inputs.parameter (Optional[OmniParameter], optional): Definitions of the workflow parameter.outputs (Optional[OmniOutput], optional): Definitions of the workflow outputs.omni_plan (Optional[OmniPlan], optional): The workflow description.benchmark_name (Optional[str], optional): Name of the associated benchmark.orchestrator (Optional[str], optional): Orchestrator URL of the associated benchmark. Automatic detection.wflow_name (Optional[str], optional): Workflow name. Will be set to the module name if none.dataset_name (Optional[str], optional): Dataset name. Will be set to the module name if none.The following methods can be run on an instance of an OmniObject:create_dataset(): Creates a renku dataset with the specified attributes in the current renku project.update_object(): Checks for new imports or updates in the input and parameter datasets. Will update object attributes accordingly.run_renku(): Generates and updates the workflow and all output files as specified in the object.update_result_dataset(): Updates and adds all output datasets to the dataset specified in the object.clean_revert_run(): Clean/Remove all outputs, workflows and activities associated with the object (including KG connections).check_updates(): Dry run option for update_object().check_run(): Dry run option for run_renku().OmniInputClass to manage inputs of an omnibenchmark module.
This class has the following attributes:names (List[str]): Names of the input filetypesprefix (Optional[Mapping[str, List[str]]], optional): Prefixes (or substrings) of the input filetypes.input_files (Optional[Mapping[str, Mapping[str, str]]], optional): Input files ordered by file types.keyword (Optional[List[str]], optional): Keyword to define which datasets are imported as input datasets.default (Optional[str], optional): Default input name (e.g., dataset).filter_names (Optional[List[str]], optional): Input dataset names to be ignored.multi_data_matching (Optional[bool]): If file matching across renku datasets should be allowed (defaults to False).The following class methods can be run on an instance of an OmniInput:update_inputs(): Method to import new and update existing input datasets and update the object accordinglyOmniOutputClass to manage outputs of an omnibenchmark module.
This class has the following attributes:name (str): Name that is specific for all outputs. Typically the module name/OmniObject name.out_names (List[str]): Names of the output file typesoutput_end (Optional[Mapping[str, str]], optional): Endings of the output filetypes.out_template (str, optional): Template to generate output file names.file_mapping (Optional[List[OutMapping]], optional): Mapping of input files, parameter values and output files.inputs (Optional[OmniInput], optional): Object specifying all valid inputs.parameter (Optional[OmniParameter], optional): Object speccifying the parameter space.default (Optional[Mapping], optional): Default output files.filter_json(Optional[str], optional): Path to json file with filter combinations.template_fun (Optional[Callable[..., Mapping]], optional): Function to use to automatically generate output filenames.template_vars (Optional[Mapping], optional): Variables that are used by template_fun.The following class methods can be run on an instance of an OmniInput:update_outputs(): Method to update the output definitions according to the objects attributes.OmniParameterClass to manage parameter of an omnibenchmark module.
This class has the following attributes:names (List[str]): Name of all valid parametervalues (Optional[Mapping[str, List]], optional): Parameter values - usually automatically detected.default (Optional[Mapping[str, str]], optional): Default parameter values.keyword (Optional[List[str]], optional): Keyword to import the parameter dataset with.filter (Optional[Mapping[str, str]], optional): Filter to use for the parameter space.combinations (Optional[List[Mapping[str, str]]], optional): All possible parameter combinations.The following class methods can be run on an instance of an OmniInput:update_parameter(): Method to import and update parameter datasets and update the object/parameter space accordingly.OmniCommandClass to manage the main workflow command of an omnibenchmark module.
This class has the following attributes:script (Union[PathLike, str]): Path to the script run by the commandinterpreter (str, optional): Interpreter to run the script with.command_line (str, optional): Command line to be run.outputs (OmniOutput, optional): Object specifying all outputs.input_val (Optional[Mapping], optional): Input file tyoes and paths to run the command on.parameter_val (Optional[Mapping], optional): Parameter names and values to run the command with.The following class methods can be run on an instance of an OmniInput:update_command(): Method to update the command according to the outputs,inputs,parameter.OmniPlanClass to manage the workflow of an omnibenchmark module.
This class has the following attributes:plan (PlanViewModel): A plan view model as defined in renkuparam_mapping (Optional[Mapping[str, str]], optional): A mapping between the component names of the plan and the OmniObject.The following class methods can be run on an instance of an OmniInput:predict_mapping_from_file_dict(): Method to predict the mapping from the (input-, output-, parameter) file mapping used to generate the command.Submit your moduleOnce a module is complete and works it can be included into the omnibenchmark orchestrator of the associated benchmark. This means it will be automatically run, continously updated and it's result will automatically be used as inputs by downstream modules. Please open an issue on the corresponding orchestrator GitLab project linking to the project to get the project taken up.
You can find the corresponding GitLab project at theomnibenchmark website.Release History0.0.48Enable global vars setting on object buildFIX:Adapt to name changes in renku pythonAdapt to renku-py 2.8.00.0.47FIX:Adapt to renku REST API changes for dataset imports/queriesUpdate gitlab url0.0.46Adapt to slug/name switch in renku dataset/project dataset APIs0.0.45FIX:Automatic activity generation0.0.44Add omni_essentials for orchestrator urlAdd local cache for orchestrator url0.0.43Adapt to renku version 2.4.21Switch to cross entity search api0.0.42Adapt to renku version 2.3.2Enable parallel execution of activities0.0.41New input argument "multi_data_matching" to explicitly allow matching files from multiple datasets.New function to link files to a dataset by prefix and keyword.FIX:Name checking returns conflicting dataset names.0.0.40FIX:file name matching for strings as file_type_dict values.0.0.39add sort_keys argument to omni_output (defaults to true -> alphabetically sorted parameter keys in out names)FIX:remove duplicated outputs independent of parameter orderclear project context in revert_runuse the next best match for equal matches in file name matching0.0.37Enable import of only one dataset by adding an all flagFIX:Match files by longest sequence instead of ratioWorkaround for bug in renku.api.Dataset.list()0.0.35Automatic input files matching prefixes for the same file typeAdd all parameter to renku_run only for ne activity and planAdapt to renku 1.10.00.0.34FIX:Enable project queries to ignore missing projects, instead of breaking0.0.33FIX:Add flag to actively push/save successfully finished activities after generation.0.0.32Add meaningful commit message to renku_save() after updating/generating activitiesAdjust to renku 1.9.1Adapt to mypy no_implicit_optional=True0.0.31Adapt to renku-python 1.8.1:Replace context manager by renku api to get plan and activity gatewaysAdjust project attributesFIX:Use url path in renku api lineage callEnable multipage results in renku api queries0.0.30FIX:Get a stable name hash used to automatically generate output names by fixing the order using sorted input file namesUse files that generated the workflow to do the file mapping0.0.29Add check_status and check_run to omni_obj class methodsFIX:Export these most important functionalities0.0.28Commit after generating/updating each activityAdd argument to disable orchestrator checkFIX:Include latest pipelines with optional numbers into orchestrator check0.0.27Change automatic output naming mechanismEnsure stable output names independent of other inputs0.0.26Add revert_run functionRemove outputs and activties with non existing inputsRemove datasets with non matching keywords0.0.23FIX:Adapt changes to renku 1.7.10.0.22FIX:Ignore datasets with broken urls0.0.17-19FIX:Update defaults after filtering0.0.16Add filter for input/parameter combinations0.0.15FIX:Replace command error with warning to allow to build an object before inputs are imported0.0.14FIX:Change benchmark url0.0.13Add function docstringsAdd name filter for importing input datasetsAdd Documentation in ReadmeFIX:Adapt renku_update_activities to handle skip_update_metadata argument in renku 1.5.00.0.12FIX:accept float as parameter values and keep after filtering0.0.9FIX:add common sequence to auto file matching0.0.8FIX:add update command to omni_obj.update_object()0.0.4 - 0.0.7FIX:convert defaults to string to generate planadapt output defaultdependency between command line call and renku input definitionsignore not existing defaults0.0.3FIX:automatic input detection from prefixes for files from the same dataset0.0.2FIX:automatic command detection, file_mapping.input_files structure0.0.1First version of all main functionalitiesMetaAlmut Lütge –@Almut30618742Anthony Sonrel –@AnthonySonrelMark Robinson –@markrobinsoncaDistributed under the Apache 2.0 license. SeeLICENSEfor more information.https://github.com/almutlue/omnibenchmark-pyContributingFork it (https://github.com/almutlue/omnibenchmark-py/fork)Create your feature branch (git checkout -b feature/fooBar)Commit your changes (git commit -am 'Add some fooBar')Push to the branch (git push origin feature/fooBar)Create a new Pull Request