# 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

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] [-t] [-v {noset,info,debug,warning,error,critical}] [-a]
                    [-c] [-l] [-s] [-o] [--no_check] [-r] [-w N]
                    [--log_folder LOG_FOLDER]
                    script_path

    Runs a PoPy script.

    positional arguments:
      script_path           Required path to configuration file.

    options:
      -h, --help            show this help message and exit
      -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 files
      -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.
      -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.
      -s, --spaces          Optionally add more spaces to the output config file
                            for greater clarity, but longer config files. Off by
                            default.
      -o, --overwrite       Optionally overwrite existing output files without
                            asking.
      --no_check            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.
      -r, --replicate_scripts
                            Suppress replicating input config files in log files.
      -w N, --worker_index N
                            Optionally provide a worker index, so get separate log
                            files for each worker
      --log_folder LOG_FOLDER
                            Optional path to worker log folder.