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.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.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.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.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
orPharmDataFrame
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 andpython3 -m pharmpy
(via__main__.py
).
- pharmpy.cli.tdist(args)[source]¶
Subcommand to apply t-distribution transformation to specified etas of model.