Exemplo n.º 1
0
    def test_fork_identical_new_trial(self):
        lineage = LineageNode(TrialStub(id="my-id", working_dir="same_folder"))
        with pytest.raises(
            RuntimeError, match="The new trial new-id has the same working directory"
        ):
            lineage.fork(TrialStub(id="new-id", working_dir="same_folder"))

        assert lineage.children == []
Exemplo n.º 2
0
    def test_fork_to_existing_path(self, tmp_path):
        trial = TrialStub(id="stub", working_dir=os.path.join(tmp_path, "stub"))
        os.makedirs(trial.working_dir)
        lineage = LineageNode(trial)
        new_trial = TrialStub(id="fork", working_dir=os.path.join(tmp_path, "fork"))
        os.makedirs(new_trial.working_dir)

        with pytest.raises(
            FileExistsError, match="Folder already exists for trial fork."
        ):
            lineage.fork(new_trial)

        assert lineage.children == []
Exemplo n.º 3
0
    def test_fork(self, mocker):
        path = "/some_path"
        trial = TrialStub(path)
        lineage = LineageNode(trial)

        new_path = "/another_path"
        new_trial = TrialStub(new_path)

        mocker.patch("shutil.copytree")
        new_lineage = lineage.fork(new_trial)
        shutil.copytree.assert_called_once_with(path, new_path)

        assert new_lineage.item.working_dir == new_trial.working_dir
        assert new_lineage.parent is lineage
        assert lineage.children[0] is new_lineage