Command Line Example

See the associated video training – Python CLI Example

Download the script here – mstarcli.py

This example provides a command line utility that does the following:

  • Load in MSB file

  • Modify any number of parameters

  • Saves the new MSB file

  • Exports the case

  • Runs the case

Usage help

usage: mstarcli.py [-h] [-f FILENAME] [-p PARAMETERS] [--gpus GPUS] [--name NAME] [--export] [--save] [--run] [--check] [--print]
                                [--force]

Command line utility to modify and run M-Star cases

optional arguments:
-h, --help            show this help message and exit
-f FILENAME, --filename FILENAME
                                                Specify the .msb filename to load in
-p PARAMETERS, --parameter PARAMETERS
                                                Specify a parameter value in the form "Object Name:Rotation Speed:120"
--gpus GPUS           List of GPU IDs, eg. --gpus=0,1
--name NAME           Name fo the case. Used for run directory and msb file naming
--export              Export case files. Requires --name
--save                Save msb file as name.msb where name is specified by --name. Requires --name
--run                 Run the solver with the modified values. Requires --gpus and --name. Implies --export and --run
--check               Perform model check. If any model check fails, processing is stopped.
--print               Print objects and parameters in the model
--force               Overwrites/removes existing files and directories

Example invocation

Here we are using a base document called “base.msb” and changing the rotation speed

python mstarcli.py -f base.msb -p "Moving Body:Rotation Speed:120" --name r120 --run --gpus 0 --force