Skip to content

Commit

Permalink
clean execute
Browse files Browse the repository at this point in the history
  • Loading branch information
giannisdoukas committed Apr 5, 2020
1 parent 4f64972 commit 9135ce2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cwlkernel/CWLKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def _execute_workflow(self, code) -> Optional[Exception]:
self._cwl_executor.set_data(self._yaml_input_data)
self._cwl_executor.set_workflow(code)
logger.debug('starting executing workflow ...')
run_id, results, stdout, stderr, exception = self._cwl_executor.execute()
logger.debug(f'\texecution results: {run_id}, {results}, {stdout}, {stderr}, {exception}')
run_id, results, exception = self._cwl_executor.execute()
logger.debug(f'\texecution results: {run_id}, {results}, {exception}')
output_directory_for_that_run = str(run_id)
for output in results:
if isinstance(results[output], list):
Expand Down
11 changes: 4 additions & 7 deletions cwlkernel/CoreExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ def set_workflow(self, workflow_str: str) -> str:
self._workflow_path = self.file_manager.write(f'{str(uuid4())}.cwl', workflow_str.encode())
return self._workflow_path

def execute(self) -> Tuple[UUID, Dict, StringIO, StringIO, Optional[Exception]]:
def execute(self) -> Tuple[UUID, Dict, Optional[Exception]]:
"""
:return: Run ID, List of new files, stdout, stderr, exception if there is any
:return: Run ID, dict with new files, exception if there is any
"""
run_id = uuid4()
# args = [self._workflow_path, *self._data_paths]
stdout = StringIO()
stderr = StringIO()

runtime_context = RuntimeContext()
runtime_context.outdir = self.file_manager.ROOT_DIRECTORY
Expand All @@ -63,10 +60,10 @@ def execute(self) -> Tuple[UUID, Dict, StringIO, StringIO, Optional[Exception]]:
data = {**new_data, **data}
try:
result: Dict = executable(**data)
return run_id, result, stdout, stderr, None
return run_id, result, None
except Exception as e:
traceback.print_exc(file=sys.stderr)
return run_id, {}, stdout, stderr, e
return run_id, {}, e

@classmethod
def validate_input_files(cls, yaml_input: Dict, cwd: Path) -> NoReturn:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_CoreExecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ def test_executor_execute(self):
data_str = f.read()
executor.set_data([data_str])
try:
execution_id, new_files, stdout, stderr, exception = executor.execute()
execution_id, new_files, exception = executor.execute()
self.assertIsNotNone(execution_id)
self.assertDictEqual(new_files, {})
self.assertIsInstance(stdout, io.IOBase)
self.assertIsInstance(stderr, io.IOBase)
self.assertIsNone(exception, 'An exception occurred while executing workflow')
except Exception:
self.fail("execution failed")
Expand Down

0 comments on commit 9135ce2

Please sign in to comment.