Skip to content

Commit 005ee93

Browse files
committed
Update exec_pypef_api
1 parent edef1f2 commit 005ee93

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

gui/qt_window.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
pypef_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
1010
#sys.path.append(pypef_root)
1111
from pypef import __version__
12-
from pypef.main import run_main
12+
from pypef.main import __doc__, run_main
1313

1414

1515
EXEC_API_OR_CLI = ['api', 'cli'][0]
@@ -332,7 +332,12 @@ def selection_llm_model(self, i):
332332
@QtCore.Slot()
333333
def pypef_help(self):
334334
self.version_text.setText("Getting help...")
335-
self.exec_pypef(f'mklsts --help')
335+
self.textedit_out.append(__doc__)
336+
self.process.finished.connect(self.process_finished)
337+
self.c += 1
338+
if self.c > 0:
339+
self.textedit_out.append("=" * 104 + " Job: " + str(self.c) + "\n")
340+
self.version_text.setText("Finished...")
336341

337342

338343
@QtCore.Slot()
@@ -437,8 +442,6 @@ def pypef_dca_llm_hybrid_train_test(self):
437442
self.version_text.setText("Hybrid (DCA+LLM-supervised) model training...")
438443
self.exec_pypef(f'hybrid --ls {training_file} --ts {test_file} --params {params_pkl_file} --llm {self.llm}')
439444

440-
441-
442445
##### TODO END ################################################################################################# TODO END
443446

444447

@@ -478,24 +481,27 @@ def exec_pypef_cli(self, cmd):
478481
self.textedit_out.append("=" * 104 + "\n")
479482

480483
def exec_pypef_api(self, cmd):
481-
self.textedit_out.append(f'Executing command:{cmd}')
484+
print(cmd) # TODO remove
485+
self.textedit_out.append(f'Executing command:\n\t{cmd}')
486+
self.c += 1
482487
try:
483488
with Capturing() as captured_output:
484489
run_main(argv=cmd)
485-
print(captured_output)
490+
print(captured_output)
486491
for cap_out_text in captured_output:
487492
self.textedit_out.append(cap_out_text)
488493
except Exception as e: # anything
489-
self.textedit_out.append(f"Provided wrong inputs! Error: {e}")
494+
self.textedit_out.append(f"Provided wrong inputs! Error:\n\t{e}")
490495
finally:
491496
self.process.finished.connect(self.process_finished)
492497
if self.c > 0:
493-
self.textedit_out.append("=" * 104 + "\n")
498+
self.textedit_out.append("=" * 104 + " Job: " + str(self.c) + "\n")
499+
self.version_text.setText("Finished...")
494500

495501

496502
def process_finished(self):
497503
self.version_text.setText("Finished...")
498-
#self.process = None
504+
self.process = None
499505

500506

501507
if __name__ == "__main__":

pypef/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286
A2M format [default: False].
287287
"""
288288

289-
from sys import argv, version_info
289+
from sys import version_info
290290
from pypef import __version__
291291
if version_info[0] < 3 or version_info[1] < 9:
292292
raise SystemError(f"The current version of PyPEF (v {__version__}) requires at "

0 commit comments

Comments
 (0)