Skip to content

Commit

Permalink
Add seaborn to reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
euxhenh committed Jul 29, 2023
1 parent 7f4b55e commit 9796c76
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ gseapy
diptest
phenotype_cover
leidenalg
pyensembl
pyensembl
seaborn
14 changes: 6 additions & 8 deletions src/grinch/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,12 @@ class BaseConfigurable(_BaseConfigurable):

class Config(BaseConfig):
seed: int | None = None
logs_path: Path | None = Path('./grinch_logs') # Default
logs_path: Path = Path('./grinch_logs') # Default
sanity_check: ClassVar[bool] = Field(False, exclude=True)
interactive: bool = Field(False, exclude=True)

@field_validator('logs_path', mode='before')
def convert_to_Path(cls, val):
if val is None:
return None
return Path(val)

cfg: Config
Expand All @@ -121,7 +119,7 @@ def __init__(self, cfg: Config, /):
self._reporter = reporter

@property
def logs_path(self) -> Path | None:
def logs_path(self) -> Path:
return self.cfg.logs_path

@contextmanager
Expand All @@ -130,16 +128,16 @@ def interactive(self, save_path: str | Path | None = None, **kwargs):
yield None
plt.ioff()

if all_not_None(self.logs_path, save_path):
self.logs_path.mkdir(parents=True, exist_ok=True) # type: ignore
if save_path is not None:
self.logs_path.mkdir(parents=True, exist_ok=True)
# Set good defaults
kwargs.setdefault('dpi', 300)
kwargs.setdefault('bbox_inches', 'tight')
kwargs.setdefault('transparent', True)
plt.savefig(self.logs_path / save_path, **kwargs) # type: ignore
plt.savefig(self.logs_path / save_path, **kwargs)

plt.clf()
plt.show()
plt.close()

def log(
self,
Expand Down
1 change: 1 addition & 0 deletions src/grinch/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, cfg: Config, /) -> None:
for c in self.cfg.processors:
if self.cfg.seed is not None:
c.seed = self.cfg.seed
c.logs_path = c.logs_path / self.cfg.data_writepath.split('/')[-1]
self.processors.append(c.initialize())

@validate_call(config=dict(arbitrary_types_allowed=True))
Expand Down

0 comments on commit 9796c76

Please sign in to comment.