OmniOpt2-Logo ScaDS.ai-Logo

Run automated tests

What are automated tests?

A large part of the source code of OmniOpt2 is to make sure that everything works as expected. This code executes real test cases and looks at the results to check if they are as expected. Many things in OmniOpt2 get tested automatically to see if they work properly. All test related files are in the folder .tests.

Why would I want to run those?

OmniOpt2 is supposed to be run on a wide variety of Linux systems. Not every system specific thing can be caught, though, since I cannot test it manually on all the available Linux-distributions. If you encounter problems in OmniOpt2, I may ask you to run those tests and submit the output to me, so that I can debug it thoroughly.

You may have made a change to OmniOpt2 and want to see if it still runs and you haven't broken anything.

How to run tests?

To run all tests, which takes a lot of time, run:

./.tests/main

Possible options:

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--exit_on_first_error
Exit on first error
bool
False
--help
This help
bool
False
--run_with_coverage
Allows to use coverage instead of python3 for coverage testing unit test coverage
bool
False
--quick
Only run quick tests
bool
False
--reallyquick
Only run really quick tests
bool
False
--superquick
Only run super quick tests
bool
False
--debug
Enables debug mode
bool
False
--no_linkchecker
Disable link checker
bool
False
--no_linter
Disable linter
bool
False
--skip_test_job_nr
Skip testing for proper job nrs
bool
False
--skip_first_n_tests
Skip the first n tests
int
--skip_worker_check
Skip worker checks
bool
False
--no_plots
Disables plot tests
bool
False

Example on the quickest useful test

When this succeeds without any errors, you can be reasonably sure that OmniOpt2 will properly do the following things under normal circumstances:

./.tests/main --num_random_steps=1 --max_eval=2 --reallyquick

All test scripts

adding_jobs_to_new_job

Test if adding jobs from existing jobs to new jobs works

all_shellscripts_with_help_have_help_page

See if all bash scripts have --help.

bandit

Tests for security-related python bugs and improvement suggestions.

check_if_results_csv_has_the_right_headers

Start an OmniOpt2 run and see if the results.csv has the proper results.

check_state_file_documentation

Test if all state files that are written are documented.

continued_constraint

Testing if continuing a constrained run works.

current_runs_plot_test

Plots all current projects in runs and tests if the plot script succeeded.

deadcode

Find unreachable and unused code.

doc_has_outdated_params

Test if any documentation page has outdated options for .omniopt.py/omniopt.

find_add_arguments_with_double_quotes

Find arguments in .omniopt.py that have double quotes and fail if they do, since other script that parse it need them to be single quotes.

find_double_add_arguments_help

Find arguments added multiple times in .omniopt.py.

find_double_function_names

Find function names that are defined twice or more.

find_double_function_thats_already_in_helper

Find functions that are defined in any .py and also .helpers.py, so that the they can be moved to the .helpers.py compeletly.

find_functions_that_are_defined_multiple_times

Find functions that are defined multiple times and could be moved to .helpers.py.

find_functions_with_missing_types

Find python-scripts with missing function return types.

find_missing_env_vars_documentation

Find environment variables that change how OmniOpt works that are not documented.

find_missing_toc_in_md_files

Find help documentation files missing the Table-of-Contents.

find_typos_in_bash

Finds typos in bash scripts.

find_typos_in_gui

Find typos in the GUI (PHP).

find_typos_in_js

Find typos in JavaScript-files.

find_typos_in_php

Find typos in php scripts.

find_typos_in_python

Find typos in python scripts.

find_undocumented_exit_codes

Check if all used exit codes are documented.

find_untyped_cli_args

Find CLI arguments that are not typed properly for mypy and beartype.

find_unused_but_documented_exit_codes

Find exit codes in documentation that are not used in OmniOpt2.

find_unused_functions_in_omniopt

Find functions in .omniopt.py that are unused.

find_unused_params

find parameters that are defined in OmniOpt but never used.

find_unused_params_in_plots

Find argparse parameter for plots that go unused.

find_unused_share_functions

Find functions in the share_functions.php that are not used anywhere.

find_wrong_order_definitions

Find definitions of functions that are in the wrong order.

find_wrongly_typed_cli_args

Find CLI arguments that have the wrong types.

flake8

Runs linter 'flake8' on python.

folder_structure

Tests if all files that are in the run subfolders are documented properly.

install_via_pip

Install via github and pip and test if it works properly.

js_syntax

Check syntax of JS scripts.

linkchecker

Checks all links on the site.

lint_python

Run python-linters only.

lizard

Test scripts for cyclomatic complexity.

missing_plot_metadata

Tests if al plot scripts have the metadata for the help pages, i.e. # EXPECTED FILES and # DESCRIPTION.

multiplication_constraint

Test non-standard constraints.

mypy

Run mypy to find variables that are not typed properly.

optimization_example

Simple optimization example based on the shekel-function.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--fixed_param
Will be ignored
bool
False
--fail_or_not
Whether to fail or not
0 or 1
--random_sem
Enable random SEM
0 or 1
--nr_results
Number of results the example program should have (default: 1)
int
--help
This help
bool
False
--debug
Enables debug mode
bool
False

optimization_example_full_search

Optimization example based on the shekel-function.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--help
This help
bool
False
--debug
Enables debug mode
bool
False

orchestrator

Tests if the orchestrator runs properly.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--nosuccess
Don't run successful tests
bool
False
--help
This help
bool
False
--debug
Enables debug mode
bool
False

php_files

Syntax check all PHP files.

php_search

Test if the search.php compiles and delivers proper results.

phpcs

Run a PHP linter.

plots

Test all plot scripts for different jobs.

post_job_pareto_front_calculation

Run an omniopt2 job with 2 result objectives, but cancel it, and test if the pareto front is calculated correctly afterwards.

pyflakes

Run pyflakes linter on .py files.

pylint

Runs pylint linter on python files.

radon

Find functions with too large cyclomatic complexity.

share

Tests the share page for PHP-syntax errors and other simple-to-test stuff.

share_tests

Run different tests for the share functions.

shellcheck

Lints bash files.

single_quotes_in_configloader

Tests if the config-loader in .omniopt.py has only single quotes, as double-quotes cause other scripts that parse it to fail.

state_files

Test if all state_files are properly documented.

unit_tests

Runs some basic unit-tests on different scripts.

wronggoing_stuff

Test if OmniOpt2 reacts properly if stuff goes wrong.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--nosuccess
Don't run successful tests
bool
False
--help
This help
bool
False
--debug
Enables debug mode
bool
False

linter

Run different linters.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--quick
Disable slow tests
bool
False
--help
This help
bool
False
--dont_fail_on_error
Don't fail on error
bool
False

optimization_example_all_float

Very simple single-objective-optimization-problem based on the shekel-function where all inputs are float.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--random_sem
Enable random SEM
0 or 1
--x
Any float
float
--y
Any float
float
--z
Any float
float
--a
Any float
float
--help
This help
bool
False
--debug
Enables debug mode
bool
False

start_simple_optimization_run

Start a simple optimization based on the shekel-function.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--max_eval
Maximum number of evaluations for this test
int
--mem_gb
Memory in GB (0 for all)
int
--num_parallel_jobs
Maximum number of parallel workers for this test
int
--num_random_steps
Number of random steps
int
--model
Model name
str
--gridsearch
Perform grid search
bool
False
--gpus
Number of GPUs per worker
int
--time
Time each subjob should run
int
--allow_failure
Adds a parameter to randomly fail
bool
False
--force_local_execution
Run locally even if SLURM is installed
bool
False
--all_float
Use all_float logic
bool
False
--flame_graph
Enable flame-graph
bool
False
--one_param
One parameter
bool
False
--two_params
Two parameters
bool
False
--nr_results
Nr of 'RESULT's (default: 1)
int
--seed
Seed
int
--additional_parameter
List of additional parameters
str
--alternate_min_max
Alternate min/max when nr_results > 1
bool
False
--force_choice_for_ranges
Force ranges to be converted to choice
bool
False
--follow
Follow tail
bool
False
--generate_all_jobs_at_once
Generate all jobs at once
bool
False
--verbose
Verbose output
bool
False
--revert_to_random_when_seemingly_exhausted
Revert to random if the model space is seemingly exhausted
bool
False
--testname
Override testname
str
--show_ram_every_n_seconds
Show ram usage every n seconds
int
--random_sem
Add random SEM to each result
bool
False
--help
This help
bool
False
--debug
Enable debug mode
bool
False

test_seed

Test if the seed is properly used and results are consistent and deterministic.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--seed
Sets the seed value
int
--gpus
Number of GPUs
int
--hash
MD5 hash value
str
--help
Displays this help message
bool
False

train_example_network

Starts an OmniOpt2 run that trains an example neural network.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--help
This help
bool
False
--debug
Enables debug mode
bool
False
--data
Data folder (default: data, possible options: data, data_tiny, data_full)
str
--num_parallel_jobs
Number of parallel jobs (default: 20, but at least --num_random_steps)
int
--worker_timeout
Number of minutes for a single-worker to timeout (default: 30)
int
--mem_gb
Memory in GB (default 5)
int
--time
Max runtime in minutes (default: 300)
int
--num_random_steps
Number of random steps
int
--max_eval
Max number of evals (default: 200)
int
--min_dense
Number of min dense layers (default: 1)
int
--max_dense
Number of max dense (default: 10)
int
--min_dense_units
Number of min dense_units layers (default: 1)
int
--max_dense_units
Number of max dense_units (default: 10)
int
--min_conv_filters
Number of min conv_filters layers (default: 1)
int
--max_conv_filters
Number of max conv_filters (default: 10)
int
--min_conv
Number of min conv layers (default: 1)
int
--max_conv
Number of max conv (default: 10)
int
--min_epochs
Number of min epochs (default: 10)
int
--max_epochs
Number of max epochs (default: 40)
int
--min_height
Min height (default: 40)
int
--max_height
max height (default: 80)
int
--min_width
Min width (default: 40)
int
--max_width
max width (default: 80)
int
--min_learning_rate
Min learning_rate (default: 0.01)
float
--max_learning_rate
Max learning_rate (default: 0.4)
float
--validation_split
Validation split (default: 0.2)
float
--result_names
Result names (default: VAL_ACCURACY=max VAL_LOSS=min RAM_USAGE=min RUNTIME=min)
str
--follow
Follow the output (default: 0)
bool
False
--gridsearch
Do gridsearch
bool
False
--generate_all_jobs_at_once
Generate all jobs at once
bool
False
--revert_to_random_when_seemingly_exhausted
Revert to random search when search space seems exhausted
bool
False

external_generator

Test external generator.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--mem_gb
Memory in GB (default: 1)
int
--time
Time in minutes (default: 60)
int
--worker_timeout
Timeout for worker (default: 60)
int
--max_eval
Maximum evaluations (default: 2)
int
--num_parallel_jobs
Number of parallel jobs (default: 1)
int
--gpus
Number of GPUs (default: 1)
int
--num_random_steps
Number of random steps (default: 1)
int
--external_generator
External generator command (Base64 encoded)
str
--help
Show this help message and exit
bool
False

randomforest

Test if random forest works properly.

multi_results_different_models

Test multi-objective-optimization with different models.

tpe

Test the Tree Parzen Estimator model (TPE).

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--max_eval
Maximum number of evaluations (default: 6)
--num_random_steps
Number of random steps before model (default: 1)
--num_parallel_jobs
Number of parallel jobs (default: 2)
--mem_gb
Memory in GB per job (default: 4)
--testname
Name for the test run (default: TPE)
--gpus
Use GPU (default: auto-detect)
0 or 1
--additional
Additional parameters for the optimizer
--help
Show this help message
bool
False

all_oo_options_are_in_gui_and_vice_versa

Find GUI options that are not in OmniOpt2 or vice versa, so they always reflect each other.

main

Main test script, coordinates complete test runs

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--exit_on_first_error
Exit on first error
bool
False
--help
This help
bool
False
--run_with_coverage
Allows to use coverage instead of python3 for coverage testing unit test coverage
bool
False
--quick
Only run quick tests
bool
False
--reallyquick
Only run really quick tests
bool
False
--superquick
Only run super quick tests
bool
False
--debug
Enables debug mode
bool
False
--no_linkchecker
Disable link checker
bool
False
--no_linter
Disable linter
bool
False
--skip_test_job_nr
Skip testing for proper job nrs
bool
False
--skip_first_n_tests
Skip the first n tests
int
--skip_worker_check
Skip worker checks
bool
False
--no_plots
Disables plot tests
bool
False

transforms

Test transforms.

Parameter Description Type Action Default Value
Ungrouped - Extracted from --help
--max_eval
Maximum number of evaluations (default: 6)
--num_random_steps
Number of random steps before model (default: 1)
--num_parallel_jobs
Number of parallel jobs (default: 2)
--mem_gb
Memory in GB per job (default: 4)
--testname
Name for the test run (default: TRANSFORMS)
--gpus
Use GPU (default: auto-detect)
0 or 1
--additional
Additional parameters for the optimizer
--help
Show this help message
bool
False