Skip to content

Commit

Permalink
- Enhance threading call process
Browse files Browse the repository at this point in the history
  • Loading branch information
maycuatroi committed Jun 11, 2023
1 parent 78b38eb commit 94ca718
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion evoflow/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.9.2
0.1.9.3
13 changes: 7 additions & 6 deletions evoflow/entities/core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def run(self, **kwargs):
) as live:
# live.update(Panel(spinners, title="Panel 2"))

# add
self.live_panel = live
while True:
# do self.__run by new thread
self.__run(live=live, **kwargs)

def __run(self, live=None, **kwargs):
def __run(self, **kwargs):
self.compile()
logger.info(f"Running job: {self.name}")
self.params_pool = kwargs
Expand All @@ -85,8 +85,6 @@ def __run(self, live=None, **kwargs):
log_string = f"Running step : {step}"
logger.info(log_string)
step.prepare(**self.params_pool)
if live is not None:
self.__update_live(live)
try:
action_params = inspect.getfullargspec(step.action).args
build_params = {}
Expand All @@ -111,6 +109,7 @@ def __run(self, live=None, **kwargs):
return last_result

def __init__(self, name=None, start_step: Step = None, **kwargs):
self.live_panel = None # for progress monitor
self.current_step = None
self.__start_step: Step = start_step
self.params_pool = {}
Expand Down Expand Up @@ -247,7 +246,9 @@ def add_running_step(self, step):
def remove_running_step(self, step):
self.__running_steps.remove(step)

def __update_live(self, live):
def update_status(self,**kwargs):
if self.live_panel is None:
return
tree = Tree(self.name)
running_steps = self.__running_steps

Expand All @@ -273,4 +274,4 @@ def __update_live(self, live):
if step.is_running():
tree.add(Spinner("material", text=Text(step.name, style="blue")))

live.update(Panel(tree, title=f"Running {self.name}"))
self.live_panel.update(Panel(tree, title=f"Running {self.name}"))
4 changes: 3 additions & 1 deletion evoflow/entities/core/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def end(self, **kwargs) -> dict:
"""
self.status = self.STATUS_SUCCESS
self.job.remove_running_step(self)
self.job.update_status()
return self.params

def prepare(self, **kwargs):
Expand All @@ -109,6 +110,7 @@ def prepare(self, **kwargs):
self.params = kwargs
self.job.add_running_step(self)
self.status = self.STATUS_RUNNING
self.job.update_status()

def __str__(self):
return self.name
Expand Down Expand Up @@ -166,4 +168,4 @@ def is_running(self):
"""
Check if step is running
"""
return self.status == self.STATUS_RUNNING
return self.status == self.STATUS_RUNNING

0 comments on commit 94ca718

Please sign in to comment.