|
2 | 2 | import sys |
3 | 3 | import time |
4 | 4 |
|
5 | | -from google.protobuf import json_format |
6 | | -from google.protobuf.json_format import MessageToJson |
7 | | -from google.protobuf.json_format import MessageToDict |
8 | | -from fds.protobuf.stach.Package_pb2 import Package |
9 | | - |
10 | | -from fds.analyticsapi.engines.configuration import Configuration |
11 | | -from fds.analyticsapi.engines.api_client import ApiClient |
| 5 | +from fds.analyticsapi.engines import ComponentSummary |
| 6 | +from fds.analyticsapi.engines.api.calculations_api import CalculationsApi |
12 | 7 | from fds.analyticsapi.engines.api.components_api import ComponentsApi |
13 | 8 | from fds.analyticsapi.engines.api.configurations_api import ConfigurationsApi |
14 | | -from fds.analyticsapi.engines.api.calculations_api import CalculationsApi |
15 | 9 | from fds.analyticsapi.engines.api.utility_api import UtilityApi |
| 10 | +from fds.analyticsapi.engines.api_client import ApiClient |
| 11 | +from fds.analyticsapi.engines.configuration import Configuration |
16 | 12 | from fds.analyticsapi.engines.models.calculation import Calculation |
17 | 13 | from fds.analyticsapi.engines.models.pa_calculation_parameters import PACalculationParameters |
18 | | -from fds.analyticsapi.engines.models.pa_identifier import PAIdentifier |
19 | 14 | from fds.analyticsapi.engines.models.pa_date_parameters import PADateParameters |
| 15 | +from fds.analyticsapi.engines.models.pa_identifier import PAIdentifier |
20 | 16 | from fds.analyticsapi.engines.models.spar_calculation_parameters import SPARCalculationParameters |
21 | | -from fds.analyticsapi.engines.models.spar_identifier import SPARIdentifier |
22 | 17 | from fds.analyticsapi.engines.models.spar_date_parameters import SPARDateParameters |
| 18 | +from fds.analyticsapi.engines.models.spar_identifier import SPARIdentifier |
23 | 19 | from fds.analyticsapi.engines.models.vault_calculation_parameters import VaultCalculationParameters |
24 | | -from fds.analyticsapi.engines.models.vault_identifier import VaultIdentifier |
25 | 20 | from fds.analyticsapi.engines.models.vault_date_parameters import VaultDateParameters |
| 21 | +from fds.analyticsapi.engines.models.vault_identifier import VaultIdentifier |
| 22 | +from fds.protobuf.stach.Package_pb2 import Package |
| 23 | + |
| 24 | +from google.protobuf import json_format |
| 25 | +from google.protobuf.json_format import MessageToJson |
| 26 | +from google.protobuf.json_format import MessageToDict |
| 27 | +from urllib3 import Retry |
26 | 28 |
|
27 | 29 | # Copy 'Converting API output to Table Format' snippet to a file with name 'stach_extensions.py' to use below import statement |
28 | 30 | from stach_extensions import StachExtensions |
|
61 | 63 | # config.proxy = "<proxyUrl>" |
62 | 64 | config.verify_ssl = False |
63 | 65 |
|
| 66 | +# Setting configuration to retry api calls on http status codes of 429 and 503. |
| 67 | +config.retries = Retry(total=3, status=3, status_forcelist=frozenset([429, 503]), backoff_factor=2, raise_on_status=False) |
| 68 | + |
64 | 69 | api_client = ApiClient(config) |
65 | 70 |
|
66 | 71 | components_api = ComponentsApi(api_client) |
67 | 72 |
|
68 | 73 | components = components_api.get_pa_components(pa_document_name) |
69 | | -component_id = list((dict(filter(lambda component: (component[1].name == pa_component_name and component[1].category == pa_component_category), components.items()))).keys())[0] |
| 74 | +pa_component_desc = ComponentSummary(name=pa_component_name, category=pa_component_category) |
| 75 | +component_id = [id for id in list(components.keys()) if components[id] == pa_component_desc][0] |
70 | 76 |
|
71 | 77 | pa_account_identifier = PAIdentifier(pa_benchmark_sp_50) |
72 | 78 | pa_accounts = [pa_account_identifier] |
|
77 | 83 | pa_calculation_parameters = {"1": PACalculationParameters(component_id, pa_accounts, pa_benchmarks, pa_dates)} |
78 | 84 |
|
79 | 85 | components = components_api.get_spar_components(spar_document_name) |
80 | | -component_id = list((dict(filter(lambda component: (component[1].name == spar_component_name and component[1].category == spar_component_category), components.items()))).keys())[0] |
| 86 | +spar_component_desc = ComponentSummary(name=spar_component_name, category=spar_component_category) |
| 87 | +component_id = [id for id in list(components.keys()) if components[id] == spar_component_desc][0] |
81 | 88 |
|
82 | 89 | spar_account_identifier = SPARIdentifier(spar_benchmark_r_1000, spar_benchmark_russell_return_type, spar_benchmark_russell_prefix) |
83 | 90 | spar_accounts = [spar_account_identifier] |
|
87 | 94 | spar_calculation_parameters = {"2": SPARCalculationParameters(component_id, spar_accounts, spar_benchmark_identifier, spar_dates)} |
88 | 95 |
|
89 | 96 | components = components_api.get_vault_components(vault_document_name) |
90 | | -component_id = list((dict(filter(lambda component: (component[1].name == vault_component_name and component[1].category == vault_component_category), components.items()))).keys())[0] |
| 97 | +vault_component_desc = ComponentSummary(name=vault_component_name, category=vault_component_category) |
| 98 | +component_id = [id for id in list(components.keys()) if components[id] == vault_component_desc][0] |
91 | 99 |
|
92 | 100 | vault_account_identifier = VaultIdentifier(vault_default_account) |
93 | 101 | vault_dates = VaultDateParameters(vault_startdate, vault_enddate, frequency) |
|
115 | 123 | print("Calculation Id: " + calculation_id) |
116 | 124 |
|
117 | 125 | status_response = calculations_api.get_calculation_status_by_id_with_http_info(calculation_id) |
118 | | -while (status_response[1] == 200 and (status_response[0].status == "Queued" or status_response[0].status == "Executing")): |
| 126 | +while status_response[1] == 200 and (status_response[0].status in ("Queued", "Executing")): |
119 | 127 | max_age = '5' |
120 | 128 | age_value = status_response[2].get("cache-control") |
121 | 129 | if age_value is not None: |
|
0 commit comments