Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/sophios/api/_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""CWL Types."""
from enum import Enum
from pathlib import Path
from typing import Any


class CWLTypesEnum(str, Enum):
Expand Down
39 changes: 0 additions & 39 deletions src/sophios/api/pythonapi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# pylint: disable=W1203
"""CLT utilities."""
import logging
import subprocess as sub
from pathlib import Path, PurePath
from typing import Any, ClassVar, Optional, TypeVar, Union, Dict, List

Expand Down Expand Up @@ -39,9 +38,6 @@ def filter(self, record: logging.LogRecord) -> bool:
logger_wicad.addFilter(DisableEverythingFilter())


_WIC_PATH = Path(__file__).parent.parent.parent.parent # WIC dir


class InvalidInputValueError(Exception):
pass

Expand Down Expand Up @@ -461,16 +457,6 @@ def _yml(self) -> dict:
d["when"] = self.when
return d

def _save_cwl(self, path: Path) -> None:
cwl_adapters = path.joinpath("cwl_adapters")
cwl_adapters.mkdir(exist_ok=True, parents=True)
with open(
cwl_adapters.joinpath(f"{self.process_name}.cwl"),
"w",
encoding="utf-8",
) as file:
file.write(yaml.dump(self.yaml))

def get_inp_attr(self, __name: str) -> Any:
"""Returns the input object of the given name"""
return self.inputs[self._input_names.index(__name)]
Expand Down Expand Up @@ -647,10 +633,6 @@ def add_output(self, __name: str) -> Any:
self.outputs.append(out)
return out

# def __repr__(self) -> str:
# repr_ = ...
# return repr_

def __setattr__(self, __name: str, __value: Any) -> Any:
if __name in ["inputs", "outputs", "yaml", "cfg_yaml", "process_name", "_input_names", "_output_names",
"__private_attributes__", "__pydantic_private__"]:
Expand Down Expand Up @@ -682,25 +664,6 @@ def __getattr__(self, __name: str) -> Any:
# The same goes for __setattr__ and __delattr__, see: https://github.com/pydantic/pydantic/issues/8643"
return super().__getattr__(__name) # type: ignore

def _save_yaml(self) -> None:
_WIC_PATH.mkdir(parents=True, exist_ok=True)
self.yml_path = _WIC_PATH.joinpath(f"{self.process_name}.wic")
with open(f"{self.process_name}.wic", "w", encoding="utf-8") as file:
file.write(yaml.dump(self.yaml))

def _save_all_cwl(self) -> None:
"""Save CWL files to cwl_adapters.

This is necessary for WIC to compile the workflow.
"""
_WIC_PATH.mkdir(parents=True, exist_ok=True)
for s in self.steps:
try:
if isinstance(s, Step):
s._save_cwl(_WIC_PATH) # pylint: disable=W0212
except BaseException as exc:
raise exc

def flatten_steps(self) -> list[Step]:
"""Flattens all Steps into a linear list. This is similar, but different, from inlineing.

Expand Down Expand Up @@ -797,8 +760,6 @@ def get_cwl_workflow(self, args_dict: Dict[str, str] = {}) -> Json:
"yaml_inputs": yaml_inputs,
**cwl_ast
}
# delete the skeletal and ephemeral autogenerated folder
_ = sub.run(['rm -rf autogenerated'], shell=True, check=False, executable="/bin/bash")
return workflow_json

def run(self, compile_args_dict: Dict[str, str] = {}, run_args_dict: Dict[str, str] = {}) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/sophios/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def compile_workflow_once(yaml_tree_ast: YamlTree,
(yaml_path_orig, yaml_tree_orig) = copy.deepcopy(yaml_tree_ast)

if not testing:
print(' starting', (' ' * len(namespaces)) + yaml_path)
print(' starting compilation of', (' ' * len(namespaces)) + yaml_path)

# Check for top-level yml dsl args
wic = {'wic': yaml_tree.get('wic', {})}
Expand Down Expand Up @@ -909,7 +909,7 @@ def populate_scalar_val(in_dict: dict) -> Any:
yaml_inputs.update(new_keyval)

if not testing:
print('finishing', (' ' * len(namespaces)) + yaml_path)
print('finishing compilation of', (' ' * len(namespaces)) + yaml_path)
# Note: We do not necessarily need to return inputs_workflow.
# 'Internal' inputs are encoded in yaml_tree. See Comment above.
node_data = NodeData(namespaces, yaml_stem, yaml_tree_orig, yaml_tree, tool_i, yaml_inputs,
Expand Down