def test_delete_tags(self): 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.set_tag(run_id, RunTag("tag0", "value0")) fs.set_tag(run_id, RunTag("tag1", "value1")) tags = fs.get_run(run_id).data.tags assert tags["tag0"] == "value0" assert tags["tag1"] == "value1" fs.delete_tag(run_id, "tag0") new_tags = fs.get_run(run_id).data.tags assert "tag0" not in new_tags.keys() # test that you cannot delete tags that don't exist. with pytest.raises(MlflowException): fs.delete_tag(run_id, "fakeTag") # test that you cannot delete tags for nonexistent runs with pytest.raises(MlflowException): fs.delete_tag("random_id", "tag0") fs = FileStore(self.test_root) fs.delete_run(run_id) # test that you cannot delete tags for deleted runs. assert fs.get_run( run_id).info.lifecycle_stage == LifecycleStage.DELETED with pytest.raises(MlflowException): fs.delete_tag(run_id, "tag0")
def test_get_deleted_run(self): """ Getting metrics/tags/params/run info should 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)
def test_delete_restore_run(self): 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] # Should not throw. assert fs.get_run(run_id).info.lifecycle_stage == 'active' fs.delete_run(run_id) assert fs.get_run(run_id).info.lifecycle_stage == 'deleted' fs.restore_run(run_id) assert fs.get_run(run_id).info.lifecycle_stage == 'active'
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)) with pytest.raises(MlflowException): fs.log_param(run_id, Param('a', 'b'))