Skip to content

Commit

Permalink
Issue #190: export-experiment: change CLI option run-ids-file to run-…
Browse files Browse the repository at this point in the history
…ids (comma seperated)
  • Loading branch information
amesar committed Jul 15, 2024
1 parent 6ac63cd commit 287e39c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions mlflow_export_import/common/click_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def opt_export_version_model(function):
)(function)
return function

def opt_run_ids_file(function):
function = click.option("--run-ids-file",
help="File with run IDs to export.",
def opt_run_ids(function):
function = click.option("--run-ids",
help="List of run IDs to export (comma seperated).",
type=str,
required=False
)(function)
Expand Down
17 changes: 7 additions & 10 deletions mlflow_export_import/experiment/export_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mlflow_export_import.common.click_options import (
opt_experiment,
opt_output_dir,
opt_run_ids_file,
opt_run_ids,
opt_notebook_formats,
opt_export_permissions,
opt_run_start_time,
Expand Down Expand Up @@ -62,7 +62,7 @@ def export_experiment(
failed_run_ids = []
num_runs_exported = 0
if run_ids:
for j,run_id in enumerate(run_ids):
for _,run_id in enumerate(run_ids):
_export_run(mlflow_client, run_id, exp.experiment_id, output_dir, ok_run_ids, failed_run_ids,
run_start_time, run_start_time_str, export_deleted_runs, notebook_formats)
num_runs_exported += 1
Expand All @@ -73,7 +73,7 @@ def export_experiment(
if export_deleted_runs:
from mlflow.entities import ViewType
kwargs["view_type"] = ViewType.ALL
for j,run in enumerate(SearchRunsIterator(mlflow_client, exp.experiment_id, **kwargs)):
for _,run in enumerate(SearchRunsIterator(mlflow_client, exp.experiment_id, **kwargs)):
_export_run(mlflow_client, run, exp.experiment_id, output_dir, ok_run_ids, failed_run_ids,
run_start_time, run_start_time_str, export_deleted_runs, notebook_formats)
num_runs_exported += 1
Expand Down Expand Up @@ -147,22 +147,19 @@ def _export_run(mlflow_client, run_or_run_id, experiment_id, output_dir,
@click.command()
@opt_experiment
@opt_output_dir
@opt_run_ids_file
@opt_run_ids
@opt_export_permissions
@opt_run_start_time
@opt_export_deleted_runs
@opt_notebook_formats

def main(experiment, output_dir, run_ids_file, export_permissions, run_start_time, export_deleted_runs, notebook_formats):
def main(experiment, output_dir, run_ids, export_permissions, run_start_time, export_deleted_runs, notebook_formats):
_logger.info("Options:")
for k,v in locals().items():
_logger.info(f" {k}: {v}")

if run_ids_file:
with open(run_ids_file, "r", encoding="utf-8") as f:
run_ids = [ line.rstrip() for line in f ]
else:
run_ids = None
if run_ids:
run_ids = run_ids.split(",")

export_experiment(
experiment_id_or_name = experiment,
Expand Down

0 comments on commit 287e39c

Please sign in to comment.