mg-pso-gui 0.0.193__py3-none-any.whl → 0.0.195__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.193
3
+ Version: 0.0.195
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=Zd6g8URhhScwr6lmgz3c-1SK4aylDT-dK1HFB0opl90,24760
4
+ mgpsogui/gui/HomePage.py,sha256=ApzNyeOENIGMvJiff-E_EBdTQZtKny_DfzHllm5S8z4,25197
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
@@ -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=6dx8kz_fODGKhG--oDW3gr9jNr_RAK311Cp1OY1jyuA,2983
31
+ mgpsogui/util/GraphGenerator.py,sha256=_YCZRzB8f4qzj5LRhOLTFS9SZMUceRPBjdBTqm0JkbI,7850
32
+ mgpsogui/util/PSORunner.py,sha256=jYsOBGR-Mu1cN0JTE6R-Wa3UWUxIufCbM9jZxpFPwwI,6706
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.193.dist-info/METADATA,sha256=Z7EmvVSsFfbuu2BsiwZykqelGlGd6pZ5A88l4Mrygmk,9459
37
- mg_pso_gui-0.0.193.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
38
- mg_pso_gui-0.0.193.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
39
- mg_pso_gui-0.0.193.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
40
- mg_pso_gui-0.0.193.dist-info/RECORD,,
36
+ mg_pso_gui-0.0.195.dist-info/METADATA,sha256=5ZqwSoJ46QjkuYJWuhWXXCsefHAiCylsMHQkYOzfLc8,9459
37
+ mg_pso_gui-0.0.195.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
38
+ mg_pso_gui-0.0.195.dist-info/entry_points.txt,sha256=jg82VOFjR1XDGrchs1wJSCqKYE4Ozv12aBcCSp--koA,117
39
+ mg_pso_gui-0.0.195.dist-info/top_level.txt,sha256=y7JuS9xJN5YdxUsQ3PSVjN8MzQAnR146bP3ZN3PYWdE,9
40
+ mg_pso_gui-0.0.195.dist-info/RECORD,,
mgpsogui/gui/HomePage.py CHANGED
@@ -26,6 +26,8 @@ import ast
26
26
  import platform
27
27
  import time
28
28
 
29
+ from queue import Empty
30
+
29
31
  from ..util import PSORunner
30
32
  from ..util import GraphGenerator
31
33
 
@@ -48,6 +50,10 @@ from ..util.CTkToolTip import CTkToolTip as ctt
48
50
  customtkinter.set_appearance_mode("Dark") # Modes: "System" (standard), "Dark", "Light"
49
51
  customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
50
52
 
53
+ results_queue = Queue()
54
+ stdout_queue = Queue()
55
+ stderr_queue = Queue()
56
+
51
57
  class App(customtkinter.CTk):
52
58
  def __init__(self):
53
59
  super().__init__()
@@ -341,8 +347,7 @@ class App(customtkinter.CTk):
341
347
  info = self.option_manager.get_project_data()
342
348
  folder = os.path.join(info['path'], info['name'])
343
349
 
344
- self.process_queue = Queue()
345
- self.train_process = Process(target=PSORunner.run_process, args=(self.process_queue, metrics, folder))
350
+ self.train_process = Process(target=PSORunner.run_process, args=(stdout_queue, stderr_queue, results_queue, metrics, folder))
346
351
  self.train_process.daemon = True
347
352
  self.train_process.start()
348
353
  self.after(1000, self.watch_loop)
@@ -403,6 +408,16 @@ class App(customtkinter.CTk):
403
408
 
404
409
  if not os.path.exists(folder):
405
410
  os.makedirs(folder)
411
+
412
+ try:
413
+ stdout_line = stdout_queue.get_nowait()
414
+ stderr_line = stderr_queue.get_nowait()
415
+ except Empty:
416
+ pass # No output yet
417
+ else:
418
+ # Got line from the output: do something
419
+ print(f"Received stdout: {stdout_line}")
420
+ print(f"Received stderr: {stderr_line}")
406
421
 
407
422
  if (os.path.exists(os.path.join(folder, 'output.txt'))):
408
423
  with open(os.path.join(folder, 'output.txt'), 'r') as f:
@@ -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,107 @@
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
+ old_stdout = sys.stdout
38
+ old_stderr = sys.stderr
39
+
40
+ read_stdout, write_stdout = os.pipe()
41
+ read_stderr, write_stderr = os.pipe()
42
+
43
+ sys.stdout = os.fdopen(write_stdout, 'w')
44
+ sys.stderr = os.fdopen(write_stderr, 'w')
45
+
46
+ stdour_thread = threading.Thread(target=enqueue_output, args=(os.fdopen(read_stdout, 'r'), stdout_queue))
47
+ stderr_thread = threading.Thread(target=enqueue_output, args=(os.fdopen(read_stderr, 'r'), stderr_queue))
48
+ stdour_thread.daemon = True
49
+ stderr_thread.daemon = True
50
+ stdour_thread.start()
51
+ stderr_thread.start()
52
+
53
+ options = {}
54
+ oh_strategy = {}
55
+
56
+ for key in calibration_map.keys():
57
+ if "options_" in key:
58
+ options[key.replace("options_", "")] = float(calibration_map[key])
59
+ if "strategy_" in key:
60
+ oh_strategy[key.replace("strategy_", "")] = calibration_map[key]
61
+
62
+ print("\n")
63
+ print(calibration_map)
64
+ print("\n")
65
+ print(options)
66
+ print("\n")
67
+ print(oh_strategy)
68
+ print("\n")
69
+
70
+ print("Running global_best...\n")
71
+
72
+ optimizer, trace = global_best(steps, # step definition
73
+ rounds=(int(calibration_map['min_rounds']), int(calibration_map['max_rounds'])), # min/max number of rounds
74
+ args=args, # static arguments
75
+ n_particles=int(calibration_map['n_particles']), # number of particle candidates for each param
76
+ iters=int(calibration_map['iters']), # max # of iterations
77
+ n_threads=int(calibration_map['n_threads']), # number of threads to use
78
+ # ftol=0.00000001, # min cost function delta for convergence
79
+ options=options, # hyperparameter
80
+ oh_strategy=oh_strategy, # adaptive hyperparameter adjustments based on current and max # of iterations
81
+ conf={
82
+ 'service_timeout': int(calibration_map['service_timeout']),
83
+ 'http_retry': int(calibration_map['http_retry']),
84
+ 'http_allow_redirects': True if calibration_map['allow_redirects'] == "True" else False,
85
+ 'async_call': True if calibration_map['async_call'] == "True" else False,
86
+ 'http_conn_timeout': int(calibration_map['conn_timeout']),
87
+ 'http_read_timeout': int(calibration_map['read_timeout']),
88
+ 'particles_fail': int(calibration_map['particles_fail'])
89
+ },
90
+ )
91
+
92
+ stdour_thread.join()
93
+ stderr_thread.join()
94
+
95
+ sys.stdout = old_stdout
96
+ sys.stderr = old_stderr
97
+ results_queue.put((optimizer, trace))
98
+
99
+
100
+
101
+
102
+ """import csip
103
+ import cosu
104
+ import sys
4
105
  import multiprocessing
5
106
  import threading
6
107
  import time
@@ -50,7 +151,7 @@ def run_process(process_queue, data, folder):
50
151
 
51
152
  print("Running global_best...\n")
52
153
 
53
- optimizer, trace = global_best(steps, # step definition
154
+ optimizer, trace = global_best(steps, # step definition
54
155
  rounds=(int(calibration_map['min_rounds']), int(calibration_map['max_rounds'])), # min/max number of rounds
55
156
  args=args, # static arguments
56
157
  n_particles=int(calibration_map['n_particles']), # number of particle candidates for each param
@@ -72,3 +173,4 @@ def run_process(process_queue, data, folder):
72
173
 
73
174
  process_queue.put((optimizer, trace))
74
175
 
176
+ """