gpt4 book ai didi

python - 如何 "Permanently"删除Mlflow中的实验?

转载 作者:行者123 更新时间:2023-12-02 02:37:18 28 4
gpt4 key购买 nike

任何地方都没有记录永久删除实验。我正在使用 Mlflow 和后端 postgres db

这是我运行的内容:

client = MlflowClient(tracking_uri=server)
client.delete_experiment(1)

这会删除实验,但是当我运行与刚刚删除的实验同名的新实验时,它将返回此错误:

mlflow.exceptions.MlflowException: Cannot set a deleted experiment 'cross-sell' as the active experiment. You can restore the experiment, or permanently delete the  experiment to create a new one.

我在文档中找不到任何显示如何永久删除所有内容的地方。

最佳答案

不幸的是,目前似乎无法通过 UI 或 CLI 执行此操作:-/

执行此操作的方法取决于您使用的后端文件存储的类型。

文件存储:

如果您使用文件系统作为存储机制(默认),那么这很容易。 “已删除”实验将移至 .trash 文件夹。您只需要清除它即可:

rm -rf mlruns/.trash/*

截至 documentation 的当前版本(1.7.2),他们评论道:

It is recommended to use a cron job or an alternate workflow mechanism to clear .trash folder.

SQL 数据库:

这比较棘手,因为需要删除一些依赖项。我正在使用 MySQL,这些命令对我有用:

USE mlflow_db;  # the name of your database
DELETE FROM experiment_tags WHERE experiment_id=ANY(
SELECT experiment_id FROM experiments where lifecycle_stage="deleted"
);
DELETE FROM latest_metrics WHERE run_uuid=ANY(
SELECT run_uuid FROM runs WHERE experiment_id=ANY(
SELECT experiment_id FROM experiments where lifecycle_stage="deleted"
)
);
DELETE FROM metrics WHERE run_uuid=ANY(
SELECT run_uuid FROM runs WHERE experiment_id=ANY(
SELECT experiment_id FROM experiments where lifecycle_stage="deleted"
)
);
DELETE FROM tags WHERE run_uuid=ANY(
SELECT run_uuid FROM runs WHERE experiment_id=ANY(
SELECT experiment_id FROM experiments where lifecycle_stage="deleted"
)
);
DELETE FROM runs WHERE experiment_id=ANY(
SELECT experiment_id FROM experiments where lifecycle_stage="deleted"
);
DELETE FROM experiments where lifecycle_stage="deleted";

关于python - 如何 "Permanently"删除Mlflow中的实验?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60088889/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com