Skip to main content

A small library to help running and logging the behaviour of research tools

Project description

runhelper

runhelper is a small library that helps you logs metrics for your instances and stores them on a easy to parse CSV file.

Tool-side Usage

Currently, there are three main types of metric supported.

Timer tags

Timer tags are used to time specific parts of your code.

runhelper.timer_start('my.tag')
time_sensitive_code1()
time_sensitive_code2()
runhelper.timer_stop('my.tag')

Times are accumulated during the execution of your tool.

Counter tags

Counter tags are used to count events.

runhelper.tag_increment('my.tag')

You can optionally increment the tag by a value different than 1 (floats are also supported).

runhelper.tag_increment('my.tag', 3)

Custom tags

You can also log any custom values you want.

runhelper.log_any('my.tag', my_object)

Automatic logging at program termination

By default, runhelper logs all timer and counter tags on normal program termination. If you also want to log when the program is force terminated you need to register the SIGTERM handler:

runhelper.register_sigterm_handler()

If you wish to perform additional operations when a SIGTERM happens you can also pass a callback:

runhelper.register_sigterm_handler(callback_function)

Evaluation-side Usage

The evaluation side of runhelper consists of a single class that encapsulates all functionality. The Runner class helps you run instances in parallel, supports timeouts and memouts (when used with rulsolver) and extracts all the tags logged from your tool into an easy to parse CSV file. The tool also allows you to transparently resume a previously running experiment, skipping all the instances that were executed already. The following snippet exemplifies its usage:

instances = [ INSTANCE_LIST ]

runner = Runner('path_to_runsolver', 'output_file.csv',
                 timeout=TIMELIMIT_IN_SECONDS,
                 memout=MEMLIMIT_IN_KBS,
                 pool_size=NUM_PROCESSES)
                 
for instance in instances:
    runner.schedule(instance, [TOOL_EXECUTABLE, ARG1, ARG2, ...], INSTANCE_OUTPUT_FILE)
    
runner.wait()

This code will, for each instance, call the command TOOL_EXECUTABLE with the arguments you specify and save its output to INSTANCE_OUTPUT_FILE. The result is a CSV file containing one line for each instance with some basic info, plus all the tags that you logged during the tool execution. Here is an example of an output file:

instance real cpu ram timeout memout my.tag.1 my.tag.2
i1 3.2 3.1 5600 False False 0.34 6
i2 10 9.8 6200 True False 0.2 11
i3 2.1 2 1200 False False 0.01 3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

runhelper-0.2.3.tar.gz (36.1 kB view details)

Uploaded Source

Built Distribution

runhelper-0.2.3-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file runhelper-0.2.3.tar.gz.

File metadata

  • Download URL: runhelper-0.2.3.tar.gz
  • Upload date:
  • Size: 36.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.2

File hashes

Hashes for runhelper-0.2.3.tar.gz
Algorithm Hash digest
SHA256 f4b10e83de45a924924f6aac33b8595308980bbd37302160f0bc0cf6e5f8a591
MD5 d77fb66ccd82b0b2e80aae5b4b9beba7
BLAKE2b-256 3a5f823f9b6b73c7c6498baf2c9793d1dec2d1ac5c6e680e71af7a99300a414c

See more details on using hashes here.

File details

Details for the file runhelper-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: runhelper-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.25.2

File hashes

Hashes for runhelper-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4f4c81e53183084eedd9499b6757327c4ba2787b5ed51e32dadb2b7d713afd86
MD5 1e167426f26ff26caa4bf9ff8fe2d62e
BLAKE2b-256 0607bdbd49eed37cd733e18c805e379532bb6a26a204f7981d2715328182d9d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page