Skip to content

Commit

Permalink
Merge pull request #382 from AllenCellModeling/feature/manual_config_…
Browse files Browse the repository at this point in the history
…save

Add save config function
  • Loading branch information
saeliddp authored May 8, 2024
2 parents 0463022 + 5f02a60 commit cac51a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion cyto_dl/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def load_default_experiment(
output_dir.mkdir(parents=True, exist_ok=True)

self.cfg = cfg
OmegaConf.save(self.cfg, output_dir / f'{"train" if train else "eval"}_config.yaml')

def print_config(self):
print_config_tree(self.cfg, resolve=True)
Expand All @@ -88,6 +87,13 @@ def override_config(self, overrides: Dict[str, Union[str, int, float, bool]]):
for k, v in overrides.items():
OmegaConf.update(self.cfg, k, v)

def save_config(self, path: Path) -> None:
"""Save current config to provided path.
:param path: path at which to save config
"""
OmegaConf.save(self.cfg, path)

async def _train_async(self):
return train_model(self.cfg)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies = [
"astropy>=5.2",
"rich",
"boto3",
"bioio",
"bioio>=1.0.1",
"bioio-czi",
"bioio-ome-tiff",
"bioio-tifffile"
Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_load_default_experiment_valid_exp_type(MockMkdir, MockSave):
model: CytoDLModel = CytoDLModel()
model.load_default_experiment(ExperimentType.SEGMENTATION.value, "fake_dir")
MockMkdir.assert_called()
MockSave.assert_called()
MockSave.assert_not_called()


@patch("cyto_dl.api.model.OmegaConf.save")
Expand Down

0 comments on commit cac51a4

Please sign in to comment.