Skip to content

Commit

Permalink
Merge pull request #127 from hsorby/main
Browse files Browse the repository at this point in the history
Add human readable message to workflow execution failure.
  • Loading branch information
hsorby authored Dec 3, 2024
2 parents 99503f0 + 7c7ec1f commit c7f357f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mapclient/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def windows_main(workflow, execute_now):
if wm.canExecute() == 0:
window.execute()
else:
logger.error('Could not execute workflow.')
logger.error(f'Could not execute workflow, reason: "{wm.execute_status_message()}"')

splash.showMessage('Ready ...', 100)
splash.finish(window)
Expand Down Expand Up @@ -287,7 +287,7 @@ def model(self):
if wm.canExecute() == 0:
wm.execute()
else:
logger.error('Could not execute workflow.')
logger.error(f'Could not execute workflow, reason: "{wm.execute_status_message()}"')

# Possibly don't need to run app.exec_()
return app.quit()
Expand Down
3 changes: 3 additions & 0 deletions src/mapclient/core/managers/workflowmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def set_workflow_direction(self, direction):
def canExecute(self):
return self._scene.canExecute()

def execute_status_message(self):
return self._scene.execute_status_message()

def registerDoneExecutionForAll(self, callback):
self._scene.registerDoneExecutionForAll(callback)

Expand Down
10 changes: 10 additions & 0 deletions src/mapclient/core/workflow/workflowdependencygraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def __init__(self, scene):
self._current = -1
self._direction = 1
self._finished_callback = None
self._execute_status_message = "No status reported."

def _find_all_connected_nodes(self):
"""
Expand Down Expand Up @@ -149,6 +150,9 @@ def _connections_for_nodes(self, source, destination):
def set_finished_callback(self, callback):
self._finished_callback = callback

def execute_status_message(self):
return self._execute_status_message

def can_execute(self):
self._dependency_graph = self._calculate_dependency_graph()
self._reverse_dependency_graph = _reverse_dict_with_lists(self._dependency_graph)
Expand All @@ -168,16 +172,22 @@ def can_execute(self):
configured = [metastep.getStep().isConfigured() for metastep in self._topological_order]

if not all(configured):
self._execute_status_message = "Not all steps are configured."
return 1
elif items_count == 0:
self._execute_status_message = "No steps in workflow."
return 2
elif items_count > 1 and len(self._topological_order) == 0 and len(self._dependency_graph.keys()) == 0:
self._execute_status_message = "Multiple steps but no connections to create workflow."
return 3
elif self._current != -1:
self._execute_status_message = "Already executing."
return 4
elif items_count > 1 and len(self._topological_order) == 0:
self._execute_status_message = "Multiple steps but no connections to create workflow 2."
return 5

self._execute_status_message = "Can execute."
return 0

def abort(self):
Expand Down
3 changes: 3 additions & 0 deletions src/mapclient/core/workflow/workflowscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ def setMainWindow(self, main_window):
def canExecute(self):
return self._dependencyGraph.can_execute()

def execute_status_message(self):
return self._dependencyGraph.execute_status_message()

def execute(self):
self._dependencyGraph.execute()

Expand Down

0 comments on commit c7f357f

Please sign in to comment.