def test_search_with_max_results(self): fs = FileStore(self.test_root) exp = fs.create_experiment("search_with_max_results") runs = [ fs.create_run(exp, 'user', r, []).info.run_id for r in range(10) ] runs.reverse() print(runs) print(self._search(fs, exp)) assert (runs[:10] == self._search(fs, exp)) for n in [0, 1, 2, 4, 8, 10, 20, 50, 100, 500, 1000, 1200, 2000]: assert (runs[:min(1200, n)] == self._search(fs, exp, max_results=n)) with self.assertRaises(MlflowException) as e: self._search(fs, exp, None, max_results=int(1e10)) self.assertIn("Invalid value for request parameter max_results. It ", e.exception.message)
def test_create_experiment_appends_to_artifact_uri_path_correctly(self): cases = [ ("path/to/local/folder", "path/to/local/folder/{e}"), ("/path/to/local/folder", "/path/to/local/folder/{e}"), ("#path/to/local/folder?", "#path/to/local/folder?/{e}"), ("file:path/to/local/folder", "file:path/to/local/folder/{e}"), ("file:///path/to/local/folder", "file:///path/to/local/folder/{e}"), ("file:path/to/local/folder?param=value", "file:path/to/local/folder/{e}?param=value"), ("file:///path/to/local/folder", "file:///path/to/local/folder/{e}"), ( "file:///path/to/local/folder?param=value#fragment", "file:///path/to/local/folder/{e}?param=value#fragment", ), ("s3://bucket/path/to/root", "s3://bucket/path/to/root/{e}"), ( "s3://bucket/path/to/root?creds=mycreds", "s3://bucket/path/to/root/{e}?creds=mycreds", ), ( "dbscheme+driver://root@host/dbname?creds=mycreds#myfragment", "dbscheme+driver://root@host/dbname/{e}?creds=mycreds#myfragment", ), ( "dbscheme+driver://root:[email protected]?creds=mycreds#myfragment", "dbscheme+driver://root:[email protected]/{e}?creds=mycreds#myfragment", ), ( "dbscheme+driver://root:[email protected]/mydb?creds=mycreds#myfragment", "dbscheme+driver://root:[email protected]/mydb/{e}?creds=mycreds#myfragment", ), ] for artifact_root_uri, expected_artifact_uri_format in cases: with TempDir() as tmp: fs = FileStore(tmp.path(), artifact_root_uri) exp_id = fs.create_experiment("exp") exp = fs.get_experiment(exp_id) self.assertEqual( exp.artifact_location, expected_artifact_uri_format.format(e=exp_id) )
def test_search_runs_pagination(self): fs = FileStore(self.test_root) exp = fs.create_experiment("test_search_runs_pagination") # test returned token behavior runs = sorted([ fs.create_run(exp, 'user', 1000, []).info.run_id for r in range(10) ]) result = fs.search_runs([exp], None, ViewType.ALL, max_results=4) assert [r.info.run_id for r in result] == runs[0:4] assert result.token is not None result = fs.search_runs([exp], None, ViewType.ALL, max_results=4, page_token=result.token) assert [r.info.run_id for r in result] == runs[4:8] assert result.token is not None result = fs.search_runs([exp], None, ViewType.ALL, max_results=4, page_token=result.token) assert [r.info.run_id for r in result] == runs[8:] assert result.token is None
def test_create_duplicate_experiments(self): fs = FileStore(self.test_root) for exp_id in self.experiments: name = self.exp_data[exp_id]["name"] with self.assertRaises(Exception): fs.create_experiment(name)