xpressinsight.scenario.InsightRestClient.get_scenario_data
xpressinsight.scenario.InsightRestClient.get_scenario_data(self, scenario_id: str, scenario_data_class: Type[~SCENARIO_DATA_CONTAINER], filters: Optional[Dict[str, Dict[str, Iterable]]] = None) -> ~SCENARIO_DATA_CONTAINER
scenario_id
|
The ID of the scenario from which to read.
|
scenario_data_class
|
A class declared with the
ScenarioData or
AppConfig decorator, describing entities to capture with class attributes with
xi.data. or
xi.types. type hints.
|
filters
|
A dictionary of filters to apply when reading each array. The key of the dictionary is the entity name of the array (which may be different from the attribute name or the column name in the
scenario_data_class), and the value is a dictionary from index set entity name to the allowed values for those sets.
|
An instance of the supplied scenario_data_class, populated with values read from the scenario.
This function may raise the following errors:
>>> @xi.ScenarioData() ... class EntitiesToRead: ... my_integer: xi.data.Scalar(dtype=xi.integer) ... my_string: xi.data.Scalar() ... my_set: xi.data.Index() ... my_array: xi.data.Series() ... my_table: xi.data.DataFrame( ... columns=[ ... xi.data.Column('my_first_column', dtype=xi.real), ... xi.data.Column('my_second_column')]) ... ... with ins.InsightRestClient(insight_url='http://localhost:8080/') as client: ... SCENARIO_ID = '570b9100-46e3-4643-baee-2e24aa538f25' ... scenario_data = client.get_scenario_data(SCENARIO_ID, SCENARIO_ID) ... print(f'my_integer={scenario_data.my_integer}')
>>> @xi.ScenarioData() ... class EntitiesToRead: ... factories: xi.data.DataFrame( ... columns=[ ... xi.data.Column('sales'), ... xi.data.Column('expenses')]) ... ... # Fetch data for factories in Washington for the first 3 months of the year ... with ins.InsightRestClient(insight_url='http://localhost:8080/') as client: ... # Apply a filter to both columns of the data-frame ... factories_filter = { ... 'month': ['january', 'february', 'march'], ... 'state': ['Washington'] ... } ... SCENARIO_ID = '570b9100-46e3-4643-baee-2e24aa538f25' ... scenario_data = client.get_scenario_data(SCENARIO_ID, EntitiesToRead, ... filters={'factories_sales': factories_filter, ... 'factories_expenses': factories_filter}) ... print(scenario_data.factories)
© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.