pharmpy.cli module

The CLI interface of Pharmpy

Examples

Example argument lines (only preceeded by pharmpy or python3 -m pharmpy):

# filter data (as model prescribes) and output to file 'output.csv'
pharmpy data write run1.mod -o output.csv

Entrypoints and Subcommands

Standard practice of packaging is to define “entrypoints” in the setuptools setup.py. Currently:

entry_points={
    'console_scripts': [
        'pharmpy           = pharmpy.cli:main',
    ]
},

Main entrypoint is pharmpy (which maps main()), but each subcommand could be given a shortcutting entrypoint (e.g. sumo()). This would be accomplished via invoking:

Installing Pharmpy Wheel-build should install all of these to PATH. Then, these are clean targets for post-install hooks to symlink. Either to pollute the PATH namespace with traditional PsN-styled “binscripts”, as:

/usr/bin/execute               ->  /usr/bin/pharmpy execute

Or, to keep multiple versions when upgrading Pharmpy.

On Logging

As a CLI we are at the top, interacting with the user. All of Pharmpy will get messages filtered through here (loggers organize themselves in a hiearchy based on their period-split names).

Warning

Loggers mustn’t be configurated if imported as library (e.g. set handlers and such), since that should bubble up into the lap of whomever is at the top (of the Python period-separated namespace).

Definitions

class pharmpy.cli.LazyLoader(local_name, parent_module_globals, name)[source]

Bases: module

Class that masquerades as a module and lazily loads it when accessed the first time

The code for the class is taken from TensorFlow and is under the Apache 2.0 license

This is needed for the cli to be able to do things as version and help quicker than if all modules were imported.

pharmpy.cli.add_covariate_effect(args)[source]

Subcommand to add covariate effect to model.

pharmpy.cli.add_iiv(args)[source]

Subcommand to add new IIVs to model.

pharmpy.cli.add_iov(args)[source]

Subcommand to add new IOVs to model.

pharmpy.cli.boxcox(args)[source]

Subcommand to apply boxcox transformation to specified etas of model.

pharmpy.cli.check_input_path(path)[source]

Resolves path to input file and checks existence.

Raises if not found or is dir, without tracebacks (see error_exit()).

pharmpy.cli.comma_list(s)[source]
pharmpy.cli.create_joint_distribution(args)[source]

Subcommand to create full or partial block structures.

pharmpy.cli.data_anonymize(args)[source]

Subcommand to anonymize a dataset anonymization is really a special resample case where the specified group (usually the ID) is given new random unique values and reordering. Will be default try to overwrite original file (but won’t unless force)

pharmpy.cli.data_append(args)[source]

Subcommand to append a column to a dataset

pharmpy.cli.data_filter(args)[source]

Subcommand to filter a dataset

pharmpy.cli.data_print(args)[source]

Subcommand to print a dataset to stdout via pager

pharmpy.cli.data_resample(args)[source]

Subcommand to resample a dataset.

pharmpy.cli.data_write(args)[source]

Subcommand to write a dataset.

pharmpy.cli.error(exception)[source]

Raise the exception with no traceback printed

Used for non-recoverables in CLI. Exceptions giving traceback are bugs!

pharmpy.cli.format_keyval_pairs(data_dict, sort=True, right_just=False)[source]

Formats lines from data_dict.

pharmpy.cli.generate_parsers(parsers)[source]
pharmpy.cli.iiv_on_ruv(args)[source]

Subcommand to multiply epsilons with exponential etas.

pharmpy.cli.info(args)[source]

Subcommand to print Pharmpy info (and brag a little bit).

pharmpy.cli.input_model(path)[source]

Returns Model from path.

Raises if not found or is dir, without tracebacks (see error_exit()).

pharmpy.cli.input_model_or_dataset(path)[source]

Returns Model or PharmDataFrame from path

pharmpy.cli.john_draper(args)[source]

Subcommand to apply John Draper transformation to specified etas of model.

pharmpy.cli.main(args)[source]

Entry point of pharmpy CLI util and python3 -m pharmpy (via __main__.py).

pharmpy.cli.model_absorption_rate(args)[source]
pharmpy.cli.model_elimination_rate(args)[source]
pharmpy.cli.model_error(args)[source]
pharmpy.cli.model_explicit_odes(args)[source]
pharmpy.cli.model_peripheral_compartments(args)[source]
pharmpy.cli.model_print(args)[source]

Subcommand for formatting/printing model components.

pharmpy.cli.model_sample(args)[source]
pharmpy.cli.model_transit_compartments(args)[source]
pharmpy.cli.power_on_ruv(args)[source]

Subcommand to apply power effect to RUVs.

pharmpy.cli.random_seed(seed)[source]
pharmpy.cli.remove_iiv(args)[source]

Subcommand to remove IIVs.

pharmpy.cli.remove_iov(args)[source]

Subcommand to remove IOVs.

pharmpy.cli.results_bootstrap(args)[source]

Subcommand to generate bootstrap results

pharmpy.cli.results_cdd(args)[source]
pharmpy.cli.results_frem(args)[source]

Generate frem results

pharmpy.cli.results_linearize(args)[source]
pharmpy.cli.results_ofv(args)[source]

Subcommand to extract final ofv from multiple results

pharmpy.cli.results_print(args)[source]

Subcommand to print any results

pharmpy.cli.results_qa(args)[source]
pharmpy.cli.results_report(args)[source]

Subcommand to generate reports

pharmpy.cli.results_resmod(args)[source]
pharmpy.cli.results_scm(args)[source]
pharmpy.cli.results_simeval(args)[source]
pharmpy.cli.results_summary(args)[source]

Subcommand to output summary of modelfit

pharmpy.cli.run_bootstrap(args)[source]
pharmpy.cli.run_execute(args)[source]
pharmpy.cli.run_modelsearch(args)[source]
pharmpy.cli.semicolon_list(s)[source]
pharmpy.cli.tdist(args)[source]

Subcommand to apply t-distribution transformation to specified etas of model.

pharmpy.cli.update_inits(args)[source]

Subcommand to update initial estimates from previous output.

pharmpy.cli.warnings_formatter(message, *args, **kwargs)[source]
pharmpy.cli.write_model_or_dataset(model_or_dataset, new_df, path, force)[source]

Write model or dataset to output_path or using default names

Inheritance Diagram

Inheritance diagram of pharmpy.cli