Saving and LoadingΒΆ

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

TyphonSuite.save()[source]

Save the TyphonSuite to a file using typhon.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 typhon.cli

devices = {devices}

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

if __name__ == '__main__':
    typhon.cli.typhon_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 typhon.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 TyphonSuite in an already running Python process. Typhon 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 TyphonSuite inside another PyQt window for instance, or load multiple suites at once.

from qtpy.QtWidgets import QApplication
from typhon 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 TyphonSuite 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.