Skip to content
Snippets Groups Projects
Commit d908b428 authored by Charlotte Hausman's avatar Charlotte Hausman Committed by Charlotte Hausman
Browse files

fix CapabilityEngine to actually load the capability execution it's executing...

fix CapabilityEngine to actually load the capability execution it's executing and then properly release the engine after completion
parent 7de31fa6
No related branches found
No related tags found
1 merge request!86fix CapabilityEngine
Pipeline #599 passed
...@@ -22,17 +22,26 @@ class CapabilityEngine(CapabilityEngineIF): ...@@ -22,17 +22,26 @@ class CapabilityEngine(CapabilityEngineIF):
): ):
self.capability_info = capability_info self.capability_info = capability_info
self.workflow_service = workflow_service self.workflow_service = workflow_service
self.execution = None
def execute(self, execution: CapabilityExecutionIF): def load_engine(self, execution: CapabilityExecutionIF):
"""
Load capability execution of interest into capability engine for access and execution
:param execution: execution to be executed by this engine
:return:
"""
self.execution = execution
def execute(self):
""" """
Communicate with workflow service and send a request to run a workflow with given settings Communicate with workflow service and send a request to run a workflow with given settings
:param execution: :param execution:
""" """
step_sequence = CapabilitySequence.from_str(execution.steps) step_sequence = CapabilitySequence.from_str(self.execution.steps)
# Grab value of current step (workflow name) # Grab value of current step (workflow name)
cur_step = step_sequence[int(execution.current_step)] cur_step = step_sequence[int(self.execution.current_step)]
cur_step.execute(self, execution) cur_step.execute(self, self.execution)
def submit_workflow_request( def submit_workflow_request(
self, execution_id: int, workflow_name: str, workflow_args: dict, files: List[AbstractFile] self, execution_id: int, workflow_name: str, workflow_args: dict, files: List[AbstractFile]
......
...@@ -71,9 +71,10 @@ class CapabilityQueue(CapabilityQueueIF): ...@@ -71,9 +71,10 @@ class CapabilityQueue(CapabilityQueueIF):
if engine: if engine:
execution = self.capability_info.lookup_execution(execution.id) execution = self.capability_info.lookup_execution(execution.id)
# Start engine # Start engine
engine.execute(execution) engine.load_engine(execution)
# Move engine to in-use list # Move engine to in-use list
self.engine_list.in_use.append(engine) self.engine_list.in_use.append(engine)
engine.execute()
else: else:
# FIXME: Logging # FIXME: Logging
print("No available engines. Try again later.") print("No available engines. Try again later.")
...@@ -87,7 +88,7 @@ class CapabilityQueue(CapabilityQueueIF): ...@@ -87,7 +88,7 @@ class CapabilityQueue(CapabilityQueueIF):
:return: Corresponding engine :return: Corresponding engine
""" """
for engine in self.engine_list.in_use: for engine in self.engine_list.in_use:
if engine.execution_id == execution_id: if engine.execution.id == execution_id:
# Found correct engine # Found correct engine
return engine return engine
...@@ -99,7 +100,6 @@ class CapabilityQueue(CapabilityQueueIF): ...@@ -99,7 +100,6 @@ class CapabilityQueue(CapabilityQueueIF):
""" """
engine = self.find_engine(execution_id) engine = self.find_engine(execution_id)
self.engine_list.in_use.remove(engine) self.engine_list.in_use.remove(engine)
engine.execution_id = None
engine.execution = None engine.execution = None
self.engine_list.available.put(engine) self.engine_list.available.put(engine)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment