Saving and LoadingΒΆ

TyphosSuite objects can be stored for later use. The devices that were loaded into the suite via TyphosSuite.add_device() will be added once again assuming that they are stored in a happi database.

TyphosSuite.save()[source]

Save suite settings to a file using typhos.utils.save_suite().

A QFileDialog will be used to query the user for the desired location of the created Python file

The template will be of the form:

import sys
import typhos.cli

devices = {devices}

def create_suite(cfg=None):
    return typhos.cli.create_suite(devices, cfg=cfg)

if __name__ == '__main__':
    typhos.cli.typhos_cli(devices + sys.argv[1:])

There are two major ways to use this created file:

  1. Execute the Python file from the command line. This will route the call through the standard typhos.cli meaning all options described there are also available.

$ python saved_suite.py
  1. The create_suite method generated in the saved file can be used to re-create the TyphosSuite in an already running Python process. Typhos provides the load_suite() function to import the provided Python file and execute the stored create_suite method. This is useful if you want to use the file to embed a saved TyphosSuite inside another PyQt window for instance, or load multiple suites at once.

from qtpy.QtWidgets import QApplication
from typhos import load_suite

app = QApplication([])
saved_suite = load_suite('saved_suite.py')

saved_suite.show()
app.exec_()

Note

The saved file only stores a reference to the devices loaded into the TyphosSuite by name. It is assumed that these devices will be available under the same name via the configured happi database when load_suite is called. If the device has a different name in the database or you have configured a different happi database to be used your devices will not be loaded properly.