.. _popy_run:

popy_run
##########

The most important command in the suite of :ref:`popy_tools` is :command:`popy_run`. It processes |popy| scripts.

.. _popy_run_single_script:

Running a script
==================

To run a |popy| script :ref:`open_a_popy_command_prompt` and type:-

.. code-block:: console

    $ popy_run my_script.pyml
 
What happens with the script depends on its :ref:`type <script_formats>`. There are many script formats:-
      
* :ref:`fit<fit_script>` - Fit a model to data
* :ref:`gen<gen_script>` - Generate data from a model
* :ref:`sim<sim_script>` - Simulate |pkpd| curves
* :ref:`tut<tut_script>` - :ref:`gen<gen_script>` data and :ref:`fit<fit_script>` and compare the results
* :ref:`comp<comp_script>` - Compare :ref:`gen<gen_script>` and :ref:`fit<fit_script>` results
* :ref:`mfit<mfit_script>` - Fit a model to multiple data sets
* :ref:`mgen<mgen_script>` - Generate multiple data from a model
* :ref:`msim<sim_script>` - Simulate multiple |pkpd| curves
* :ref:`mtut<mtut_script>` - :ref:`mgen<mgen_script>` multiple data and :ref:`mfit<mfit_script>` and compare
* :ref:`mcomp<mcomp_script>` - Compare :ref:`mgen<mgen_script>` and :ref:`mfit<mfit_script>` results
* :ref:`grph<grph_script>` - Plot graphs
* :ref:`vpc<vpc_script>` - Plot |vpcs|
* :ref:`fitsum<fitsum_script>` - |html| summary of :ref:`fit<fit_script>` results
* :ref:`gensum<gensum_script>` - |html| summary of :ref:`gen<gen_script>` results
* :ref:`tutsum<tutsum_script>` - |html| summary of :ref:`tut<tut_script>` results
* :ref:`n2pdat<n2pdat_script>` - converts |nonmem| to |popy| data
* :ref:`p2ndat<p2ndat_script>` - converts |popy| to |nonmem| data
     
See :ref:`script_formats` for more information.

Note a common switch to use with :command:`popy_run` is:-

.. code-block:: console

    $ 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 :ref:`popy_run_command_line_options`.

.. _popy_run_multi_scripts:

Running multiple scripts
=========================

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

.. code-block:: console

    $ popy_run *.pyml

This runs all files with the '.pyml' extension in serial.

.. _popy_run_log_files:
  
Log files created by popy_run 
===============================

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

.. code-block:: console

    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:-

.. code-block:: console

    my_script.pyml.run.error.log

as a record of what went wrong.
  
.. _popy_run_command_line_options:
  
Command line options
======================
    
.. literalinclude:: /_autogen/tool_help/popy_run_help.inc
    :language: console 
    