Skip to main content

Runs python script in argument combinations and produces dataset of all results.

Project description

pip install args_to_db

Data Generation Tool for Argument Optimisation

args_to_db is an attempt to generalize and simplify the process of running a programm in different modes or configurations and combining the resulting datasets to allow for further analysis.

The functionality is separated into three different (independently usable) parts:

Command Construction

Given a programm/script which is highly dependent on parameters and arguments, which we want to run for swarm of different settings, yielding datasets for further analysis.

Argument construction is made easy with the interfaces cmd, option, flag which are the intended way of constructing Command and CommandList objects.

from args_to_db import cmd, flag, option

py = cmd('python')
# > py=[['python']]

script = cmd('script.py')
# > py=[['script.py']]

data = option('--input', ['file1.csv', 'file2.csv'])
# > data=[['--input', 'file1.csv'],
#         ['--input', 'file2.csv']]

opt_flags = flag('-O') + flag('-r')
# > opt_flags=[[],
#              ['-r'],
#              ['-O'],
#              ['-O', '-r']]

log_flag = flag('--log', vary=False)
# > log_flag=[['--log']]

cmds = py + script + data + opt_flags + log_flag
# > cmds=[['python', 'script.py', '--input', 'file1.csv', '--log'],
#         ['python', 'script.py', '--input', 'file1.csv', '-r', '--log'],
#         ['python', 'script.py', '--input', 'file1.csv', '-O', '--log'],
#         ['python', 'script.py', '--input', 'file1.csv', '-O', '-r', '--log'],
#         ['python', 'script.py', '--input', 'file2.csv', '--log'],
#         ['python', 'script.py', '--input', 'file2.csv', '-r', '--log'],
#         ['python', 'script.py', '--input', 'file2.csv', '-O', '--log'],
#         ['python', 'script.py', '--input', 'file2.csv', '-O', '-r', '--log']]

The CommandList objects are arrays of commands (which themselves are arrays again), they behave like normal python arrays except for the differnt usage of the + and += operators.

Command Execution

A given CommandList object may then be executed with run, providing the user with a live interface in the terminal of execution states and parallelisation control of the execution.

run(cmds, threads=4)
# runs all specified commands with up to 4 concurrent threads.

Data Collection

Data may be produced by the programm/script independently of being called with args_to_db, which is therefore completely optional. But functionality is provided to make data collection and combination straight forward and as easy as possible for fast results.

args = argparse.ArgumentParser().parse_args()
config = config_from_args(args, __file__)
write_results(config, {'solver_solve_time': solve_time})

This produces an output which is then later on combined with the others by the run task - note the native support of argparse objects which are often used for argument/parameter parsing.

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

args_to_db-0.1.7.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

args_to_db-0.1.7-py3-none-any.whl (24.4 kB view details)

Uploaded Python 3

File details

Details for the file args_to_db-0.1.7.tar.gz.

File metadata

  • Download URL: args_to_db-0.1.7.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for args_to_db-0.1.7.tar.gz
Algorithm Hash digest
SHA256 918db9a8d820fcc5909da55fe521f6e659d302c93b3f0cced450f8aa9b49bde3
MD5 6e23f5aa08fbf1a0580135f148909146
BLAKE2b-256 f325cbfdbe7e1c5b597e5b9bfe2f139b3352d8ed0b9b0c0c715fdf3bd50a4ac1

See more details on using hashes here.

File details

Details for the file args_to_db-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: args_to_db-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 24.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for args_to_db-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f551216f7280458ed48210b192a9003569dc53f6af0e92cc81a5c9090a699842
MD5 8fc113f4f7b802efff0d452523faba25
BLAKE2b-256 7125bbcdde578323eb51fdb8f68fdb36b9bcc4880b0c1416a65b7a2c6da30bab

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