Skip to content

Commit

Permalink
perf: exception capture when the existed experiment name is used to c…
Browse files Browse the repository at this point in the history
…reate new experiment.
  • Loading branch information
SanyHe committed Jul 10, 2023
1 parent e8201f6 commit 5c795bf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion geochemistrypi/data_mining/cli_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,24 @@ def cli_pipeline(file_name: str) -> None:
else:
new_experiment_name = Prompt.ask("✨ New Experiment", default="GeoPi - Rock Classification")
new_experiment_tag = Prompt.ask("✨ Experiment Tag Version", default="E - v1.0.0")
new_experiment_id = mlflow.create_experiment(name=new_experiment_name, artifact_location=artifact_localtion, tags={"version": new_experiment_tag})
try:
new_experiment_id = mlflow.create_experiment(name=new_experiment_name, artifact_location=artifact_localtion, tags={"version": new_experiment_tag})
except mlflow.exceptions.MlflowException as e:
if "already exists" in str(e):
console.print(" The experiment name already exists.", style="bold red")
console.print(" Use the existing experiment.", style="bold red")
console.print(f" '{new_experiment_name}' is activated.", style="bold red")
new_experiment_id = mlflow.get_experiment_by_name(name=new_experiment_name).experiment_id
else:
raise e
experiment = mlflow.get_experiment(experiment_id=new_experiment_id)
# print("Artifact Location: {}".format(experiment.artifact_location))

run_name = Prompt.ask("✨ Run Name", default="Xgboost Algorithm")
run_tag = Prompt.ask("✨ Run Tag Version", default="R - v1.0.0")
run_description = Prompt.ask("✨ Run Description", default="Use xgboost for GeoPi classification.")
mlflow.start_run(run_name=run_name, experiment_id=experiment.experiment_id, tags={"version": run_tag, "description": run_description})
clear_output()

# Data Loading
logger.debug("User Data Uploaded")
Expand Down

0 comments on commit 5c795bf

Please sign in to comment.