Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
giannisdoukas committed Jun 9, 2020
1 parent 38f64db commit 0fe13b0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cwlkernel/CWLBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_current_code(self) -> str:
return self._code

def build(self) -> WorkflowComponent:
code = yaml.load(StringIO(self._code), yaml.Loader)
code = yaml.safe_load(StringIO(self._code))
if 'id' not in code:
raise ValueError("the workflow must contain an id")
if code['class'] == 'CommandLineTool':
Expand Down
8 changes: 4 additions & 4 deletions cwlkernel/CWLExecuteConfigurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class CWLExecuteConfigurator:

def __init__(self):
"""Kernel configurations."""
for property, (default_value, validator) in self.properties.items():
value = os.environ.get(property, default_value)
for property_name, (default_value, validator) in self.properties.items():
value = os.environ.get(property_name, default_value)
if not validator(value):
raise RuntimeError("Value {0} is not allowed for property {1}".format(value, property))
raise RuntimeError("Value {0} is not allowed for property {1}".format(value, property_name))
self.__setattr__(
property,
property_name,
value
)
2 changes: 1 addition & 1 deletion cwlkernel/CWLKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _execute_workflow(self, code_path: Path) -> Optional[Exception]:
output_directory_for_that_run = str(run_id)
for output in results:
if isinstance(results[output], list):
for i, output_i in enumerate(results[output]):
for i, _ in enumerate(results[output]):
results[output][i]['id'] = f'{output}_{i + 1}'
results[output][i]['result_counter'] = self._results_manager.files_counter
self._results_manager.append_files(
Expand Down
8 changes: 4 additions & 4 deletions cwlkernel/CoreExecutor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os
import subprocess
import sys
import traceback
from pathlib import Path
from subprocess import DEVNULL
from typing import (
Dict,
List,
Expand Down Expand Up @@ -46,9 +46,9 @@ def execute(self) -> Tuple[UUID, Dict, Optional[Exception]]:
runtime_context = RuntimeContext()
runtime_context.outdir = self.file_manager.ROOT_DIRECTORY
runtime_context.basedir = self.file_manager.ROOT_DIRECTORY
runtime_context.default_stdin = subprocess.DEVNULL
runtime_context.default_stdout = subprocess.DEVNULL
runtime_context.default_stderr = subprocess.DEVNULL
runtime_context.default_stdin = DEVNULL
runtime_context.default_stdout = DEVNULL
runtime_context.default_stderr = DEVNULL
os.chdir(self.file_manager.ROOT_DIRECTORY)
factory = Factory(runtime_context=runtime_context)
executable = factory.make(self._workflow_path)
Expand Down
7 changes: 1 addition & 6 deletions cwlkernel/cwlrepository/CWLComponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ def steps(self):
steps[step]['run'] = f"{steps[step]['run']._id}.cwl"
return deepcopy(steps)

"""
A composite object can add or remove other components (both simple or
complex) to or from its child list.
"""

def add(self, component: WorkflowComponent, step_name: str) -> None:
self._steps[step_name] = {
'run': component,
Expand Down Expand Up @@ -188,7 +183,7 @@ def compose_requirements(self) -> Dict:

class WorkflowComponentFactory:
def get_workflow_component(self, yaml_string: str) -> WorkflowComponent:
component = yaml.load(StringIO(yaml_string), yaml.SafeLoader)
component = yaml.safe_load(StringIO(yaml_string))
if 'id' not in component:
component['id'] = str(uuid.uuid4())
if component['class'] == 'CommandLineTool':
Expand Down
6 changes: 3 additions & 3 deletions cwlkernel/cwlrepository/cwlrepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def validate(self, tool: WorkflowComponent):
raise TypeError(f'WorkflowComponent expected but type of {type(tool)} given')
if not isinstance(tool.id, str):
raise MissingIdError('Missing WorkflowComponent\'s id')
for input in tool.inputs:
if 'id' not in input:
raise MissingIdError(f'Missing id for input: {input}')
for tool_input in tool.inputs:
if 'id' not in tool_input:
raise MissingIdError(f'Missing id for input: {tool_input}')
for output in tool.outputs:
if 'id' not in output:
raise MissingIdError(f'Missing id for outputs: {output}')
Expand Down

0 comments on commit 0fe13b0

Please sign in to comment.