def test_log_param_with_newline(self): param_name = "new param" param_value = "a string\nwith multiple\nlines" fs = FileStore(self.test_root) run_id = self.exp_data[FileStore.DEFAULT_EXPERIMENT_ID]["runs"][0] fs.log_param(run_id, Param(param_name, param_value)) run = fs.get_run(run_id) assert run.data.params[param_name] == param_value
def test_set_deleted_run(self): """ Setting metrics/tags/params/updating run info should not be allowed on deleted runs. """ fs = FileStore(self.test_root) exp_id = self.experiments[random_int(0, len(self.experiments) - 1)] run_id = self.exp_data[exp_id]["runs"][0] fs.delete_run(run_id) assert fs.get_run(run_id).info.lifecycle_stage == LifecycleStage.DELETED with pytest.raises(MlflowException): fs.set_tag(run_id, RunTag("a", "b")) with pytest.raises(MlflowException): fs.log_metric(run_id, Metric("a", 0.0, timestamp=0, step=0)) with pytest.raises(MlflowException): fs.log_param(run_id, Param("a", "b"))
def test_log_param_enforces_value_immutability(self): param_name = "new param" fs = FileStore(self.test_root) run_id = self.exp_data[FileStore.DEFAULT_EXPERIMENT_ID]["runs"][0] fs.log_param(run_id, Param(param_name, "value1")) # Duplicate calls to `log_param` with the same key and value should succeed fs.log_param(run_id, Param(param_name, "value1")) with pytest.raises(MlflowException) as exc: fs.log_param(run_id, Param(param_name, "value2")) assert exc.value.error_code == ErrorCode.Name(INVALID_PARAMETER_VALUE) run = fs.get_run(run_id) assert run.data.params[param_name] == "value1"