mg-pso-gui 0.0.192__py3-none-any.whl → 0.0.194__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mg-pso-gui
3
- Version: 0.0.192
3
+ Version: 0.0.194
4
4
  Summary: GUI for MG-PSO
5
5
  Author: Robert Cordingly
6
6
  Author-email: <rcording@uw.ed>
@@ -1,7 +1,7 @@
1
1
  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
- mgpsogui/gui/HomePage.py,sha256=3u3N4-t8LHL-uL67r3MTyBjakUnS8sR9UodH0gKw9kQ,24299
4
+ mgpsogui/gui/HomePage.py,sha256=5bPiprgGXbEYfCS4Da0xHUectF1z8RfKu1w6fa7MCRQ,24969
5
5
  mgpsogui/gui/OptionManager.py,sha256=bFN2jWJbx1Din3waOFLmbWGt0BXD_KthGJ8Mgue_FEE,11712
6
6
  mgpsogui/gui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  mgpsogui/gui/PlatformTab/PlatformTab.py,sha256=KyIoHlMKD9nfQqHeGJwRDA4RCoe4UykjB2l6xMTKK_M,10486
@@ -17,7 +17,7 @@ mgpsogui/gui/SetupTab/SetupTab.py,sha256=Doy_6xLq1BjhLTFHRQm7CAbpQzUnNJW4KkBcdfr
17
17
  mgpsogui/gui/SetupTab/StaticParameterView.py,sha256=iEG-UpBBlAJabZo3MG768oLqOROjUPc23tKOSd47IUc,2739
18
18
  mgpsogui/gui/SetupTab/StepView.py,sha256=oG5Q-3xpTRP1f_PbNvohKctrbpD63zLAJzHD00bN44k,5531
19
19
  mgpsogui/gui/SetupTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- mgpsogui/gui/VisualizeTab/VisualizeTab.py,sha256=V37Rkd6B6JP0ILQMfA89Gny5cmv6sr6vkT3zBRWVWOQ,3276
20
+ mgpsogui/gui/VisualizeTab/VisualizeTab.py,sha256=rrti0q3tXfmCRwt87ZvnO2M6asOkS2Tp1kcv2ERjbSk,3292
21
21
  mgpsogui/gui/VisualizeTab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  mgpsogui/gui/images/collapse.png,sha256=yicb16LaY7Nl5q9V8HHlht-Fbg5xU-l4_LJ_Arfmu1c,2989
23
23
  mgpsogui/gui/images/down.png,sha256=pspJkvUitD648C_2y8JLLD4Eagpk4MDEKQJGOO_yIaY,2654
@@ -28,13 +28,13 @@ mgpsogui/gui/images/refresh_hd.png,sha256=lprZtCNZ9JUm20SPwfaslr-VV4yzzmCPEB6oFf
28
28
  mgpsogui/gui/images/stop.png,sha256=JPuxXQerCGpLikcp7cAj3iLCOjULMYYZ2sZe0lArh68,2153
29
29
  mgpsogui/gui/images/trash.png,sha256=j8cf0kWbJd-4Jp20lUVV1o1NSeQ4v1Ej4gfcIA3DVRQ,2958
30
30
  mgpsogui/gui/images/up.png,sha256=AQvFWCUqSQNaQ1E6LKZ9zNfSvW6t4mgy8uswdg9T2Hg,2457
31
- mgpsogui/util/GraphGenerator.py,sha256=hEPhka0ZKQJ9DSSywDfwoXFQMsk3RHyG8QyTLOQnN4M,7851
32
- mgpsogui/util/PSORunner.py,sha256=7iUYRUXgpZ0l0rqoyHQYY1Yg9q0gl9TE0jNaHZMv04c,2921
31
+ mgpsogui/util/GraphGenerator.py,sha256=_YCZRzB8f4qzj5LRhOLTFS9SZMUceRPBjdBTqm0JkbI,7850
32
+ mgpsogui/util/PSORunner.py,sha256=s8ISdXe7VEYL4K4OXNpSk3pwde09pWYelgUfgmSwddA,6860
33
33
  mgpsogui/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
34
  mgpsogui/util/CTkToolTip/__init__.py,sha256=G1jxV55hGtGgwyC1sR-uUUdasDdh0XZgcI-aILgGYA0,225
35
35
  mgpsogui/util/CTkToolTip/ctk_tooltip.py,sha256=SZMovpQIGvdpDRbqCKl9SHs92DrFCO2MOYL2ifolvOE,6329
36
- mg_pso_gui-0.0.192.dist-info/METADATA,sha256=3sYHKLOo6H3SGmjKGYdNevq4rtG7Ime1O8q3f5Qw2r4,9459
37
- mg_pso_gui-0.0.192.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
38
- mg_pso_gui-0.0.192.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
39
- mg_pso_gui-0.0.192.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
40
- mg_pso_gui-0.0.192.dist-info/RECORD,,
36
+ mg_pso_gui-0.0.194.dist-info/METADATA,sha256=qj_4-I6oxQP9hhPaAJIgi6BPA1FtDO1mG1z3YgKKnuw,9459
37
+ mg_pso_gui-0.0.194.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
38
+ mg_pso_gui-0.0.194.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
39
+ mg_pso_gui-0.0.194.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
40
+ mg_pso_gui-0.0.194.dist-info/RECORD,,
mgpsogui/gui/HomePage.py CHANGED
@@ -48,6 +48,10 @@ from ..util.CTkToolTip import CTkToolTip as ctt
48
48
  customtkinter.set_appearance_mode("Dark") # Modes: "System" (standard), "Dark", "Light"
49
49
  customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
50
50
 
51
+ results_queue = Queue()
52
+ stdout_queue = Queue()
53
+ stderr_queue = Queue()
54
+
51
55
  class App(customtkinter.CTk):
52
56
  def __init__(self):
53
57
  super().__init__()
@@ -341,8 +345,7 @@ class App(customtkinter.CTk):
341
345
  info = self.option_manager.get_project_data()
342
346
  folder = os.path.join(info['path'], info['name'])
343
347
 
344
-
345
- self.train_process = Process(target=PSORunner.run_process, args=(metrics, folder))
348
+ self.train_process = Process(target=PSORunner.run_process, args=(stdout_queue, stderr_queue, results_queue, metrics, folder))
346
349
  self.train_process.daemon = True
347
350
  self.train_process.start()
348
351
  self.after(1000, self.watch_loop)
@@ -403,6 +406,11 @@ class App(customtkinter.CTk):
403
406
 
404
407
  if not os.path.exists(folder):
405
408
  os.makedirs(folder)
409
+
410
+ if (stdout_queue.qsize() > 0):
411
+ val = stdout_queue.get()
412
+ self.textbox.insert("0.0", val)
413
+ print(val)
406
414
 
407
415
  if (os.path.exists(os.path.join(folder, 'output.txt'))):
408
416
  with open(os.path.join(folder, 'output.txt'), 'r') as f:
@@ -504,6 +512,16 @@ class App(customtkinter.CTk):
504
512
  if self.train_process.is_alive():
505
513
  self.after(1000, self.watch_loop)
506
514
  else:
515
+ # Check if queue is empty
516
+ if (self.process_queue.empty()):
517
+ print("PROCESS FINISHED BUT WE GOT NO OBJECTS :(")
518
+ self.footer_progress_label.configure(text="Failed")
519
+ else:
520
+ self.final_results = self.process_queue.get()
521
+ print("PROCESS FINISHED WE GOT THINGS")
522
+ print(self.final_results)
523
+ self.footer_progress_label.configure(text="Finished")
524
+
507
525
  #self.progress_bar.stop()
508
526
  self.footer_progress_bar.stop()
509
527
  #self.progress_bar.configure(mode="indeterminate")
@@ -513,7 +531,6 @@ class App(customtkinter.CTk):
513
531
  self.progress_message_left.configure(text="")
514
532
  self.progress_message_middle.configure(text="Calibration finished!")
515
533
  self.progress_message_right.configure(text="")
516
- self.footer_progress_label.configure(text="Finished")
517
534
  self.textbox.insert("0.0", "\nCalibration finished!\n")
518
535
 
519
536
  def start():
@@ -61,11 +61,11 @@ def create_tab(self, tab):
61
61
 
62
62
  self.graph_selector_value = tk.StringVar()
63
63
  self.graph_selector_value.set("Best Cost Stacked")
64
- self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, values=["Best Cost Stacked", "Best Cost by Round", "Calibrated Parameters", "Iteration Table"], variable=self.graph_selector_value, command=self.update_graph)
64
+ self.graph_selector = customtkinter.CTkOptionMenu(self.graph_sidebar, width=250, values=["Best Cost Stacked", "Best Cost by Round", "Calibrated Parameters", "Iteration Table"], variable=self.graph_selector_value, command=self.update_graph)
65
65
  self.graph_selector.grid(row=0, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
66
66
 
67
67
  # Add a button to call open_graph_in_browser
68
- self.graph_button = customtkinter.CTkButton(self.graph_sidebar, text="Open Graph in Browser", command=open_graph_in_browser)
68
+ self.graph_button = customtkinter.CTkButton(self.graph_sidebar, text="Open in Browser", width=250, command=open_graph_in_browser)
69
69
  self.graph_button.grid(row=9, column=0, padx=(20, 20), pady=(20, 20), sticky="nsew")
70
70
 
71
71
  self.graph_image_obj = Image.open(os.path.join("./images", "refresh_hd.png"))
@@ -4,7 +4,7 @@ import pandas as pd
4
4
  import numpy as np
5
5
  import os
6
6
 
7
- def best_cost_stacked(config, dataframe, option_manager):
7
+ def best_coststacked(config, dataframe, option_manager):
8
8
  fig = go.Figure()
9
9
 
10
10
  total_steps = len(config)
@@ -1,6 +1,110 @@
1
1
  import csip
2
2
  import cosu
3
3
  import sys
4
+ from multiprocessing import Process, Queue
5
+ from queue import Empty
6
+ import threading
7
+ import time
8
+ import os
9
+
10
+ from cosu.pso import global_best
11
+
12
+ def enqueue_output(out, queue):
13
+ for line in iter(out.readline, b''):
14
+ queue.put(line)
15
+ out.close()
16
+
17
+ def run_process(stdout_queue, stderr_queue, results_queue, data, folder):
18
+ steps = data['steps']
19
+ args = data['arguments']
20
+ calib = data['calibration_parameters']
21
+
22
+ calibration_map = {}
23
+ for param in calib:
24
+ param_name = param['name']
25
+ param_value = param['value']
26
+ calibration_map[param_name] = param_value
27
+
28
+ if not os.path.exists(folder):
29
+ os.makedirs(folder)
30
+
31
+ if (os.path.exists(os.path.join(folder, 'output.txt'))):
32
+ os.remove(os.path.join(folder, 'output.txt'))
33
+
34
+ if (os.path.exists(os.path.join(folder, 'error.txt'))):
35
+ os.remove(os.path.join(folder, 'error.txt'))
36
+
37
+ #sys.stdout = open(os.path.join(folder, 'output.txt'), 'w', buffering=1)
38
+ #sys.stderr = open(os.path.join(folder, 'error.txt'), 'w', buffering=1)
39
+
40
+ old_stdout = sys.stdout
41
+ old_stderr = sys.stderr
42
+
43
+ read_stdout, write_stdout = os.pipe()
44
+ read_stderr, write_stderr = os.pipe()
45
+
46
+ sys.stdout = os.fdopen(write_stdout, 'w')
47
+ sys.stderr = os.fdopen(write_stderr, 'w')
48
+
49
+ stdour_thread = threading.Thread(target=enqueue_output, args=(os.fdopen(read_stdout, 'r'), stdout_queue))
50
+ stderr_thread = threading.Thread(target=enqueue_output, args=(os.fdopen(read_stderr, 'r'), stderr_queue))
51
+ stdour_thread.daemon = True
52
+ stderr_thread.daemon = True
53
+ stdour_thread.start()
54
+ stderr_thread.start()
55
+
56
+ options = {}
57
+ oh_strategy = {}
58
+
59
+ for key in calibration_map.keys():
60
+ if "options_" in key:
61
+ options[key.replace("options_", "")] = float(calibration_map[key])
62
+ if "strategy_" in key:
63
+ oh_strategy[key.replace("strategy_", "")] = calibration_map[key]
64
+
65
+ print("\n")
66
+ print(calibration_map)
67
+ print("\n")
68
+ print(options)
69
+ print("\n")
70
+ print(oh_strategy)
71
+ print("\n")
72
+
73
+ print("Running global_best...\n")
74
+
75
+ optimizer, trace = global_best(steps, # step definition
76
+ rounds=(int(calibration_map['min_rounds']), int(calibration_map['max_rounds'])), # min/max number of rounds
77
+ args=args, # static arguments
78
+ n_particles=int(calibration_map['n_particles']), # number of particle candidates for each param
79
+ iters=int(calibration_map['iters']), # max # of iterations
80
+ n_threads=int(calibration_map['n_threads']), # number of threads to use
81
+ # ftol=0.00000001, # min cost function delta for convergence
82
+ options=options, # hyperparameter
83
+ oh_strategy=oh_strategy, # adaptive hyperparameter adjustments based on current and max # of iterations
84
+ conf={
85
+ 'service_timeout': int(calibration_map['service_timeout']),
86
+ 'http_retry': int(calibration_map['http_retry']),
87
+ 'http_allow_redirects': True if calibration_map['allow_redirects'] == "True" else False,
88
+ 'async_call': True if calibration_map['async_call'] == "True" else False,
89
+ 'http_conn_timeout': int(calibration_map['conn_timeout']),
90
+ 'http_read_timeout': int(calibration_map['read_timeout']),
91
+ 'particles_fail': int(calibration_map['particles_fail'])
92
+ },
93
+ )
94
+
95
+ stdour_thread.join()
96
+ stderr_thread.join()
97
+
98
+ sys.stdout = old_stdout
99
+ sys.stderr = old_stderr
100
+ results_queue.put((optimizer, trace))
101
+
102
+
103
+
104
+
105
+ """import csip
106
+ import cosu
107
+ import sys
4
108
  import multiprocessing
5
109
  import threading
6
110
  import time
@@ -8,7 +112,7 @@ import os
8
112
 
9
113
  from cosu.pso import global_best
10
114
 
11
- def run_process(data, folder):
115
+ def run_process(process_queue, data, folder):
12
116
  steps = data['steps']
13
117
  args = data['arguments']
14
118
  calib = data['calibration_parameters']
@@ -50,7 +154,7 @@ def run_process(data, folder):
50
154
 
51
155
  print("Running global_best...\n")
52
156
 
53
- optimizer, trace = global_best(steps, # step definition
157
+ optimizer, trace = global_best(steps, # step definition
54
158
  rounds=(int(calibration_map['min_rounds']), int(calibration_map['max_rounds'])), # min/max number of rounds
55
159
  args=args, # static arguments
56
160
  n_particles=int(calibration_map['n_particles']), # number of particle candidates for each param
@@ -69,4 +173,7 @@ def run_process(data, folder):
69
173
  'particles_fail': int(calibration_map['particles_fail'])
70
174
  },
71
175
  )
176
+
177
+ process_queue.put((optimizer, trace))
72
178
 
179
+ """