|
31 | 31 |
|
32 | 32 | class AnnotatedVariablesExtractor(ast.NodeTransformer):
|
33 | 33 | """AnnotatedVariablesExtractor removes the typing annotations
|
34 |
| - from relative to ipython2cwl and identifies all the variables |
35 |
| - relative to an ipython2cwl typing annotation.""" |
| 34 | + from relative to ipython2cwl and identifies all the variables |
| 35 | + relative to an ipython2cwl typing annotation.""" |
36 | 36 | input_type_mapper: Dict[Tuple[str, ...], Tuple[str, str]] = {
|
37 | 37 | (CWLFilePathInput.__name__,): (
|
38 | 38 | 'File',
|
@@ -308,14 +308,18 @@ def compile(self, filename: Path = Path('notebookAsCWLTool.tar')) -> str:
|
308 | 308 | """
|
309 | 309 | workdir = tempfile.mkdtemp()
|
310 | 310 | script_path = os.path.join(workdir, 'notebookTool')
|
311 |
| - cwl_path = os.path.join(workdir, 'tool.cwl') |
| 311 | + cwl_path: str = os.path.join(workdir, 'tool.cwl') |
312 | 312 | dockerfile_path = os.path.join(workdir, 'Dockerfile')
|
313 | 313 | setup_path = os.path.join(workdir, 'setup.py')
|
314 | 314 | requirements_path = os.path.join(workdir, 'requirements.txt')
|
315 |
| - with open(script_path, 'wb') as f: |
316 |
| - f.write(self._wrap_script_to_method(self._tree, self._variables).encode()) |
317 |
| - with open(cwl_path, 'w') as f: |
318 |
| - yaml.safe_dump(self.cwl_command_line_tool(), f, encoding='utf-8') |
| 315 | + with open(script_path, 'wb') as script_fd: |
| 316 | + script_fd.write(self._wrap_script_to_method(self._tree, self._variables).encode()) |
| 317 | + with open(cwl_path, 'w') as cwl_fd: |
| 318 | + yaml.safe_dump( |
| 319 | + self.cwl_command_line_tool(), |
| 320 | + cwl_fd, |
| 321 | + encoding='utf-8' |
| 322 | + ) |
319 | 323 | dockerfile = DOCKERFILE_TEMPLATE.format(
|
320 | 324 | python_version=f'python:{".".join(platform.python_version_tuple())}'
|
321 | 325 | )
|
|
0 commit comments