# popy_run

The most important command in the suite of Command Line Tools is popy_run. It processes PoPy scripts.

## Running a script

To run a PoPy script Open a PoPy Command Prompt and type:-

    $ popy_run my_script.pyml

What happens with the script depends on its type. There are many script formats:-

- fit - Fit a model to data
- gen - Generate data from a model
- sim - Simulate PK/PD curves
- tut - gen data and fit and compare the results
- comp - Compare gen and fit results
- mfit - Fit a model to multiple data sets
- mgen - Generate multiple data from a model
- msim - Simulate multiple PK/PD curves
- mtut - mgen multiple data and mfit and compare
- mcomp - Compare mgen and mfit results
- grph - Plot graphs
- vpc - Plot VPCs
- fitsum - HTML summary of fit results
- gensum - HTML summary of gen results
- tutsum - HTML summary of tut results
- n2pdat - converts Nonmem to PoPy data
- p2ndat - converts PoPy to Nonmem data

See Script File Formats for more information.

Note a common switch to use with popy_run is:-

    $ popy_run -o my_script.pyml

Here the ‘-o’ option overwrites previous output automatically. If the script has already been run and you do not use the ‘-o’ option, you will be asked to confirm you want to overwrite any previous output.

For other command line options see Command line options.

## Running multiple scripts

Note you can also run all scripts in a directory using:-

    $ popy_run *.pyml

This runs all files with the ‘.pyml’ extension in serial.

## Log files created by popy_run

When popy_run processes a script file, it creates a log file:-

    my_script.pyml.run.main.log

as a record of the output. If a runtime error occurs during processing, a stack trace is sent to:-

    my_script.pyml.run.error.log

as a record of what went wrong.

## Command line options

    usage: popy_run [-h] [-a] [-c] [-f] [-i] [-l] [-m] [-o] [-r] [-s] [-t]
                    [-v {noset,info,debug,warning,error,critical}]
                    input_file

    Runs a PoPy script

    positional arguments:
      input_file            Required path to input configuration file.

    optional arguments:
      -h, --help            show this help message and exit
      -a, --all_config      Optionally output all possible config file entries in
                            output script files. If set to false, the default
                            entries with default values are suppressed for the
                            sake of brevity.
      -c, --comment_scripts
                            Optionally add explanatory comments to all entries in
                            output script files.
      -f, --format_on_fly   Optionally attempt to format the input config file
                            during run. And switch to the new formatted verison of
                            the file. Note this re-formatting is only useful if
                            the input config is a valid version of an older PoPy
                            format.
      -i, --i_am_feeling_lucky
                            Optionally do NOT run the PoPy script checking i.e
                            silence the warnings and errors output at the start
                            this option is not recommended, but you can use if you
                            do not believe the warnings/errors and want to run
                            your script regardless.
      -l, --line_breaks     Optionally enforce line breaks in the config file.
                            This increases the length of files, but may improve
                            clarity. If set to False, short dictionary lines are
                            compacted instead using {} notation.
      -m, --manual_mode     Optionally do NOT run output scripts automatically,
                            even if 'output_mode: run' set in config file.
                            Effectively uses 'output_mode: create' instead. Then
                            user has to run output scripts manually.
      -o, --overwrite       Optionally overwrite existing output files without
                            asking.
      -r, --replicate_scripts
                            Optionally replicate input config files in log files.
      -s, --spaces          Optionally add more spaces to the output config file
                            for greater clarity, but longer config files. Off by
                            default.
      -t, --timestamp       Optionally included timestamp string in log file name
                            and output folder name.
      -v {noset,info,debug,warning,error,critical}, --verbosity {noset,info,debug,warning,error,critical}
                            verbosity of output in log file