Skip to content

Commit

Permalink
Merge pull request #109 from hsorby/one-step-exe
Browse files Browse the repository at this point in the history
Allow workflows to be executed with only one step present.
  • Loading branch information
hsorby authored Mar 7, 2024
2 parents 8c83fc5 + 811e887 commit 485e6bb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/mapclient/core/workflow/workflowdependencygraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from mapclient.core.utils import convert_exception_to_message, FileTypeObject
from mapclient.core.workflow.workflowerror import WorkflowError
from mapclient.core.workflow.workflowitems import Connection
from mapclient.core.workflow.workflowitems import Connection, MetaStep
from mapclient.core.metrics import get_metrics_logger


Expand Down Expand Up @@ -129,6 +129,15 @@ def _calculate_dependency_graph(self):

return graph

def _solo_node(self):
scene_items = list(self._scene.items())
if len(scene_items) == 1:
scene_item = scene_items[0]
if scene_item.Type == MetaStep.Type:
return scene_item

return None

def _connections_for_nodes(self, source, destination):
connections = []
for item in list(self._scene.items()):
Expand All @@ -151,7 +160,13 @@ def can_execute(self):

self._topological_order = _determine_topological_order(self._dependency_graph, starting_set)

solo_node = self._solo_node()
if solo_node:
self._dependency_graph = {solo_node: []}
self._topological_order = [solo_node]

configured = [metastep for metastep in self._topological_order if metastep.getStep().isConfigured()]

can = len(configured) == len(self._topological_order) and len(self._topological_order) >= 0
return can and self._current == -1

Expand Down

0 comments on commit 485e6bb

Please sign in to comment.