<commit_before>"""experimentator

Usage:
  exp run [options] <exp-file> (--next <level>  [--not-finished] | (<level> <n>)...)
  exp resume [options] <exp-file> <level> [<n> (<level> <n>)...]
  exp  export <exp-file> <data-file>
  exp -h | --help
  exp --version

Options:
  --not-finished     Run the first <level> that hasn't finished (rather than first that hasn't started).
  --demo             Don't save data.
  --debug            Set logging level to DEBUG.
  --skip-parents     Don't call start and end callbacks of parent levels.
  -h, --help         Show full help.
  --version          Print the installed version number of experimentator.

Commands:
  run <exp-file> --next <level>        Runs the first <level> that hasn't started. E.g.:
                                         exp run exp1.dat --next session

  run <exp-file> (<level> <n>)...      Runs the section specified by any number of <level> <n> pairs. E.g.:
                                         exp run exp1.dat participant 3 session 1

  resume <exp-file> <level>            Resume the first section at <level> that has been started but not finished.

  resume <exp-file> (<level> <n>)...   Resume the section specified by any number of <level> <n> pairs. The specified
                                       section must have been started but not finished. E.g.:
                                         exp resume exp1.dat participant 2 session 2

  export <exp-file> <data-file>      Export the data in <exp-file> to csv format as <data-file>.
                                     Note: This will not produce readable csv files for experiments with
                                           results in multi-element data structures (e.g., timeseries, dicts).

"""
import sys
import logging
from docopt import docopt

from experimentator import __version__, load_experiment, run_experiment_section, export_experiment_data


def main(*args):
    options = docopt(__doc__, argv=args, version=__version__)

    if options['--debug']:
        logging.basicConfig(level=logging.DEBUG)

    if options['run'] or options['resume']:
        exp = load_experiment(options['<exp-file>'])
        kwargs = {'demo': options['--demo'],
                  'parent_callbacks': not options['--skip-parents'],
                  'resume': options['resume'],
                  }

        if options['--next']:
            kwargs.update(section_obj=exp.find_first_not_run(
                options['<level>'][0], by_started=options['--not-finished']))

        elif options['resume'] and not options['<n>']:
            kwargs.update(section_obj=exp.find_first_partially_run(options['<level>'][0]))

        else:
            kwargs.update(zip(options['<level>'], options['<n>']))

        run_experiment_section(exp, **kwargs)

    elif options['export']:
        export_experiment_data(options['<exp-file>'], options['<data-file>'])

if __name__ == '__main__':
    main(*sys.argv)
    sys.exit(0)<commit_msg>change how args are passed to main<commit_after>"""experimentator

Usage:
  exp run [options] <exp-file> (--next <level>  [--not-finished] | (<level> <n>)...)
  exp resume [options] <exp-file> <level> [<n> (<level> <n>)...]
  exp  export <exp-file> <data-file>
  exp -h | --help
  exp --version

Options:
  --not-finished     Run the first <level> that hasn't finished (rather than first that hasn't started).
  --demo             Don't save data.
  --debug            Set logging level to DEBUG.
  --skip-parents     Don't call start and end callbacks of parent levels.
  -h, --help         Show full help.
  --version          Print the installed version number of experimentator.

Commands:
  run <exp-file> --next <level>        Runs the first <level> that hasn't started. E.g.:
                                         exp run exp1.dat --next session

  run <exp-file> (<level> <n>)...      Runs the section specified by any number of <level> <n> pairs. E.g.:
                                         exp run exp1.dat participant 3 session 1

  resume <exp-file> <level>            Resume the first section at <level> that has been started but not finished.

  resume <exp-file> (<level> <n>)...   Resume the section specified by any number of <level> <n> pairs. The specified
                                       section must have been started but not finished. E.g.:
                                         exp resume exp1.dat participant 2 session 2

  export <exp-file> <data-file>      Export the data in <exp-file> to csv format as <data-file>.
                                     Note: This will not produce readable csv files for experiments with
                                           results in multi-element data structures (e.g., timeseries, dicts).

"""
import sys
import logging
from docopt import docopt

from experimentator import __version__, load_experiment, run_experiment_section, export_experiment_data


def main(args=None):
    options = docopt(__doc__, argv=args, version=__version__)

    if options['--debug']:
        logging.basicConfig(level=logging.DEBUG)

    if options['run'] or options['resume']:
        exp = load_experiment(options['<exp-file>'])
        kwargs = {'demo': options['--demo'],
                  'parent_callbacks': not options['--skip-parents'],
                  'resume': options['resume'],
                  }

        if options['--next']:
            kwargs.update(section_obj=exp.find_first_not_run(
                options['<level>'][0], by_started=options['--not-finished']))

        elif options['resume'] and not options['<n>']:
            kwargs.update(section_obj=exp.find_first_partially_run(options['<level>'][0]))

        else:
            kwargs.update(zip(options['<level>'], options['<n>']))

        run_experiment_section(exp, **kwargs)

    elif options['export']:
        export_experiment_data(options['<exp-file>'], options['<data-file>'])

if __name__ == '__main__':
    main(sys.argv)
    sys.exit(0)
{'fraction_non_alphanumeric': 0.12793427230046947, 'fraction_numerical': 0.00335345405767941, 'mean_word_length': 2.171185539606592, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '893016', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1629, 'n_words': 527}