Commit 7aee4c64 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Solver: Fix running pipeline.

Showing with 30 additions and 14 deletions
+30 -14
......@@ -172,12 +172,13 @@ class CommandLineSolver(AbstractSolver):
if not os.path.exists(exe):
error = f"[ERROR] Path {exe} do not exists"
logger.info(error)
logger.warning(error)
return error
self._process.start(
exe, args,
)
self._process.waitForStarted()
return True
......@@ -191,7 +192,7 @@ class CommandLineSolver(AbstractSolver):
if not os.path.exists(exe):
error = f"[ERROR] Path {exe} do not exists"
logger.info(error)
logger.warning(error)
return error
self._process.start(
......@@ -212,37 +213,48 @@ class CommandLineSolver(AbstractSolver):
if not os.path.exists(exe):
error = f"[ERROR] Path {exe} do not exists"
logger.info(error)
logger.warning(error)
return error
self._process.start(
exe, args,
)
self._process.waitForStarted()
return True
def _data_ready(self):
# Read process output and put lines in queue
s = self._process.readAll().data().decode()
if self._output is not None:
for x in s.split('\n'):
self._output.put(x)
def _run_next(self, study):
self._step += 1
if self._step < len(self._runs):
res = self._runs[self._step](study)
if res is not True:
self._output.put(res)
else:
self._status = STATUS.STOPED
def _finished(self, study, exit_code, exit_status):
if self._output is not None:
self._output.put(exit_code)
logger.debug(
"Process finished with " +
f"code: {exit_code}, status: {exit_status}"
)
self._run_next(study)
def _run_next(self, study):
self._step += 1
if self._step >= len(self._runs):
self._status = STATUS.STOPED
return
fn = self._runs[self._step]
res = fn(study)
if res is not True:
self._output.put(res)
def run(self, study, process=None, output_queue=None):
self._study = study
......@@ -255,7 +267,8 @@ class CommandLineSolver(AbstractSolver):
# Connect / reconnect signal
self._process.readyRead.connect(self._data_ready)
self._process.finished.connect(
lambda c, s: self._finished(study, c, s))
lambda c, s: self._finished(study, c, s)
)
# Prepare running step
self._runs = [
......@@ -265,6 +278,8 @@ class CommandLineSolver(AbstractSolver):
]
self._step = 0
self._status = STATUS.RUNNING
# Run first step
res = self._runs[0](study)
if res is not True:
......
......@@ -20,7 +20,7 @@ import os
import logging
import numpy as np
from tools import timer
from tools import timer, trace
from Solver.CommandLine import CommandLineSolver
from Checker.Mage import MageNetworkGraphChecker
......
......@@ -273,6 +273,7 @@ class SolverLogWindow(PamhyrWindow):
def _update_logs_all(self):
while self._output.qsize() != 0:
s = self._output.get()
if type(s) is str and "[ERROR]" in s:
self._log(s, color="red")
else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment