Altair® Panopticon

 

Python

The Python connector allows the retrieval of output data from a Python Pyro (Python Remote Objects) process.

For Python connectivity, Python must be first installed, together with the latest version of Pyro4.  Additionally Pyro must be initiated manually or through using the batch file start_Python_connectivity.bat, which is found in the root of the Panopticon Designer (Desktop) installation.

If the scripts utilize additional modules such as Numpy and Scipy in the shipped example, these also need to be installed into the existing Python installation.

Using Python

  1. When creating a new data table, select Python from the Connect to data dialog. The Python Connection dialog is displayed:

 

  1. Update the Connection Details for the Python Pyro instance as appropriate:

    • Host

    • Port

    • HMAC Key - set to password

    • Data Object Name - the data structure (list of dictionaries) that Panopticon Designer (Desktop) will produce, and then will be utilized by the Python script.

  1. Select the Serialization Type: Serpent of Pickle

    • Serpent - simple serialization library based on ast.literal_eval

    • Pickle - faster serialization but less secure

 

Modify the configuration.py file located in ..\Anaconda3\Lib\site-packages\Pyro4 to specify the serialization to be used.

For example, if Pickle is selected, self.SERIALIZER value should be changed to pickle and self.SERIALIZERS_ACCEPTED value should be changed to include pickle:

 

  1. The time zone of input parameters and output data is by default unchanged. Changing the time zone is supported through the Timezone list box, based on the assumption that data is stored in UTC time and outputs are presented in the selected time zone.

Likewise, the time zone can also be parameterized.

In addition, the following Date/Time formats are supported in the Python connector:

    • yyyy-MM-dd'T'HH:mm:ss.SSSSSS

    • yyyy-MM-dd'T'HH:mm:ss

    • yyyy-MM-dd

  1. Enter the required Python Script to execute on the active Pyro instance. You can also opt to click Browse to select a Python Script file.

  2. Select whether the parameters should be automatically enclosed in quotes by checking the Enclose parameters in quotes box.

  3. After entering the valid Python script, click the Test Connection button. A confirmation dialog displays to show that the connection was successfully established.

  4. Click OK to execute the Python script, and return the resulting Python data object.

 

The returned Python data object should be a list of dictionaries, with each item of the list corresponding to a returned row, and each dictionary corresponding to a returned field name and value.

Example:

  table = []

  table.append({'ID':'1', 'Size':0.0045, 'Color':-0.060})

  table.append({'ID':'2', 'Size':0.1315, 'Color':-0.195})

  table.append({'ID':'3', 'Size':0.3463, 'Color':0.2188})

  table.append({'ID':'4', 'Size':0.2367, 'Color':-0.407})

  table.append({'ID':'5', 'Size':0.2357, 'Color':0.3081})

  return table