Skip to content

03. Installation and the Command Line Interface (CLI)

RJbalikian edited this page Dec 10, 2024 · 3 revisions

The command line interface (CLI) is introduced first since it is likely that you will need to install sprit from a CLI. Thus, initial tests and processing of data can be carried out from the same location as the package install. However, it is important to understand how the python functions are working under the hood, and for that, the python API wiki page is recommended.

Introduction to the Command Line Interface (CLI)

The command line interface (CLI) may be the quickest way to run or test the sprit package after install. It will run the sprit package python commands from the command line. The CLI may be preferred by some users and may be faster to access and run simple commands than either the python interface or GUI.

To install the sprit package, run the following, preferably in virtual environment (this can be run in conda environments, but it is recommended to use conda packages in conda environments. As of this writing, the sprit package does not yet have a conda package, though this is expected to be happen in the near future). For more details on creating a virtual environment in python, see here.

The following will install sprit in the activated environment.

pip install sprit --upgrade

The --upgrade argument is not strictly required, but is recommended since there are still many changes being implemented to the sprit package and having the most updated version will give the best chance that your package will work as expected and as outlined in this wiki.

Usage

To test that your package was installed correctly and that the CLI is working, enter the following in a terminal with the virtual environment activated where sprit was installed:

sprit --help

This will list out all of the parameters that you can use with the sprit command. For most purposes, the sprit command in the CLI is a command-line equivalent to running sprit.run() (see more details here about the details of that command). For the CLI, the first argument after the sprit command is the input_data parameter in sprit.input_params() (remember that sprit.run() passes its arguments to several other sprit commands, the first of which is sprit.input_params()). This input_data parameter should be the filepath to your data file(s), or a number 1-10 for the corresponding sample dataset. There are limited exceptions to this first argument being the input_data parameter; for example, if you use the command sprit gui, this will open the graphical user interface (GUI).

Sample Data

To test the functionality of the sprit CLI, you can use sample data. Sample data is accessed by calling "sample", or "sample1", "sample2"..."sample6", or simply the number ("1", "2", "3", etc.) as the input_data parameter:

sprit "sample1" or sprit "1" will both run the SpRIT algorithms on the first sample dataset (It is not recommended to use single quotes in the CLI, but it does work in some instances). In the case of the first sample dataset only, sprit sample or sprit "sample" may also be used.

For batch sample data, you will also need to set the file source as 'batch':

sprit "sample" --source "batch"

Examples

In all these examples, replace "sample" with a filepath if you would like to use your own data. Otherwise, these should work "out of the box" with the sample data included in the SpRIT package.

Run with verbose outputs and include a plot and print string report (verbose automatically prints a report to terminal)

sprit "sample" -v --report_format "plot"

(with verbose outputs, either -v or --verbose is the equivalent of verbose=True

Run with verbose outputs with plot and csv reports, and export these reports to directory

sprit "sample" -v --report_export_path "/path/to/output/directory/" --report_formats "plot","csv"

NOTE: shown in this above example is the preferred way to make a list input to an argument (note there are no spaces). Using spaces with no commas may also work.

You may also call --report_formats multiple times, as below (this will produce the same result as the previous call):

sprit "sample" -v --report_export_path "/path/to/output/directory/" --report_formats "plot" --report_formats "csv"

  This next call functions similarly, except it will first try to use the same directory as your input_data parameter. Since it is a sample file and it will attempt to write files into the package's sample data directory, it will then try to use your current working directory (usually, the directory from which you called the sprit command). If all else fails, it will default to the user's home directory:

sprit "sample" -v --report_export_path True --report_formats "plot","csv"

 

Accessing the Graphical User Interface (GUI) from the CLI

This is still experimental

If "GUI" or "gui" is entered as the first argument of the sprit command, rather than running sprit.run(), the graphical user interface (GUI) will be opened instead (the equivalent of running sprit.gui())

sprit GUI