Skip to content
Snippets Groups Projects
Commit eccf820d authored by Alán Muñoz's avatar Alán Muñoz
Browse files

yaml is alive!

Former-commit-id: 6ea363c356a58fb0b5dcc86b431f5eeb32a968a2
parent ddfad924
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,8 @@ from pathlib import Path, PosixPath ...@@ -2,6 +2,8 @@ from pathlib import Path, PosixPath
from typing import Union from typing import Union
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from yaml import safe_load, dump
class ParametersABC(ABC): class ParametersABC(ABC):
""" """
...@@ -16,8 +18,11 @@ class ParametersABC(ABC): ...@@ -16,8 +18,11 @@ class ParametersABC(ABC):
def from_dict(cls, d: dict): def from_dict(cls, d: dict):
return cls(**d) return cls(**d)
def to_yaml(self, path: Union[PosixPath, str]): def to_yaml(self, path: Union[PosixPath, str] = None):
return dump(self.__dict__, path) if path:
with open(Path(path), "w") as f:
dump(self.to_dict(), f)
return dump(self.to_dict())
@classmethod @classmethod
def from_yaml(cls, path: Union[PosixPath, str]): def from_yaml(cls, path: Union[PosixPath, str]):
......
...@@ -25,7 +25,7 @@ class PickerParameters(ParametersABC): ...@@ -25,7 +25,7 @@ class PickerParameters(ParametersABC):
def default(cls): def default(cls):
return cls.from_dict( return cls.from_dict(
{ {
"condition": ("present", 0.8), "condition": ["present", 0.8],
"lineage": None, "lineage": None,
"sequence": ["lineage", "condition"], "sequence": ["lineage", "condition"],
} }
......
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