Skip to content

Commit

Permalink
fix (metadata): Write config from all steps; test this
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob-Stevens-Haas committed Apr 10, 2024
1 parent 593b000 commit fa3f121
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mitosis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,9 @@ def _write_freezefile(folder: Path):

def _prettyprint_config(folder: Path, params: Collection[Parameter]):
pretty = pprint.pformat(params)
with open(folder / "config.txt", "w") as f:
with open(folder / "config.txt", "a") as f:
f.write(pretty)
f.write("\n")


def unpack(obj_ref: str) -> Any:
Expand Down
14 changes: 12 additions & 2 deletions mitosis/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_mock_experiment(mock_steps, tmp_path):
assert len(data[1]["data"]) == 5


def test_mod_logging_debug(mock_steps, tmp_path):
def test_mod_metadata_debug(mock_steps, tmp_path):
hexstr = mitosis.run(
mock_steps,
debug=True,
Expand All @@ -153,10 +153,15 @@ def test_mod_logging_debug(mock_steps, tmp_path):
log_str = "".join(f.readlines())
assert "This is run every time" in log_str
assert "This is run in debug mode only" in log_str
with open(trial_folder / "config.txt") as f:
config_lines = f.readlines()
config_params = [eval(line) for line in config_lines]
passed_params = [{p.arg_name: p.vals for p in step.args} for step in mock_steps]
assert config_params == passed_params


@pytest.mark.clean
def test_mod_logging(mock_steps, tmp_path):
def test_mod_metadata(mock_steps, tmp_path):
hexstr = mitosis.run(
mock_steps,
debug=False,
Expand All @@ -167,6 +172,11 @@ def test_mod_logging(mock_steps, tmp_path):
log_str = "".join(f.readlines())
assert "This is run every time" in log_str
assert "This is run in debug mode only" not in log_str
with open(trial_folder / "config.txt") as f:
config_lines = f.readlines()
config_params = [eval(line) for line in config_lines]
passed_params = [{p.arg_name: p.vals for p in step.args} for step in mock_steps]
assert config_params == passed_params


def test_malfored_return_experiment(mock_steps, tmp_path):
Expand Down

0 comments on commit fa3f121

Please sign in to comment.