Skip to main content

Command Line Interface (CLI)

Everything seen/clicked in the GUI can also be read/written via the CLI. All available commands can be found in the help menu (available in the terminal).

CLI: Help Menu Examples

Top-level menu:

pyra-cli --help
# Usage: pyra-cli [OPTIONS] COMMAND [ARGS]...
#
# Options:
# --help Show this message and exit.
#
# Commands:
# config
# core
# logs
# plc
# remove-filelocks Remove all filelocks.
# state

Command group menu:

pyra-cli config --help
# Usage: pyra-cli config [OPTIONS] COMMAND [ARGS]...
#
# Options:
# --help Show this message and exit.
#
# Commands:
# get Read the current config.json file.
# update Set the config.json file.
# validate Validate the current config.json file.

Individual command menus:

pyra-cli config update --help
# Usage: pyra-cli config update [OPTIONS] [CONTENT]
#
# Set config. Pass the JSON directly or via a file path. Only a subset of the
# required config variables has to be passed. The non-occurring values will be
# reused from the current config.
#
# The required schema can be found in the documentation.
#
# Options:
# --help Show this message and exit.

CLI: Config Update

Running the following command will update the number of seconds Pyra spends in one loop:

pyra-cli config update "{\"general\":{\"seconds_per_core_iteration\":20}}\"

The same command can be achieved in Python without all the escaping done manually:

import json
import os
import subprocess

def run_pyra_cli_config_update(update: dict) -> str:
p = subprocess.run(
args=["pyra-cli.bat", "config", "update", json.dumps(update)],
cwd=os.path.join(os.environ["USERPROFILE"], "Documents","pyra"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stderr, stdout = p.stderr.decode().strip(), p.stdout.decode().strip()
assert p.returncode == 0, f"pyra-cli config update failed: {stderr}"
return stdout


update = {"general": {"seconds_per_core_iteration": 20}}
print(run_pyra_cli_config_update(update))

Pyra will validate the structure of the update and enforce some rules on the parameter values (value range, file existence, etc.)

The developer docs contain a full list of schema and value requirements for the config file.

Starting and Stopping Measurements via CLI

  1. Set Pyra's measurement mode to "CLI mode" using the UI or the CLI:
pyra-cli config update "{\"measurement_decision\": {\"mode\": \"cli\"}}"
update = {"measurement_decision": {"mode": "cli"}}
run_pyra_cli_config_update(update)
  1. Update the CLI's decision on whether or not to measure using the CLI:
pyra-cli config update "{\"measurement_decision\": {\"cli_decision_result\": true}}"
pyra-cli config update "{\"measurement_decision\": {\"cli_decision_result\": false}}"
update = {"measurement_decision": {"cli_decision_result": True}}
run_pyra_cli_config_update(update)

update = {"measurement_decision": {"cli_decision_result": False}}
run_pyra_cli_config_update(update)
info

The CLI does not offer commands for starting and stopping CamTracker or OPUS directly because this conflicts with PYRA Core's management of these applications.