MSTR-Robotics-magerdaniel 0.3.11__tar.gz → 0.3.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12/MSTR_Robotics_magerdaniel.egg-info}/PKG-INFO +3 -2
- {mstr_robotics_magerdaniel-0.3.11/MSTR_Robotics_magerdaniel.egg-info → mstr_robotics_magerdaniel-0.3.12}/PKG-INFO +3 -2
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_connectors.py +6 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_helper.py +13 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/dossier.py +10 -9
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/navigation.py +9 -3
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/prepare_AI_data.py +51 -44
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/read_out_prj_obj.py +270 -95
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/report.py +46 -29
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/user_RAG.py +29 -4
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/setup.py +1 -1
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/LICENSE +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/MANIFEST.in +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/MSTR_Robotics_magerdaniel.egg-info/SOURCES.txt +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/MSTR_Robotics_magerdaniel.egg-info/dependency_links.txt +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/MSTR_Robotics_magerdaniel.egg-info/requires.txt +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/MSTR_Robotics_magerdaniel.egg-info/top_level.txt +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/README.md +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/__init__.py +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_lu_data.py +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_mod_prj_obj.py +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/mstr_classes.py +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/mstr_pandas.py +0 -0
- {mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: MSTR_Robotics_magerdaniel
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.12
|
|
4
4
|
Summary: MicroStrateg(P)ython
|
|
5
5
|
Home-page: https://github.com/magerdaniel
|
|
6
6
|
Author: Daniel Mager
|
|
@@ -24,6 +24,7 @@ Dynamic: classifier
|
|
|
24
24
|
Dynamic: description
|
|
25
25
|
Dynamic: description-content-type
|
|
26
26
|
Dynamic: home-page
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
Dynamic: requires-dist
|
|
28
29
|
Dynamic: requires-python
|
|
29
30
|
Dynamic: summary
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: MSTR_Robotics_magerdaniel
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.12
|
|
4
4
|
Summary: MicroStrateg(P)ython
|
|
5
5
|
Home-page: https://github.com/magerdaniel
|
|
6
6
|
Author: Daniel Mager
|
|
@@ -24,6 +24,7 @@ Dynamic: classifier
|
|
|
24
24
|
Dynamic: description
|
|
25
25
|
Dynamic: description-content-type
|
|
26
26
|
Dynamic: home-page
|
|
27
|
+
Dynamic: license-file
|
|
27
28
|
Dynamic: requires-dist
|
|
28
29
|
Dynamic: requires-python
|
|
29
30
|
Dynamic: summary
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_connectors.py
RENAMED
|
@@ -134,6 +134,12 @@ class mstr_api():
|
|
|
134
134
|
report_def=conn.get(url)
|
|
135
135
|
return report_def.json()
|
|
136
136
|
|
|
137
|
+
def get_cube_all_def(self,conn, cube_id, showExpressionAs="tokens", showFilterTokens="true",
|
|
138
|
+
showAdvancedProperties="true"):
|
|
139
|
+
url = f'{conn.base_url}/api/model/cubes/{cube_id}?showExpressionAs={showExpressionAs}&showFilterTokens={showFilterTokens}&showAdvancedProperties={showAdvancedProperties}'
|
|
140
|
+
cube_all_def_d = conn.get(url).json()
|
|
141
|
+
return cube_all_def_d
|
|
142
|
+
|
|
137
143
|
def get_report_raw(self,conn,report_id,instance_id):
|
|
138
144
|
#normaly I use the report libraries from mstrio
|
|
139
145
|
# to fetch the data. Sometimes they bring back an error. so this one is for trouble
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_helper.py
RENAMED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
class str_func:
|
|
2
2
|
|
|
3
|
+
def web_base_url(self,base_url):
|
|
4
|
+
url_start = base_url.split("/") # Split by backslash
|
|
5
|
+
web_base_url=f'{url_start[0]+"//"+url_start[2]}/MicroStrategy/servlet/mstrWeb?'
|
|
6
|
+
return web_base_url
|
|
7
|
+
|
|
8
|
+
def get_server_base_url(self,base_url):
|
|
9
|
+
url_parts = base_url.split("/")
|
|
10
|
+
server = url_parts[2].split(":")
|
|
11
|
+
return server[0]
|
|
12
|
+
|
|
13
|
+
def get_project_name_base_url(self, project_name):
|
|
14
|
+
return project_name.replace(" ", "+")
|
|
15
|
+
|
|
3
16
|
def rem_braket(self, exp):
|
|
4
17
|
if exp[:1] =="(":
|
|
5
18
|
exp = exp.replace("(", "")
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/dossier.py
RENAMED
|
@@ -106,15 +106,14 @@ class doss_read_out_det():
|
|
|
106
106
|
def run_read_out_doss_hier_det(self, conn, dossier_l):
|
|
107
107
|
self.visual_list = []
|
|
108
108
|
for dossier_id in dossier_l:
|
|
109
|
-
instance_id=i_mstr_api.create_dossier_instance(conn,dossier_id)
|
|
110
|
-
doss_hier = i_mstr_api.get_dossier_def(conn, dossier_id)
|
|
111
|
-
# print(doss_hier)
|
|
112
|
-
self.visual_d = {}
|
|
113
|
-
self.visual_d["dossier_id"] = dossier_id
|
|
114
|
-
self.visual_d["dossier_name"] = doss_hier["name"]
|
|
115
|
-
self.visual_d["error_msg"] = ''
|
|
116
109
|
try:
|
|
117
|
-
|
|
110
|
+
instance_id=i_mstr_api.create_dossier_instance(conn,dossier_id)
|
|
111
|
+
doss_hier = i_mstr_api.get_dossier_def(conn, dossier_id)
|
|
112
|
+
# print(doss_hier)
|
|
113
|
+
self.visual_d = {}
|
|
114
|
+
self.visual_d["dossier_id"] = dossier_id
|
|
115
|
+
self.visual_d["dossier_name"] = doss_hier['name']
|
|
116
|
+
self.visual_d["error_msg"] = ''
|
|
118
117
|
for chapter in doss_hier["chapters"]:
|
|
119
118
|
# print(chapter)
|
|
120
119
|
self.visual_d["chapter_key"] = chapter["key"]
|
|
@@ -122,7 +121,9 @@ class doss_read_out_det():
|
|
|
122
121
|
self.read_pages_hier_det(conn=conn,chapter=chapter, instance_id=instance_id)
|
|
123
122
|
|
|
124
123
|
except Exception as err:
|
|
125
|
-
print(err)
|
|
124
|
+
#print(err)
|
|
125
|
+
self.visual_d["dossier_id"] = dossier_id
|
|
126
|
+
self.visual_d["dossier_name"] = ""
|
|
126
127
|
self.visual_d["chapter_key"] = ""
|
|
127
128
|
self.visual_d["chapter_name"] = ""
|
|
128
129
|
self.visual_d["page_key"] = ""
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/navigation.py
RENAMED
|
@@ -183,19 +183,25 @@ class answer_prompts():
|
|
|
183
183
|
break
|
|
184
184
|
return prp_ans_l
|
|
185
185
|
|
|
186
|
-
def save_AI_rep(self, conn, report_id, prompt_answ, ai_rep_name, ai_rep_folder_id):
|
|
186
|
+
def save_AI_rep(self, conn, report_id, prompt_answ, ai_rep_name, ai_rep_folder_id, promptOption="static"):
|
|
187
187
|
instance_id = i_rep.open_Instance(conn=conn, report_id=report_id)
|
|
188
188
|
first_draft = i_rep.set_inst_prompt_ans(conn=conn, report_id=report_id, instance_id=instance_id,
|
|
189
189
|
prompt_answ=prompt_answ)
|
|
190
190
|
|
|
191
|
+
"""
|
|
191
192
|
rep_stat = i_rep.get_open_prp_stat(conn=conn, report_id=report_id, instance_id=instance_id)
|
|
192
193
|
|
|
194
|
+
|
|
193
195
|
if rep_stat == 2:
|
|
194
|
-
prompt_answ =
|
|
196
|
+
prompt_answ = i_prompts.close_open_prp(conn=conn, report_id=report_id, instance_id=instance_id,
|
|
195
197
|
prompt_answ=prompt_answ)
|
|
198
|
+
|
|
199
|
+
first_draft = i_rep.set_inst_prompt_ans(conn=conn, report_id=report_id, instance_id=instance_id,
|
|
200
|
+
prompt_answ=prompt_answ)
|
|
201
|
+
"""
|
|
196
202
|
rep_id = i_rep.save_rep_inst(conn=conn, instance_id=instance_id, rep_name=ai_rep_name
|
|
197
203
|
, save_mode="OVERWRITE"
|
|
198
|
-
, promptOption=
|
|
204
|
+
, promptOption=promptOption
|
|
199
205
|
, setCurrentAsDefaultAnswer=True)
|
|
200
206
|
|
|
201
207
|
return rep_id
|
|
@@ -14,7 +14,7 @@ i_mstr_global=mstr_global()
|
|
|
14
14
|
i_rep=rep()
|
|
15
15
|
i_mstr_api=mstr_api()
|
|
16
16
|
|
|
17
|
-
class
|
|
17
|
+
class zzz_read_out_cube_att():
|
|
18
18
|
|
|
19
19
|
def trans_cbe_el_prp(self, ele_str):
|
|
20
20
|
|
|
@@ -23,27 +23,6 @@ class read_out_cube_att():
|
|
|
23
23
|
el_ans_d = {"id": ':'.join(el_l[-1 * (len(el_l) - 1):]) + ";" + el_l[0]}
|
|
24
24
|
return el_ans_d
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
def zzz_read_cube_att_elements(self,conn,cube_list_l ):
|
|
28
|
-
key_val_l=[]
|
|
29
|
-
|
|
30
|
-
for cube_id in cube_list_l:
|
|
31
|
-
#print(cube_id["id"])
|
|
32
|
-
cube = OlapCube(connection=conn, id=cube_id["id"])
|
|
33
|
-
att_ell_l=cube.attr_elements
|
|
34
|
-
for att in att_ell_l:
|
|
35
|
-
#print(att["attribute_name"])
|
|
36
|
-
key_val_d={}
|
|
37
|
-
key_val_d["attribute_id"]=att["attribute_id"]
|
|
38
|
-
key_val_d["attribute_name"]=att["attribute_name"]
|
|
39
|
-
for element in att["elements"]:
|
|
40
|
-
#print(element)
|
|
41
|
-
key_val_d["element_ans"]=self.trans_cbe_el_prp(ele_str=element["id"])
|
|
42
|
-
key_val_d["element_val_key"]=element["formValues"][0]
|
|
43
|
-
key_val_l.append(key_val_d.copy())
|
|
44
|
-
|
|
45
|
-
return key_val_l
|
|
46
|
-
|
|
47
26
|
def read_cube_att_forms(self,conn,cube_def, att_name, form_name=None):
|
|
48
27
|
#reads out attorm definitions
|
|
49
28
|
rag_att_form_id_d = {}
|
|
@@ -100,31 +79,59 @@ class read_out_cube_att():
|
|
|
100
79
|
all_cube_element_l.extend(cube_element_l)
|
|
101
80
|
return all_cube_element_l
|
|
102
81
|
|
|
82
|
+
|
|
83
|
+
def zzz_read_cube_att_elements(self,conn,cube_list_l ):
|
|
84
|
+
key_val_l=[]
|
|
85
|
+
|
|
86
|
+
for cube_id in cube_list_l:
|
|
87
|
+
#print(cube_id["id"])
|
|
88
|
+
cube = OlapCube(connection=conn, id=cube_id["id"])
|
|
89
|
+
att_ell_l=cube.attr_elements
|
|
90
|
+
for att in att_ell_l:
|
|
91
|
+
#print(att["attribute_name"])
|
|
92
|
+
key_val_d={}
|
|
93
|
+
key_val_d["attribute_id"]=att["attribute_id"]
|
|
94
|
+
key_val_d["attribute_name"]=att["attribute_name"]
|
|
95
|
+
for element in att["elements"]:
|
|
96
|
+
#print(element)
|
|
97
|
+
key_val_d["element_ans"]=self.trans_cbe_el_prp(ele_str=element["id"])
|
|
98
|
+
key_val_d["element_val_key"]=element["formValues"][0]
|
|
99
|
+
key_val_l.append(key_val_d.copy())
|
|
100
|
+
|
|
101
|
+
return key_val_l
|
|
102
|
+
|
|
103
103
|
class map_objects():
|
|
104
104
|
|
|
105
105
|
def get_doss_rep_prp(self,conn, object_l):
|
|
106
106
|
prp_rep_l = []
|
|
107
|
+
prp_rep_err_l = []
|
|
107
108
|
for rep_dos in object_l:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
109
|
+
try:
|
|
110
|
+
if rep_dos["type"] == 3:
|
|
111
|
+
for prp in i_rep.get_rep_prp_l(conn=conn, report_id=rep_dos["id"]):
|
|
112
|
+
rep_prp_d = {}
|
|
113
|
+
rep_prp_d["project_id"]=conn.project_id
|
|
114
|
+
rep_prp_d["rep_dos_id"] = rep_dos["id"]
|
|
115
|
+
rep_prp_d["type"] = rep_dos["type"]
|
|
116
|
+
rep_prp_d["sub_type"] = rep_dos["sub_type"]
|
|
117
|
+
rep_prp_d["prompt_id"] = prp.id
|
|
118
|
+
prp_rep_l.append(rep_prp_d.copy())
|
|
119
|
+
elif rep_dos["type"] == 55:
|
|
120
|
+
for prp in i_mstr_api.get_dossier_prp_l(conn=conn, dossier_id=rep_dos["id"]):
|
|
121
|
+
rep_prp_d = {}
|
|
122
|
+
rep_prp_d["project_id"]=conn.project_id
|
|
123
|
+
rep_prp_d["rep_dos_id"] = rep_dos["id"]
|
|
124
|
+
rep_prp_d["type"] = rep_dos["type"]
|
|
125
|
+
rep_prp_d["sub_type"] = rep_dos["sub_type"]
|
|
126
|
+
rep_prp_d["prompt_id"] = prp["id"]
|
|
127
|
+
prp_rep_l.append(rep_prp_d.copy())
|
|
128
|
+
|
|
129
|
+
except Exception as e:
|
|
130
|
+
prp_rep_err_d = {"rep_dos_id": rep_dos["id"], "rep_dos_type":rep_dos["type"], "err_msg": str(e)}
|
|
131
|
+
prp_rep_err_l.append(prp_rep_err_d.copy())
|
|
132
|
+
|
|
133
|
+
all_rep_prp_d = {"prp_rep_l": prp_rep_l, "prp_rep_err_l": prp_rep_err_l}
|
|
134
|
+
return all_rep_prp_d
|
|
128
135
|
|
|
129
136
|
def get_RAG_cube_attribute_id(self,conn, cube_l):
|
|
130
137
|
cube_att_l = []
|
|
@@ -138,11 +145,11 @@ class map_objects():
|
|
|
138
145
|
cube_att_l.append(cube_att_d.copy())
|
|
139
146
|
return cube_att_l
|
|
140
147
|
|
|
141
|
-
def bld_ai_prp_ans(self,conn, cube_id, rep_dos_id, key_word_l):
|
|
148
|
+
def bld_ai_prp_ans(self,conn, cube_id, rep_dos_id, key_word_l,key_val_l = ["key"]):
|
|
142
149
|
|
|
143
150
|
disp_col_ids_l = []
|
|
144
151
|
attr_elements_l = []
|
|
145
|
-
|
|
152
|
+
#
|
|
146
153
|
# print(mstr_rag_col_d)
|
|
147
154
|
mstr_rag_col_d=i_cube.get_mtdi_cube_col_id(conn, cube_l=[cube_id])
|
|
148
155
|
for col_name in mstr_rag_col_d[cube_id].keys():
|
|
@@ -188,70 +188,75 @@ class io_attributes():
|
|
|
188
188
|
def read_att_form_exp(self,conn,att_id_l,*args,**kwargs):
|
|
189
189
|
all_att_maps_d = self.run_prop_d.copy()
|
|
190
190
|
all_att_maps_l = []
|
|
191
|
-
|
|
191
|
+
all_att_err_l = []
|
|
192
192
|
for att_id in att_id_l:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
else:
|
|
215
|
-
all_att_maps_d["key_form"]=False
|
|
216
|
-
|
|
217
|
-
all_att_maps_d["display_form_nr"]=0
|
|
218
|
-
display_form_nr=1
|
|
219
|
-
for rd_form in att["displays"]["reportDisplays"]:
|
|
220
|
-
if form["id"] == rd_form["id"]:
|
|
221
|
-
all_att_maps_d["display_form_nr"]=display_form_nr
|
|
222
|
-
else:
|
|
223
|
-
display_form_nr+=1
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
all_att_maps_d["browse_form_nr"] = 0
|
|
227
|
-
browse_form_nr = 1
|
|
228
|
-
for bd_form in att["displays"]["browseDisplays"]:
|
|
229
|
-
if form["id"] == bd_form["id"]:
|
|
230
|
-
all_att_maps_d["browse_form_nr"] = browse_form_nr
|
|
193
|
+
try:
|
|
194
|
+
att=self.i_read_att(connection=conn,id=att_id,show_expression_as="tokens").json()
|
|
195
|
+
key_form_l = self.get_att_key_form_l(att)
|
|
196
|
+
for form in att["forms"]:
|
|
197
|
+
if "isFormGroup" not in list(form.keys()):
|
|
198
|
+
all_att_maps_d["project_id"] = conn.headers["X-MSTR-ProjectID"]
|
|
199
|
+
all_att_maps_d["attribute_id"] = att_id
|
|
200
|
+
all_att_maps_d["attribute_name"] =att["name"]
|
|
201
|
+
all_att_maps_d["form_id"] = form["id"]
|
|
202
|
+
all_att_maps_d["form_name"] = form["name"]
|
|
203
|
+
#all_att_maps_d["description"] = form["description"]
|
|
204
|
+
all_att_maps_d["form_category"] = form["category"]
|
|
205
|
+
all_att_maps_d["form_type"] = form["type"]
|
|
206
|
+
all_att_maps_d["displayFormat"] = form["displayFormat"]
|
|
207
|
+
all_att_maps_d["form_dataType"] = form["dataType"]["type"]
|
|
208
|
+
all_att_maps_d["REST_form_type"] = i_prompts.get_exp_prp_data_type(baseFormType=form["dataType"]["type"])
|
|
209
|
+
all_att_maps_d["form_precision"] = form["dataType"]["precision"]
|
|
210
|
+
all_att_maps_d["form_scale"] = form["dataType"]["scale"]
|
|
211
|
+
|
|
212
|
+
if form["id"] in key_form_l:
|
|
213
|
+
all_att_maps_d["key_form"]=True
|
|
231
214
|
else:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
215
|
+
all_att_maps_d["key_form"]=False
|
|
216
|
+
|
|
217
|
+
all_att_maps_d["display_form_nr"]=0
|
|
218
|
+
display_form_nr=1
|
|
219
|
+
for rd_form in att["displays"]["reportDisplays"]:
|
|
220
|
+
if form["id"] == rd_form["id"]:
|
|
221
|
+
all_att_maps_d["display_form_nr"]=display_form_nr
|
|
222
|
+
else:
|
|
223
|
+
display_form_nr+=1
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
all_att_maps_d["browse_form_nr"] = 0
|
|
227
|
+
browse_form_nr = 1
|
|
228
|
+
for bd_form in att["displays"]["browseDisplays"]:
|
|
229
|
+
if form["id"] == bd_form["id"]:
|
|
230
|
+
all_att_maps_d["browse_form_nr"] = browse_form_nr
|
|
231
|
+
else:
|
|
232
|
+
browse_form_nr += 1
|
|
233
|
+
|
|
234
|
+
for e in form["expressions"]:
|
|
235
|
+
# print(e)
|
|
236
|
+
all_att_maps_d["form_expressionId"] = e["expressionId"]
|
|
237
|
+
all_att_maps_d["form_expressionText"] = e["expression"]["text"]
|
|
238
|
+
# all_att_maps_d["expression_text"]=e["expression"]["text"]
|
|
239
|
+
for tok in e["expression"]["tokens"]:
|
|
240
|
+
if "target" in list(tok.keys()):
|
|
241
|
+
if "column" == tok["target"]["subType"]:
|
|
242
|
+
all_att_maps_d["exp_value"] = tok["value"]
|
|
243
|
+
all_att_maps_d["column_id"] = tok["target"]["objectId"]
|
|
244
|
+
all_att_maps_d["column_name"] = tok["target"]["name"]
|
|
245
|
+
all_att_maps_d["column_versionId"] = tok["target"]["versionId"]
|
|
246
|
+
all_att_maps_d["column_dateCreated"] = tok["target"]["dateCreated"]
|
|
247
|
+
all_att_maps_d["column_dateModified"] = tok["target"]["dateModified"]
|
|
252
248
|
all_att_maps_l.append(all_att_maps_d.copy())
|
|
249
|
+
for table in e["tables"]:
|
|
250
|
+
all_att_maps_d["table_id"] = table["objectId"]
|
|
251
|
+
all_att_maps_d["table_subType"] = table["subType"]
|
|
252
|
+
all_att_maps_l.append(all_att_maps_d.copy())
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
except Exception as e:
|
|
255
|
+
all_att_err_d={"attribute_id":att_id , "err_msg":str(e)}
|
|
256
|
+
all_att_err_l.append(all_att_err_d.copy())
|
|
257
|
+
|
|
258
|
+
all_att_d={"all_att_maps_l":all_att_maps_l,"all_att_err_l":all_att_err_l}
|
|
259
|
+
return all_att_d
|
|
255
260
|
|
|
256
261
|
def get_att_key_form_l(self,att):
|
|
257
262
|
key_form_l = []
|
|
@@ -287,7 +292,7 @@ class read_schema():
|
|
|
287
292
|
fact_l=i_md_searches.search_for_type_l(conn,obj_l=["13"] )
|
|
288
293
|
fact_id_l=i_msic.get_key_form_dict_l(dict_l=fact_l)
|
|
289
294
|
|
|
290
|
-
att_form_exp_l=self.io_attributes.read_att_form_exp(conn=conn,att_id_l=att_id_l)
|
|
295
|
+
att_form_exp_l=self.io_attributes.read_att_form_exp(conn=conn,att_id_l=att_id_l)["all_att_maps_l"]
|
|
291
296
|
att_form_exp_df=pd.DataFrame.from_dict(att_form_exp_l)
|
|
292
297
|
|
|
293
298
|
fact_exp_l=self.io_facts.read_fact_exp(conn=conn,fact_id_l=fact_id_l)
|
|
@@ -323,7 +328,7 @@ class read_gen():
|
|
|
323
328
|
|
|
324
329
|
def get_obj_def(self,conn, object_id, obj_type=None, obj_sub_type=None):
|
|
325
330
|
obj_def = {}
|
|
326
|
-
print(obj_type)
|
|
331
|
+
#print(obj_type)
|
|
327
332
|
if str(obj_type) == "12":
|
|
328
333
|
|
|
329
334
|
obj_def = attributes.get_attribute(connection=conn, id=object_id, show_expression_as="tokens").json()
|
|
@@ -454,11 +459,17 @@ class read_prompts():
|
|
|
454
459
|
self.prompt_obj_l.append(p_obj_row_d.copy())
|
|
455
460
|
|
|
456
461
|
else:
|
|
457
|
-
#
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
#print(prompt_def_d)
|
|
463
|
+
if ("expressionType" in prompt_def_d.keys() and
|
|
464
|
+
prompt_def_d["expressionType"]=="hierarchy" and
|
|
465
|
+
prompt_def_d["question"]["listAllHierarchies"]==True):
|
|
466
|
+
print("allHierPrompt")
|
|
467
|
+
else:
|
|
468
|
+
|
|
469
|
+
p_obj_row_d["object_id"] = prompt_def_d["question"]["search"]["objectId"]
|
|
470
|
+
p_obj_row_d["prp_subType"] = prompt_def_d["question"]["search"]["subType"]
|
|
471
|
+
self.prompt_obj_l.append(p_obj_row_d.copy())
|
|
472
|
+
self.prp_search_obj_l.append({"id": p_obj_row_d["prompt_id"], "type": 10}.copy())
|
|
462
473
|
|
|
463
474
|
def _add_att_to_obj_l(self,conn,p_row_d):
|
|
464
475
|
p_obj_row_d={}
|
|
@@ -632,8 +643,6 @@ class read_report():
|
|
|
632
643
|
obj_d["form_name"] = ""
|
|
633
644
|
return obj_d
|
|
634
645
|
|
|
635
|
-
|
|
636
|
-
|
|
637
646
|
def read_grid_attribute(self,conn, obj, row_col_fg, row_col_nr):
|
|
638
647
|
att_l=[]
|
|
639
648
|
att_d = self.run_prop_d.copy()
|
|
@@ -764,18 +773,24 @@ class read_report():
|
|
|
764
773
|
rep_def=i_rep.get_report_all_def(conn=conn,report_id=report_id,show_advanced_properties=show_advanced_properties)
|
|
765
774
|
filter_text=""
|
|
766
775
|
report_limit_text=""
|
|
767
|
-
|
|
768
|
-
filter_text=str(rep_def["
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
if "dataTemplate" in rep_def["dataSource"].keys():
|
|
772
|
-
for u in rep_def["dataSource"]["dataTemplate"]['units']:
|
|
773
|
-
if u["type"]=="metrics":
|
|
774
|
-
try:
|
|
775
|
-
report_limit_text=str(u["limit"]["text"])
|
|
776
|
-
except:
|
|
777
|
-
pass
|
|
776
|
+
if "errors" in rep_def.keys():
|
|
777
|
+
filter_text=str(rep_def["errors"])
|
|
778
|
+
else:
|
|
779
|
+
try:
|
|
778
780
|
|
|
781
|
+
filter_text=str(rep_def["dataSource"]["filter"]["text"])
|
|
782
|
+
except:
|
|
783
|
+
pass
|
|
784
|
+
if "dataTemplate" in rep_def["dataSource"].keys():
|
|
785
|
+
if "units" in rep_def["dataSource"]["dataTemplate"].keys():
|
|
786
|
+
for u in rep_def["dataSource"]["dataTemplate"]['units']:
|
|
787
|
+
if u["type"]=="metrics":
|
|
788
|
+
try:
|
|
789
|
+
report_limit_text=str(u["limit"]["text"])
|
|
790
|
+
except:
|
|
791
|
+
pass
|
|
792
|
+
else:
|
|
793
|
+
filter_text=str(str(rep_def["dataSource"]["dataTemplate"]))
|
|
779
794
|
rep_head_d=i_mstr_global.get_object_info_d(conn=conn,object_id=report_id,type="3")
|
|
780
795
|
#rep_head_d.rename(columns={'id': 'report_id'}, inplace=True)
|
|
781
796
|
rep_head_d.pop("project_id")
|
|
@@ -791,24 +806,33 @@ class read_report():
|
|
|
791
806
|
rep_head_l=[]
|
|
792
807
|
rep_avail_obj_l=[]
|
|
793
808
|
rep_grid_obj_l=[]
|
|
809
|
+
rep_def_err_l=[]
|
|
794
810
|
for report_id in report_id_l:
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
811
|
+
try:
|
|
812
|
+
load_d["project_id"]=conn.project_id
|
|
813
|
+
load_d["report_id"]=report_id
|
|
814
|
+
self.run_prop_d=load_d.copy()
|
|
815
|
+
rep_def=i_rep.get_report_def(conn=conn,report_id=report_id).json()
|
|
816
|
+
grid_obj_d=self.read_out_grid(conn=conn,grid_definition=rep_def["definition"]["grid"])
|
|
817
|
+
pageBy_obj_d=self.read_grid_pageBy(conn=conn,pageBy_l=rep_def["definition"]["grid"]["pageBy"])
|
|
818
|
+
avail_obj_d=self.read_avail_obj(conn=conn,avail_obj=rep_def["definition"]["availableObjects"])
|
|
819
|
+
|
|
820
|
+
rep_grid_obj_l.extend(grid_obj_d)
|
|
821
|
+
rep_grid_obj_l.extend(pageBy_obj_d)
|
|
822
|
+
rep_avail_obj_l.extend(avail_obj_d)
|
|
823
|
+
rep_head_d=self.read_rep_quick_filt(conn=conn,report_id=report_id,show_advanced_properties="false")
|
|
824
|
+
rep_head_l.append(rep_head_d)
|
|
825
|
+
|
|
826
|
+
except Exception as e:
|
|
827
|
+
rep_def_err_d = {"load_d": load_d, "rep_def":rep_def,"grid_obj_d":grid_obj_d,
|
|
828
|
+
"pageBy_obj_d":pageBy_obj_d,"avail_obj_d":avail_obj_d,
|
|
829
|
+
"err_msg": str(e)}
|
|
830
|
+
rep_def_err_l.append(rep_def_err_d.copy())
|
|
808
831
|
|
|
809
832
|
rep_def_df= self.bld_rep_def_df(rep_head_l,rep_grid_obj_l=rep_grid_obj_l,rep_avail_obj_l=rep_avail_obj_l)
|
|
810
833
|
|
|
811
|
-
|
|
834
|
+
rep_def_d={"rep_def_df":rep_def_df,"rep_def_err_l":rep_def_err_l}
|
|
835
|
+
return rep_def_d
|
|
812
836
|
|
|
813
837
|
def bld_rep_def_df(self,rep_head_l, rep_grid_obj_l, rep_avail_obj_l):
|
|
814
838
|
|
|
@@ -839,4 +863,155 @@ class read_report():
|
|
|
839
863
|
left_on=['project_id', 'report_id', 'object_id', 'form_id'],
|
|
840
864
|
right_on=['project_id', 'report_id', 'object_id', 'form_id'], how='left')
|
|
841
865
|
rep_def_df = i_df_helper.clean_double_col(df=rep_def_df)
|
|
842
|
-
return rep_def_df
|
|
866
|
+
return rep_def_df
|
|
867
|
+
|
|
868
|
+
class read_cube():
|
|
869
|
+
|
|
870
|
+
def read_cube_model_header(self,conn, cube_id, cube_head_d=None):
|
|
871
|
+
cube_all_def_d = i_mstr_api.get_cube_all_def(conn=conn, cube_id=cube_id,)
|
|
872
|
+
cbe_all_info = cube_all_def_d["information"]
|
|
873
|
+
cbe_opt = cube_all_def_d["options"]
|
|
874
|
+
cbe_sourceType = cube_all_def_d["sourceType"]
|
|
875
|
+
cbe_timeBased = cube_all_def_d["timeBased"]
|
|
876
|
+
cbe_filt = cube_all_def_d["filter"]
|
|
877
|
+
|
|
878
|
+
# cbe_def=cubes.cube_definition(connection= conn, id= cube_id).json()
|
|
879
|
+
|
|
880
|
+
if cube_head_d == None:
|
|
881
|
+
cube_head_d = {}
|
|
882
|
+
cube_head_d["project_id"] = conn.project_id
|
|
883
|
+
cube_head_d["cube_id"] = cbe_all_info["id"]
|
|
884
|
+
|
|
885
|
+
cube_head_d["cube_name"] = cbe_all_info["name"]
|
|
886
|
+
cube_head_d["primaryLocale"] = cbe_all_info["primaryLocale"]
|
|
887
|
+
cube_head_d["subType"] = cbe_all_info["subType"]
|
|
888
|
+
cube_head_d["create_date"] = cbe_all_info["dateCreated"]
|
|
889
|
+
cube_head_d["mod_date"] = cbe_all_info["dateModified"]
|
|
890
|
+
cube_head_d["language_d"] = str(cbe_opt["dataLanguages"])
|
|
891
|
+
cube_head_d["refresch_type"] = str(cbe_opt["dataRefresh"])
|
|
892
|
+
cube_head_d["paration_by_d"] = str(cbe_opt["dataPartition"]["partitionAttribute"])
|
|
893
|
+
cube_head_d["number_of_partions"] = str(cbe_opt["dataPartition"]["numberOfPartitions"])
|
|
894
|
+
cube_head_d["fetch_parallel"] = str(cbe_opt["dataPartition"]["fetchDataSlicesInParallel"])
|
|
895
|
+
cube_head_d["source_type"] = str(cbe_sourceType)
|
|
896
|
+
cube_head_d["timezone"] = cbe_timeBased["timezone"]
|
|
897
|
+
cube_head_d["calendar"] = cbe_timeBased["calendar"]
|
|
898
|
+
cube_head_d["enableTimezoneAndCalendarReporting"] = cbe_timeBased["enableTimezoneAndCalendarReporting"]
|
|
899
|
+
if "text" in cbe_filt.keys():
|
|
900
|
+
cube_head_d["filter_text"] = cbe_filt["text"]
|
|
901
|
+
else:
|
|
902
|
+
cube_head_d["filter_text"] = ""
|
|
903
|
+
return cube_head_d
|
|
904
|
+
|
|
905
|
+
def read_cube_load_info(self,conn, cube_id):
|
|
906
|
+
cbe_head_d = cubes.cube_info(connection=conn, id=cube_id).json()["cubesInfos"][0]
|
|
907
|
+
# print(cbe_head_d.keys())
|
|
908
|
+
cube_head_d = {}
|
|
909
|
+
cube_head_d["project_id"] = conn.project_id
|
|
910
|
+
cube_head_d["cube_id"] = cbe_head_d["cubeId"]
|
|
911
|
+
cube_head_d["cube_name"] = cbe_head_d["cubeName"]
|
|
912
|
+
cube_head_d["path"] = cbe_head_d["path"]
|
|
913
|
+
cube_head_d["modificationTime"] = cbe_head_d["modificationTime"]
|
|
914
|
+
cube_head_d["server_mode"] = cbe_head_d["serverMode"]
|
|
915
|
+
cube_head_d["cube_size"] = cbe_head_d["size"]
|
|
916
|
+
cube_head_d["cube_status"] = cbe_head_d["status"]
|
|
917
|
+
return cube_head_d
|
|
918
|
+
|
|
919
|
+
def read_cube(self,conn, cube_id):
|
|
920
|
+
cube_head_d = self.read_cube_load_info(conn, cube_id)
|
|
921
|
+
cube_head_d = self.read_cube_model_header(conn, cube_id, cube_head_d)
|
|
922
|
+
cube_def = cubes.cube_definition(connection=conn, id=cube_id).json()
|
|
923
|
+
cube_att_d = self.read_cube_att_forms(conn, cube_def)
|
|
924
|
+
cube_met_d = self.read_cube_metrics(conn, cube_def)
|
|
925
|
+
cube_d = {"cube_head_d": cube_head_d, "cube_att_d": cube_att_d, "cube_met_d": cube_met_d}
|
|
926
|
+
return cube_d
|
|
927
|
+
|
|
928
|
+
# ['information', 'template', 'filter', 'options', 'timeBased', 'sourceType', 'advancedProperties']
|
|
929
|
+
|
|
930
|
+
def read_all_olap_cubes(self,conn, cube_l):
|
|
931
|
+
|
|
932
|
+
cube_head_d_l = []
|
|
933
|
+
cube_att_d_l = []
|
|
934
|
+
cube_met_d_l = []
|
|
935
|
+
for cube_id in cube_l:
|
|
936
|
+
cube_d = self.read_cube(conn=conn, cube_id=cube_id)
|
|
937
|
+
cube_head_d_l.append(cube_d["cube_head_d"])
|
|
938
|
+
cube_att_d_l.extend(cube_d["cube_att_d"])
|
|
939
|
+
cube_met_d_l.extend(cube_d["cube_met_d"])
|
|
940
|
+
cube_l_d = {"cube_head_d_l": cube_head_d_l, "cube_att_d_l": cube_att_d_l, "cube_met_d_l": cube_met_d_l}
|
|
941
|
+
return cube_l_d
|
|
942
|
+
|
|
943
|
+
def trans_cbe_el_prp(self, ele_str):
|
|
944
|
+
|
|
945
|
+
el_l = ele_str.split(":")
|
|
946
|
+
el_ans_str = "h" + ':'.join(el_l[-1 * (len(el_l) - 1):])
|
|
947
|
+
el_ans_d = {"id": ':'.join(el_l[-1 * (len(el_l) - 1):]) + ";" + el_l[0]}
|
|
948
|
+
return el_ans_d
|
|
949
|
+
|
|
950
|
+
def read_cube_att_forms(self,conn,cube_def):
|
|
951
|
+
#reads out attorm definitions
|
|
952
|
+
rag_att_form_d_l=[]
|
|
953
|
+
for att in cube_def["definition"]["availableObjects"]["attributes"]:
|
|
954
|
+
for form in att["forms"]:
|
|
955
|
+
#print(att)
|
|
956
|
+
#print(form)
|
|
957
|
+
rag_att_form_d = {}
|
|
958
|
+
rag_att_form_d["project_id"] = conn.project_id
|
|
959
|
+
rag_att_form_d["cube_id"] = cube_def["id"]
|
|
960
|
+
rag_att_form_d["attribute_id"] = att["id"]
|
|
961
|
+
rag_att_form_d["attribute_name"] = att["name"]
|
|
962
|
+
rag_att_form_d["form_id"] = form["id"]
|
|
963
|
+
rag_att_form_d["form_name"] = form["name"]
|
|
964
|
+
if "dataType" in form.keys():
|
|
965
|
+
rag_att_form_d["form_dataType"] = i_prompts.get_exp_prp_data_type(form["dataType"])
|
|
966
|
+
else:
|
|
967
|
+
rag_att_form_d["form_dataType"] = i_prompts.get_exp_prp_data_type(form["baseFormType"])
|
|
968
|
+
rag_att_form_d_l.append(rag_att_form_d.copy())
|
|
969
|
+
|
|
970
|
+
return rag_att_form_d_l
|
|
971
|
+
|
|
972
|
+
def read_cube_metrics(self,conn, cube_def):
|
|
973
|
+
metric_def_d_l=[]
|
|
974
|
+
for m in cube_def["definition"]["availableObjects"]["metrics"]:
|
|
975
|
+
m_def_d={}
|
|
976
|
+
m_def_d["project_id"] = conn.project_id
|
|
977
|
+
m_def_d["cube_id"] = cube_def["id"]
|
|
978
|
+
m_def_d["metric_id"]=m["id"]
|
|
979
|
+
m_def_d["metric_name"] = m["name"]
|
|
980
|
+
m_def_d["metric_data_type"] = m["dataType"]
|
|
981
|
+
metric_def_d_l.append(m_def_d.copy())
|
|
982
|
+
return metric_def_d_l
|
|
983
|
+
|
|
984
|
+
def fetch_cube_elements(self, conn, cube_id,limit_val=10000,*args,**kwargs):
|
|
985
|
+
rag_att_form_l = []
|
|
986
|
+
offset_val = 0
|
|
987
|
+
row_count = 1
|
|
988
|
+
while row_count > 0:
|
|
989
|
+
resp=i_mstr_api.get_v2_cube_instance(conn=conn, cube_id=cube_id, offset_val=offset_val,limit_val=limit_val,*args,**kwargs)
|
|
990
|
+
#url = f'{conn.base_url}/api/v2/cubes/{cube_id}/instances?offset={offset_val}&limit={limit_val}'
|
|
991
|
+
#resp = conn.post(url)
|
|
992
|
+
cube_def= resp.json()
|
|
993
|
+
for att in cube_def["definition"]["grid"]["rows"]:
|
|
994
|
+
form_nr = 0
|
|
995
|
+
rag_att_form_d = {}
|
|
996
|
+
rag_att_form_d["project_id"] = conn.project_id
|
|
997
|
+
rag_att_form_d["attribute_id"] = att["id"]
|
|
998
|
+
rag_att_form_d["attribute_name"] = att["name"]
|
|
999
|
+
row_count = len(att["elements"])
|
|
1000
|
+
for form in att["forms"]:
|
|
1001
|
+
rag_att_form_d["form_id"] = form["id"]
|
|
1002
|
+
rag_att_form_d["form_name"] = form["name"]
|
|
1003
|
+
rag_att_form_d["form_dataType"] = i_prompts.get_exp_prp_data_type(form["dataType"])
|
|
1004
|
+
for element in att["elements"]:
|
|
1005
|
+
rag_att_form_d["key"] = element["formValues"][form_nr]
|
|
1006
|
+
rag_att_form_d["ele_prp_ans"] = element["id"]
|
|
1007
|
+
rag_att_form_l.append(rag_att_form_d.copy())
|
|
1008
|
+
offset_val += limit_val
|
|
1009
|
+
resp.close()
|
|
1010
|
+
return rag_att_form_l
|
|
1011
|
+
|
|
1012
|
+
def read_cube_att_form_exp_val_l(self, conn, cube_list_l,*args,**kwargs):
|
|
1013
|
+
all_cube_element_l=[]
|
|
1014
|
+
for cube in cube_list_l:
|
|
1015
|
+
cube_element_l=self.fetch_cube_elements(conn=conn,cube_id=cube["id"],*args,**kwargs)
|
|
1016
|
+
all_cube_element_l.extend(cube_element_l)
|
|
1017
|
+
return all_cube_element_l
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/report.py
RENAMED
|
@@ -8,11 +8,12 @@ from mstrio.project_objects.report import Report
|
|
|
8
8
|
from mstrio.api.cubes import cube_definition
|
|
9
9
|
import pandas as pd
|
|
10
10
|
from mstr_robotics.mstr_pandas import df_helper
|
|
11
|
-
from mstr_robotics._helper import msic
|
|
11
|
+
from mstr_robotics._helper import msic,str_func
|
|
12
12
|
import json
|
|
13
13
|
|
|
14
14
|
i_mstr_api=mstr_api()
|
|
15
15
|
i_msic=msic()
|
|
16
|
+
i_str_func=str_func()
|
|
16
17
|
|
|
17
18
|
class rep:
|
|
18
19
|
|
|
@@ -21,6 +22,7 @@ class rep:
|
|
|
21
22
|
self.i_parser = parser
|
|
22
23
|
self.i_df_helper=df_helper()
|
|
23
24
|
|
|
25
|
+
|
|
24
26
|
def open_Instance(self, conn, report_id):
|
|
25
27
|
rep_instance = self.i_reports.report_instance(connection=conn, report_id=report_id)
|
|
26
28
|
return rep_instance.json()["instanceId"]
|
|
@@ -139,6 +141,16 @@ class rep:
|
|
|
139
141
|
html_link = f'<a href={rep_url} target="_blank">Jump to MSTR Library</a>'
|
|
140
142
|
return html_link
|
|
141
143
|
|
|
144
|
+
def web_base_url(self,conn, report_id):
|
|
145
|
+
web_base_url=i_str_func.web_base_url(base_url=conn.base_url)
|
|
146
|
+
server=i_str_func.get_server_base_url(base_url=conn.base_url)
|
|
147
|
+
project_name=i_str_func.get_project_name_base_url(project_name=conn.project_name)
|
|
148
|
+
rep_url=f'{web_base_url}Server={server}&Project={project_name}&evt=4001&src=mstrWeb.4001&reportViewMode=1&reportID={report_id}¤tViewMedia=2'
|
|
149
|
+
print(rep_url)
|
|
150
|
+
#rep_url = f'{conn.base_url}/app/{conn.project_id}/{report_id}/share'
|
|
151
|
+
html_link = f'<a href={rep_url} target="_blank">Jump to MSTR Web</a>'
|
|
152
|
+
return html_link
|
|
153
|
+
|
|
142
154
|
def bld_free_form_rep_df(self,conn, report_id,prp_answ_d=None):
|
|
143
155
|
#historically needed to adjust column names
|
|
144
156
|
#can probally be deleted
|
|
@@ -333,13 +345,13 @@ class prompts():
|
|
|
333
345
|
if baseFormType in ["fixed_length_string","n_var_char","Char","varChar"]:
|
|
334
346
|
exp_prp_data_type="Char"
|
|
335
347
|
|
|
336
|
-
if baseFormType in ["integer","double","numeric","decimal","int64","float"]:
|
|
348
|
+
if baseFormType in ["integer","double","numeric","number","decimal","int64","float"]:
|
|
337
349
|
exp_prp_data_type="Numeric"
|
|
338
350
|
|
|
339
351
|
if baseFormType in ["big_decimal","bigDecimal"]:
|
|
340
352
|
exp_prp_data_type="BigDecimal"
|
|
341
353
|
|
|
342
|
-
if baseFormType in ["time_stamp","date"]:
|
|
354
|
+
if baseFormType in ["time_stamp","date","dateTime","timeStamp"]:
|
|
343
355
|
exp_prp_data_type="DateTime"
|
|
344
356
|
|
|
345
357
|
if exp_prp_data_type == "":
|
|
@@ -374,32 +386,37 @@ class prompts():
|
|
|
374
386
|
|
|
375
387
|
def close_open_prp(self,conn, report_id, instance_id, prompt_answ):
|
|
376
388
|
# checks the answered prp
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
open_prp_d["
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
389
|
+
rep_stat = rep().get_open_prp_stat(conn=conn, report_id=report_id, instance_id=instance_id)
|
|
390
|
+
|
|
391
|
+
if rep_stat == 2:
|
|
392
|
+
prompt_answ_d = json.loads(prompt_answ)
|
|
393
|
+
prp_ans_d_l = prompt_answ_d["prompts"]
|
|
394
|
+
prp_ans_id_l = i_msic.keep_cols_from_dict_l(list_l=prp_ans_d_l, keep_cols=["id"])
|
|
395
|
+
|
|
396
|
+
# checks the all prp in report / dashboard
|
|
397
|
+
rep_open_prp_d_l = rep().get_open_prompts(conn=conn, report_id=report_id, instance_id=instance_id)
|
|
398
|
+
rep_open_prp_id_l = i_msic.keep_cols_from_dict_l(list_l=rep_open_prp_d_l, keep_cols=["id"])
|
|
399
|
+
|
|
400
|
+
# checks the prp not answered jet
|
|
401
|
+
open_prp_l = [x for x in rep_open_prp_id_l if x not in prp_ans_id_l]
|
|
402
|
+
open_prp_l = i_msic.get_vals_from_dict_l(dict_l=open_prp_l)
|
|
403
|
+
|
|
404
|
+
for prp in rep_open_prp_d_l:
|
|
405
|
+
print(prp["id"])
|
|
406
|
+
if prp["id"] in open_prp_l:
|
|
407
|
+
print(prp)
|
|
408
|
+
open_prp_d = {}
|
|
409
|
+
open_prp_d["id"] = prp["id"]
|
|
410
|
+
open_prp_d["type"] = prp["type"]
|
|
411
|
+
if prp["type"] in ["OBJECTS", "ELEMENTS"]:
|
|
412
|
+
open_prp_d["answers"] = []
|
|
413
|
+
else:
|
|
414
|
+
open_prp_d["answers"] = {}
|
|
415
|
+
rep_open_prp_d_l.append(open_prp_d.copy())
|
|
416
|
+
prompt_answ = self.frame_prp(prp_ans=rep_open_prp_d_l)
|
|
417
|
+
rep().set_inst_prompt_ans(conn=conn, report_id=report_id, instance_id=instance_id,
|
|
418
|
+
prompt_answ=prompt_answ)
|
|
419
|
+
return
|
|
403
420
|
|
|
404
421
|
def zzz_loop_att_exp_prp(self,prp_job_ans_l):
|
|
405
422
|
expr_JSON_l = []
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/user_RAG.py
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import ast
|
|
2
3
|
from openai import OpenAI
|
|
3
4
|
from flashtext import KeywordProcessor
|
|
4
5
|
from langchain.vectorstores import FAISS
|
|
@@ -19,9 +20,15 @@ class keyword_processor():
|
|
|
19
20
|
return keywords_l
|
|
20
21
|
|
|
21
22
|
def check_keyword(self,filt_obj_str):
|
|
23
|
+
print(filt_obj_str)
|
|
22
24
|
keywords_l = self.KeywordProcessor.extract_keywords(filt_obj_str)
|
|
23
25
|
return keywords_l[0]
|
|
24
26
|
|
|
27
|
+
def check_keyword_all(self,filt_obj_str):
|
|
28
|
+
print(filt_obj_str)
|
|
29
|
+
keywords_l = self.KeywordProcessor.extract_keywords(filt_obj_str)
|
|
30
|
+
return keywords_l
|
|
31
|
+
|
|
25
32
|
class vectorDB_faisst():
|
|
26
33
|
|
|
27
34
|
def __init__(self,sKey):
|
|
@@ -41,9 +48,10 @@ class vectorDB_faisst():
|
|
|
41
48
|
|
|
42
49
|
class mstr_openAI():
|
|
43
50
|
|
|
44
|
-
def __init__(self
|
|
51
|
+
def __init__(self):
|
|
52
|
+
pass
|
|
45
53
|
#self.sKey=sKey
|
|
46
|
-
self.i_embeddings = OpenAIEmbeddings(openai_api_key=sKey)
|
|
54
|
+
#self.i_embeddings = OpenAIEmbeddings(openai_api_key=sKey)
|
|
47
55
|
|
|
48
56
|
|
|
49
57
|
def check_trans_chatGPT(self,sKey,messages,*args,**kwargs):
|
|
@@ -54,7 +62,6 @@ class mstr_openAI():
|
|
|
54
62
|
def call_open_AI(self, sKey, messages, max_tokens=1000, temperature=0.3, model="gpt-4o-mini"):
|
|
55
63
|
# This is the default and can be omitted
|
|
56
64
|
client = OpenAI(api_key=sKey)
|
|
57
|
-
|
|
58
65
|
chat_completion = client.chat.completions.create(
|
|
59
66
|
messages=messages,
|
|
60
67
|
# model="gpt-3.5-turbo",
|
|
@@ -65,8 +72,26 @@ class mstr_openAI():
|
|
|
65
72
|
js = json.loads(chat_completion.json())
|
|
66
73
|
return js
|
|
67
74
|
|
|
68
|
-
class
|
|
75
|
+
class chat_bot():
|
|
76
|
+
|
|
77
|
+
def run_chat_msg(self,msg_t,sKey,model,vector_store,max_tokens,temperature):
|
|
78
|
+
key_word_l = vector_store.check_keyword_all( filt_obj_str=msg_t)
|
|
79
|
+
rag_rep_prp_l = []
|
|
80
|
+
|
|
81
|
+
# rag_rep_prp_filt_d=get_rag_rep_prp_d(conn=conn,cube_id=cube_RAG_form_val_ans_id, mstr_rag_col_d=mstr_rag_col_d,rep_dos_id=rep_dos_id,key_word_l=key_word_l)
|
|
82
|
+
|
|
83
|
+
messages = self.split_AI_msg(msg_t, key_word_l)
|
|
69
84
|
|
|
85
|
+
json_t = mstr_openAI().call_open_AI(sKey=sKey, messages=messages, max_tokens=max_tokens, temperature=temperature, model=model)
|
|
86
|
+
json_t_d = json.loads(json_t["choices"][0]["message"]["content"])
|
|
87
|
+
msg_filter_t = json_t_d["filter"]
|
|
88
|
+
messages = self.filter_RAG_l(msg_t=msg_t, key_word_l=key_word_l, msg_filter_t=msg_filter_t)
|
|
89
|
+
json_f = mstr_openAI().call_open_AI(sKey=sKey, messages=messages, max_tokens=max_tokens, temperature=temperature, model=model)
|
|
90
|
+
json_f = json_f["choices"][0]["message"]["content"]
|
|
91
|
+
filter_d = ast.literal_eval(json_f)
|
|
92
|
+
json_fin = json_t_d.copy()
|
|
93
|
+
json_fin["filter"] = filter_d
|
|
94
|
+
return json_fin
|
|
70
95
|
def filter_RAG_l(self,msg_t, key_word_l, msg_filter_t):
|
|
71
96
|
messages = [
|
|
72
97
|
{
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/__init__.py
RENAMED
|
File without changes
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_lu_data.py
RENAMED
|
File without changes
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/_mod_prj_obj.py
RENAMED
|
File without changes
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/mstr_classes.py
RENAMED
|
File without changes
|
{mstr_robotics_magerdaniel-0.3.11 → mstr_robotics_magerdaniel-0.3.12}/mstr_robotics/mstr_pandas.py
RENAMED
|
File without changes
|
|
File without changes
|