mg-pso-gui 0.1.198__py3-none-any.whl → 0.1.200__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mg-pso-gui
3
- Version: 0.1.198
3
+ Version: 0.1.200
4
4
  Summary: GUI for MG-PSO
5
5
  Author: Robert Cordingly
6
6
  Author-email: <rcording@uw.ed>
@@ -2,7 +2,7 @@ mgpsogui/__init__.py,sha256=q7AfBjeJABnFtbsZnsObpUwaXKPDVYtz46G6MKXLF74,42
2
2
  mgpsogui/mgpsogui.py,sha256=NIZmyNcbwC8EgSwf1ubdMUSJscrIEgoD4jLYziqHQ-k,148
3
3
  mgpsogui/start.yaml,sha256=ZjCVLb-MLqAxrGRm9kA7_SDpa-45EuKIELNQ2QqCAiU,4713
4
4
  mgpsogui/gui/HomePage.py,sha256=S4vm9gtwoWjfbNmFSX5e-_l18ti0YIFulrH9a3v953s,22845
5
- mgpsogui/gui/OptionManager.py,sha256=CmwUV6FdgBf1DN8EhCVM1IRptCGVlArZFjpgWvHUwpE,14807
5
+ mgpsogui/gui/OptionManager.py,sha256=dtWY5jzNAaL6t3q7SLHiwoKQOYrAsMGE5UqwYdmPzF4,14829
6
6
  mgpsogui/gui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  mgpsogui/gui/PlatformTab/PlatformTab.py,sha256=q8x_tvVgSoyGINuQbivXRThF3gaSSfg8X_dsLSPv4F0,10492
8
8
  mgpsogui/gui/PlatformTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -11,13 +11,13 @@ mgpsogui/gui/RunTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
11
11
  mgpsogui/gui/SetupTab/BoundsEditorWindow.py,sha256=_6_xEl46PY9MmNvpmoMNdNDbVav6ODwWSDROboy57Cs,2866
12
12
  mgpsogui/gui/SetupTab/BoundsList.py,sha256=L77UEaUJNiUE-ZsYIl44tWRb1zBfxaEQ-bAG1V5_IH0,12268
13
13
  mgpsogui/gui/SetupTab/CalibrationParametersView.py,sha256=ppVBHG3nphku9-P6Z8az-HTpgk8vHxnj-A5m80BZTgA,2784
14
- mgpsogui/gui/SetupTab/FunctionsList.py,sha256=tUqW43VWpxFpdo9UHaPvFQ0CtCo9mFI3mri52ikntrE,4092
14
+ mgpsogui/gui/SetupTab/FunctionsList.py,sha256=Ty0S2Hs7XrtZCQNo7nSKNVYoMkRQN9-x0CEWogwgcO4,4709
15
15
  mgpsogui/gui/SetupTab/ListEditor.py,sha256=vlP0KDPu8J1_6KXuUTlE7OClgfF0Qk6cISsFm_SglUw,3232
16
16
  mgpsogui/gui/SetupTab/ListParametersView.py,sha256=wYcDcaooYkw-y7XW6dJUwhTWxLuUUOK5tGUFVHBf3ck,7352
17
17
  mgpsogui/gui/SetupTab/OptimalParameterView.py,sha256=VKn-4BlVyqspFIOkbWsM0q9pYVsmqnSND0xP2hDKb60,1785
18
18
  mgpsogui/gui/SetupTab/SetupTab.py,sha256=_cehQwQhDbX92da_AwqYQ2mQo7sFDGkN1IsYQmctK5o,2776
19
19
  mgpsogui/gui/SetupTab/StaticParameterView.py,sha256=iEG-UpBBlAJabZo3MG768oLqOROjUPc23tKOSd47IUc,2739
20
- mgpsogui/gui/SetupTab/StepView.py,sha256=mUtxtXoEnh86oILaTaobjW3lpkgNio1MZZuM2RLOsqU,9034
20
+ mgpsogui/gui/SetupTab/StepView.py,sha256=C6DDinU9AgaUM1EOAHetFI4bE89ANJ247F0doksaPus,9091
21
21
  mgpsogui/gui/SetupTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  mgpsogui/gui/VisualizeTab/MatrixEditor.py,sha256=JPQmfljdddIwHtTKpFqUdk7hRzVdX-IKl4neOk3DsjM,3132
23
23
  mgpsogui/gui/VisualizeTab/SideBar.py,sha256=MtZfDScNFN0fQ8DyPm6bZGJSrFRgT14fZeUq-qc61O8,21936
@@ -35,7 +35,7 @@ mgpsogui/gui/images/test.png,sha256=MUnVpRK-isxhEHzx4Q6Yh0M6FRZD1qvgCHH2XmiSBbk,
35
35
  mgpsogui/gui/images/trash.png,sha256=j8cf0kWbJd-4Jp20lUVV1o1NSeQ4v1Ej4gfcIA3DVRQ,2958
36
36
  mgpsogui/gui/images/up.png,sha256=AQvFWCUqSQNaQ1E6LKZ9zNfSvW6t4mgy8uswdg9T2Hg,2457
37
37
  mgpsogui/util/GraphGenerator.py,sha256=OyCPwIDkbRzNZiJQII3F76yTKj_EdeMiE8vaih-n5lE,22811
38
- mgpsogui/util/PSORunner.py,sha256=sWgickFGl97p3ybWz97LR5qeYhnNqryKx5nWAa-NhwA,6306
38
+ mgpsogui/util/PSORunner.py,sha256=-kOjzPaYVq8G5NJSdUddAYxa5KVPTn3NYmVGv2I_1cg,10251
39
39
  mgpsogui/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  mgpsogui/util/debug.py,sha256=Swzny9_1S-CCONWGssj9iDoSpbwu5Vr4f95g_9L8bec,19759
41
41
  mgpsogui/util/helpers.py,sha256=Ht2rge_4pGO7halz6KoLsL2eukB0k2tlkx68lBBmBA8,2669
@@ -60,8 +60,8 @@ mgpsogui/util/recosu/utils/trace_writer.py,sha256=V9BJlOjCbNYGoXGEk3CF5wjifBxvar
60
60
  mgpsogui/util/recosu/utils/utils.py,sha256=QB8vftq3142ekG0ORjz0ZBHU5YknXbR0oTsrxrPAsF0,3951
61
61
  mgpsogui/util/recosu/utils/plot/__init__.py,sha256=h1KjM7_tNDv351pcwt8A6Ibb1jhwWyx5Gbu-zj-sI3Q,71
62
62
  mgpsogui/util/recosu/utils/plot/cost_steps.py,sha256=1Ce11AJyweWkmvjXPxEygzS-h8yVLmQEDLS53yjPLqQ,3779
63
- mg_pso_gui-0.1.198.dist-info/METADATA,sha256=uNvoylGNem8RiBo7616A0ZYctI_bdkS7vRpwf3JqGLQ,9456
64
- mg_pso_gui-0.1.198.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
65
- mg_pso_gui-0.1.198.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
66
- mg_pso_gui-0.1.198.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
67
- mg_pso_gui-0.1.198.dist-info/RECORD,,
63
+ mg_pso_gui-0.1.200.dist-info/METADATA,sha256=MtO6uzSX0HXy_M1Crudg10PiS4-B2CVoslla7Mm34FY,9456
64
+ mg_pso_gui-0.1.200.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
65
+ mg_pso_gui-0.1.200.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
66
+ mg_pso_gui-0.1.200.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
67
+ mg_pso_gui-0.1.200.dist-info/RECORD,,
@@ -22,7 +22,7 @@ class OptionManager():
22
22
  self.steps = []
23
23
  self.service_parameters = {}
24
24
 
25
- self.service_modes = ["Optimization: MG-PSO", "Sampling: Halton", "Sampling: Random", "Sensitivity Analysis"]
25
+ self.service_modes = ["Optimization: MG-PSO", "Sampling: Halton", "Sampling: Random", "Sensitivity: Halton", "Sensitivity: Random"]
26
26
  for mode in self.service_modes:
27
27
  self.arguments["urls"][mode] = sv()
28
28
 
@@ -47,8 +47,27 @@ class FunctionsList(CTkFrame):
47
47
 
48
48
  row += 1
49
49
 
50
+ columns = ["absdiff",
51
+ "absdifflog",
52
+ "ave",
53
+ "bias",
54
+ "fhf",
55
+ "ioa",
56
+ "ioa2",
57
+ "kge",
58
+ "kge09",
59
+ "mns",
60
+ "mse",
61
+ "ns",
62
+ "ns2log",
63
+ "nslog1p",
64
+ "nslog2",
65
+ "pbias",
66
+ "pmcc",
67
+ "rmse",
68
+ "trmse"]
50
69
  CTkEntry(self.containerFrame, textvariable=func["name"]).grid(row=row, column=0, padx=(5, 5), pady=(5, 5), sticky="ew")
51
- CTkEntry(self.containerFrame, textvariable=func["of"]).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
70
+ CTkOptionMenu(self.containerFrame, values=columns, variable=func["of"]).grid(row=row, column=1, padx=(5, 5), pady=(5, 5), sticky="ew")
52
71
  CTkEntry(self.containerFrame, textvariable=func["weight"]).grid(row=row, column=2, padx=(5, 5), pady=(5, 5), sticky="ew")
53
72
 
54
73
  row += 1
@@ -106,7 +106,7 @@ class StepView(CTkScrollableFrame):
106
106
 
107
107
  row += 1
108
108
 
109
- if step['open'] or (self.mode == "Sampling: Halton" or self.mode == "Sampling: Random" or self.mode == "Sensitivity Analysis"):
109
+ if step['open'] or (self.mode == "Sampling: Halton" or self.mode == "Sampling: Random" or self.mode == "Sensitivity: Halton" or self.mode == "Sensitivity: Random"):
110
110
  bounds = BoundsList.BoundsList(
111
111
  self.containerFrame, option_manager=self.option_manager, step_index=index)
112
112
  bounds.grid(row=row, column=0, padx=(10, 10),
@@ -132,6 +132,7 @@ class StepView(CTkScrollableFrame):
132
132
  CTkButton(self.containerFrame, text="Add Group", command=self.create_new_step).grid(
133
133
  row=row, columnspan=2, column=0, padx=(10, 10), pady=(10, 10), sticky="ew")
134
134
 
135
+ """
135
136
  if (self.mode == "Sampling: Halton" or self.mode == "Sampling: Random" or self.mode == "Sensitivity Analysis"):
136
137
  self.analysisFrame = CTkFrame(self)
137
138
  self.analysisFrame.grid(row=2, column=0, columnspan=2, padx=(10, 10), pady=(10, 10), sticky="nsew")
@@ -161,7 +162,7 @@ class StepView(CTkScrollableFrame):
161
162
  self.positive_editor.grid_rowconfigure(0, weight=1)
162
163
 
163
164
  self.negative_editor = ListEditor.ListEditor(self.analysisFrame, option_manager=self.option_manager,
164
- title = "Negative Best Metrics",
165
+ title = "Zero Best Metrics",
165
166
  columns=columns,
166
167
  parameter_name="sensitivity_negativeBestMetrics",
167
168
  parameter_remove_func=self.option_manager.remove_sensitivity_negativeBestMetrics,
@@ -169,3 +170,4 @@ class StepView(CTkScrollableFrame):
169
170
  self.negative_editor.grid(row=0, column=2, padx=(10, 10), pady=(10, 0), sticky="nsew")
170
171
  self.negative_editor.grid_columnconfigure(0, weight=1)
171
172
  self.negative_editor.grid_rowconfigure(0, weight=1)
173
+ """
@@ -7,6 +7,10 @@ import time
7
7
  import os
8
8
  from .recosu.sampling.sampling import run_sampler
9
9
  from .recosu.pso import global_best
10
+ from csip import Client
11
+ import traceback
12
+ import urllib
13
+ import shutil
10
14
 
11
15
  def enqueue_output(out, queue):
12
16
  for line in iter(out.readline, b''):
@@ -131,6 +135,80 @@ def run_process(stdout_queue, stderr_queue, results_queue, data, folder):
131
135
  trace_file=os.path.join(folder, 'results', 'random_trace.csv'))
132
136
  results_queue.put(trace)
133
137
  print(trace, flush=True)
138
+ elif my_mode == "Sensitivity: Halton":
139
+ shutil.copyfile(os.path.join(folder, 'results', 'halton_trace.csv'), os.path.join(folder, 'results', 'trace.csv'))
140
+ trace_path = os.path.join(folder, 'results', 'trace.csv')
141
+
142
+ # Get list of parameters from steps
143
+ parameters = []
144
+ for param in steps[0]['parameters']:
145
+ parameters.append(param['name'])
146
+
147
+ request_json = {
148
+ "metainfo": {
149
+ "service_url": None,
150
+ "description": "",
151
+ "name": "",
152
+ "mode": "async"
153
+ },
154
+ "parameter": [
155
+ {
156
+ "name": "parameters",
157
+ "value": parameters
158
+ },
159
+ {
160
+ "name": "positiveBestMetrics",
161
+ "value": ["ns","kge","mns","kge09","nslog2"]
162
+ },
163
+ {
164
+ "name": "zeroBestMetrics",
165
+ "value": ["pbias","rmse"]
166
+ }
167
+ ]
168
+ }
169
+ # Write the request to a file
170
+ with open(os.path.join(folder, 'results', 'request.json'), 'w') as f:
171
+ f.write(str(request_json))
172
+ request_path = os.path.join(folder, 'results', 'request.json')
173
+
174
+ sensitivity_analysis(args['url'], request_path, trace_path, folder)
175
+ elif my_mode == "Sensitivity: Random":
176
+ shutil.copyfile(os.path.join(folder, 'results', 'random_trace.csv'), os.path.join(folder, 'results', 'trace.csv'))
177
+ trace_path = os.path.join(folder, 'results', 'trace.csv')
178
+
179
+ # Get list of parameters from steps
180
+ parameters = []
181
+ for param in steps[0]['parameters']:
182
+ parameters.append(param['name'])
183
+
184
+ request_json = {
185
+ "metainfo": {
186
+ "service_url": None,
187
+ "description": "",
188
+ "name": "",
189
+ "mode": "async"
190
+ },
191
+ "parameter": [
192
+ {
193
+ "name": "parameters",
194
+ "value": parameters
195
+ },
196
+ {
197
+ "name": "positiveBestMetrics",
198
+ "value": ["ns","kge","mns","kge09","nslog2"]
199
+ },
200
+ {
201
+ "name": "zeroBestMetrics",
202
+ "value": ["pbias","rmse"]
203
+ }
204
+ ]
205
+ }
206
+ # Write the request to a file
207
+ with open(os.path.join(folder, 'results', 'request.json'), 'w') as f:
208
+ f.write(str(request_json))
209
+ request_path = os.path.join(folder, 'results', 'request.json')
210
+
211
+ sensitivity_analysis(args['url'], request_path, trace_path, folder)
134
212
  else:
135
213
  print("Running MG-PSO Optimization...\n", flush=True)
136
214
  optimizer, trace = global_best(steps,
@@ -166,4 +244,31 @@ def run_process(stdout_queue, stderr_queue, results_queue, data, folder):
166
244
  stderr_thread.join()
167
245
 
168
246
  sys.stdout = old_stdout
169
- sys.stderr = old_stderr
247
+ sys.stderr = old_stderr
248
+
249
+ def create_request(request_file: str) -> Client:
250
+ request: Client = Client.from_file(request_file)
251
+ return request
252
+
253
+ def download_output(response: Client, target_directory) -> None:
254
+ data_names: list[str] = response.get_data_names()
255
+ for name in data_names:
256
+ url = response.get_data_value(name)
257
+ file_path = os.path.join(target_directory, name)
258
+ urllib.request.urlretrieve(url, file_path)
259
+
260
+ def sensitivity_analysis(url, request_file, trace_file, output_directory):
261
+ request: Client = create_request(request_file)
262
+ files: list[str] = [trace_file] if os.path.isfile(trace_file) else []
263
+ conf = {
264
+ 'service_timeout': 60.0, # (sec)
265
+ }
266
+ result: Client = Client()
267
+ try:
268
+ result = request.execute(url, files=files, sync=True, conf=conf)
269
+ except Exception as ex:
270
+ traceback.print_exc()
271
+ exit(1)
272
+
273
+ if result.is_finished():
274
+ download_output(result, output_directory)