Skip to content

Commit

Permalink
feat: mlflow query for run and get eval_df (#911)
Browse files Browse the repository at this point in the history
Small change, hope it's OK with a check for style :-)
  • Loading branch information
MartinBernstorff authored May 15, 2024
2 parents e37e6f1 + ba1932d commit 6632b19
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions psycop/common/global_utils/mlflow/mlflow_data_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def get_config(self) -> Config:
cfg_path = self.download_artifact(artifact_name="config.cfg", save_location=None)
return Config().from_disk(cfg_path)

def eval_df(self) -> pl.DataFrame:
eval_df_path = self.download_artifact(artifact_name="eval_df.parquet", save_location=None)
return pl.read_parquet(eval_df_path)

def download_artifact(self, artifact_name: str, save_location: str | None = None) -> Path:
"""Download an artifact from a run. Returns the path to the downloaded artifact.
If save_location is None, will save to temporary directory"""
Expand Down Expand Up @@ -78,6 +82,10 @@ def get_all_metrics_for_experiment(self, experiment_name: str) -> MlflowAllMetri

return MlflowAllMetricsFrame(frame=metrics_df, allow_extra_columns=False)

def get_run(self, experiment_name: str, run_name: str) -> PsycopMlflowRun:
runs = self._get_mlflow_runs_by_experiment(experiment_name=experiment_name)
return next(run for run in runs if run.info.run_name == run_name)

def get_best_run_from_experiment(
self, experiment_name: str, metric: str, larger_is_better: bool = True
) -> PsycopMlflowRun:
Expand Down

0 comments on commit 6632b19

Please sign in to comment.