Application Interface
The functions for interacting with the Insight server are provided by the xpressinsight.AppInterface class. The methods of that class can be used, e.g., for downloading and uploading attachments, and for getting scenario and application meta data.
You can access the application interface functions via the insight property of the Insight application. This property is inherited from the base class xpressinsight.AppBase. The following example code, can be used to upload an attachment from within the Insight application class:
self.insight.put_scen_attach("attachment.txt")
Note that the Python keyword self represents the current instance of the Insight application class. The following example shows how to integrate this line of code in an application.
import xpressinsight as xi @xi.AppConfig(name="Attachment Example") class App(xi.AppBase): @xi.ExecModeLoad(descr="Uploads attachment.") def load(self): with open("attachment.txt", "w") as text_file: text_file.write("Hello!") self.insight.put_scen_attach("attachment.txt") print('Upload status:', self.insight.attach_status) @xi.ExecModeRun(descr="Downloads attachment.") def run(self): self.insight.get_scen_attach("attachment.txt") print('Download status:', self.insight.attach_status) if self.insight.attach_status == xi.AttachStatus.OK: with open("attachment.txt", "r") as text_file: print(text_file.readline())
App Interface Classes
AppInterface |
This class represents the Xpress Insight application interface. Use this interface to access attachments and meta data like the scenario ID.
|
AppInterface.app_attach_info |
Retrieves information about a given app attachment.
|
AppInterface.app_id |
Property for the id of the Xpress Insight application which is the parent of the model.
|
AppInterface.app_name |
Property for the name of the Xpress Insight application which is the parent of the model.
|
AppInterface.attach_status |
Read-only property indicating the status of the most recent attempt to access or modify an attachment.
|
AppInterface.delete_scen_attach |
Deletes a scenario attachment.
|
AppInterface.delete_work_dir |
Delete the internal working directory of the xpressinsight package.
|
AppInterface.exec_mode |
Property for the execution mode in which Xpress Insight is running the model.
|
AppInterface.get_app_attach |
Retrieves an app attachment from the Insight server, placing it in the Python working directory where it can be read by the model.
|
AppInterface.get_attach_by_tag |
Gets Insight attachments by tag
|
AppInterface.get_attach_filenames_by_tag |
Gets Insight attachments by tag
|
AppInterface.get_attach_rules |
Retrieves the the 'rules' used to validate attachments and attachment meta-data.
|
AppInterface.get_attachs_by_tag |
Gets Insight attachments by tag
|
AppInterface.get_scen_attach |
Retrieves an attachment from the Insight server either for a given scenario, placing it in the Python working directory where it can be read by the model.
|
AppInterface.list_app_attach |
Retrieves a list of all the files attached to the app.
|
AppInterface.list_app_attach_by_tag |
Retrieves a list of all the files attached to the app with the given tag.
|
AppInterface.list_attach_tags |
Retrieves a list of the attachment tags defined in the companion file.
|
AppInterface.list_scen_attach |
Retrieves a list of all the files attached to a given scenario.
|
AppInterface.list_scen_attach_by_tag |
Retrieves a list of all the files attached to a scenario with the given tag.
|
AppInterface.put_scen_attach |
Uploads a scenario attachment to the Insight server, reading it from the Python working directory.
|
AppInterface.rename_scen_attach |
Renames an existing scenario attachment.
|
AppInterface.reset_progress |
Resets the progress state for each progress metric back to zero.
|
AppInterface.scen_attach_info |
Retrieves information about a given scenario attachment.
|
AppInterface.scenario_id |
Property for the id of the Xpress Insight scenario.
|
AppInterface.scenario_name |
Property for the name of the Xpress Insight scenario.
|
AppInterface.scenario_path |
Property for the path of the Xpress Insight scenario.
|
AppInterface.set_attach_rules |
Sets the 'rules' used to validate attachments and attachment meta-data.
|
AppInterface.set_attach_tags |
Sets the list of tags that can be used in attachments
|
AppInterface.set_scen_attach_desc |
Update the description of an existing scenario attachment.
|
AppInterface.set_scen_attach_hidden |
Mark an existing scenario attachment as hidden or visible in the Xpress Insight UI.
|
AppInterface.set_scen_attach_tags |
Update the tags of an existing scenario attachment.
|
AppInterface.test_app_attach_dir |
Property for the path to use for the attachments directory of the current app, when in test mode.
|
AppInterface.test_attach_dir |
Property for the location to store mock attachments for app and scenario, when in test mode.
|
AppInterface.test_cfile_path |
Property for the location of the app companion file to parse, when in test mode.
|
AppInterface.test_mode |
Read-only property to check whether the Insight application is running in test mode or in Insight.
|
AppInterface.test_scen_attach_dir |
Property for the path to use for the scenario attachments directory of the current scenario.
|
AppInterface.update |
Sends a progress update notification for a single metric from the model to the Xpress Insight system.
|
AppInterface.username |
Property for the username of the Insight user that initiated the current scenario execution.
|
AppInterface.work_dir |
Read-only property for the internal working directory of the xpressinsight package.
|
Metric |
Indicates the type of metric a progress update is providing.
|
ObjSense |
Indicates the direction of optimization.
|
Attachments Classes
Attachment |
An object containing information about a single attachment.
|
AttachmentRules |
A class containing information about the rules used by Insight when verifying attachments.
|
AttachStatus |
Indicates the status of the most recent attempt to access or modify an attachment.
|
AttachTag |
A class containing information about a tag defined in the app's companion file.
|
AttachTagUsage |
Possible values for attachment tag usage.
|