Fixed unit tests
This commit is contained in:
@@ -81,7 +81,7 @@ class WorkflowDesignerCommandManager(BaseCommandManager):
|
||||
"hx_post": f"{ROUTE_ROOT}{Routes.PauseWorkflow}",
|
||||
"hx-target": f"#{self._owner.tabs_manager.get_id()}",
|
||||
"hx-swap": "outerHTML",
|
||||
"hx-vals": f'js:{{"_id": "{self._id}")}}',
|
||||
"hx-vals": f'js:{{"_id": "{self._id}"}}',
|
||||
}
|
||||
|
||||
def stop_workflow(self):
|
||||
@@ -89,7 +89,7 @@ class WorkflowDesignerCommandManager(BaseCommandManager):
|
||||
"hx_post": f"{ROUTE_ROOT}{Routes.StopWorkflow}",
|
||||
"hx-target": f"#{self._owner.tabs_manager.get_id()}",
|
||||
"hx-swap": "outerHTML",
|
||||
"hx-vals": f'js:{{"_id": "{self._id}")}}',
|
||||
"hx-vals": f'js:{{"_id": "{self._id}"}}',
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ class WorkflowDesigner(BaseComponent):
|
||||
|
||||
def stop_workflow(self):
|
||||
self._error_message = None
|
||||
self._player.run()
|
||||
self._player.stop()
|
||||
return self.tabs_manager.refresh()
|
||||
|
||||
def on_processor_details_event(self, component_id: str, event_name: str, details: dict):
|
||||
|
||||
@@ -68,8 +68,6 @@ class WorkflowPlayer(BaseComponent):
|
||||
|
||||
self._init_state(ComponentState.NOT_RUN)
|
||||
|
||||
components_by_id = {c.id: c for c in self._designer.get_workflow_components()}
|
||||
|
||||
try:
|
||||
sorted_components = self._get_sorted_components()
|
||||
engine = self._get_engine(sorted_components)
|
||||
@@ -81,7 +79,7 @@ class WorkflowPlayer(BaseComponent):
|
||||
return
|
||||
except WorkflowsPlayerError as ex:
|
||||
self.has_error = True
|
||||
self.global_error = f"Failed to init component '{ex.component_id}': {ex.error}"
|
||||
self.global_error = self._get_global_error_as_str(ex, "Failed to init ")
|
||||
if ex.component_id in self.runtime_states:
|
||||
self.runtime_states[ex.component_id].state = ComponentState.FAILURE
|
||||
self.runtime_states[ex.component_id].error_message = str(ex.error)
|
||||
@@ -105,7 +103,7 @@ class WorkflowPlayer(BaseComponent):
|
||||
error = engine.errors[component.id]
|
||||
runtime_state.state = ComponentState.FAILURE
|
||||
runtime_state.error_message = str(error)
|
||||
self.global_error = f"Error in component '{error.component_id}': {error.error}" # update global error as well
|
||||
self.global_error = self._get_global_error_as_str(error, "Error in ") # update global error as well
|
||||
self.has_error = True
|
||||
break # the remaining components will remain as NOT_RUN
|
||||
|
||||
@@ -196,6 +194,9 @@ class WorkflowPlayer(BaseComponent):
|
||||
|
||||
elif component.type == ProcessorTypes.Presenter and component.properties["processor_name"] == "Default":
|
||||
engine.add_processor(DefaultDataPresenter(component.id, component.properties["columns"]))
|
||||
else:
|
||||
raise ValueError(
|
||||
f"Unsupported processor : type={component.type}, name={component.properties['processor_name']}")
|
||||
except Exception as e:
|
||||
raise WorkflowsPlayerError(component.id, e)
|
||||
|
||||
@@ -214,3 +215,10 @@ class WorkflowPlayer(BaseComponent):
|
||||
suffix = get_unique_id()
|
||||
|
||||
return make_safe_id(f"{prefix}{suffix}")
|
||||
|
||||
@staticmethod
|
||||
def _get_global_error_as_str(error, prefix=""):
|
||||
if hasattr(error, "component_id"):
|
||||
return f"{prefix}component '{error.component_id}': {error.error}"
|
||||
else:
|
||||
return str(error)
|
||||
|
||||
Reference in New Issue
Block a user