如何在没有服务器的情况下将 mlflow 指标和参数保存到 s3 存储桶?

Bea*_*oes 5 python amazon-s3 amazon-sagemaker mlflow

我想将从 mlflow 获取的参数和指标保存到 s3 存储桶中。通常我通过设置tracking_uriin mlflow 来获取这些并将其保存在服务器上,但在这种情况下我不能拥有服务器(被告知不行),只想以与以下相同的方式将我的参数和指标存储在 s3 存储桶上它将使用tracking_uri.

我可以毫无问题地将工件存储在 s3 存储桶上,但不能存储参数/指标。

这是一些代码:

def mlflow_testing():
    
    tracking_uri =  "s3://bucket_name/mlflow/",
    experiment_name = "test",
    artifact_uri= "s3://bucket_name/mlflow/"
    
    mlflow.set_tracking_uri(tracking_uri)
    mlflow.create_experiment(experiment_name, artifact_uri)
    mlflow.set_experiment(experiment_name)
    
    with mlflow.start_run() as run:
        mlflow.log_param("test1", 0)
        mlflow.log_metric("test2", 1)
    
        with open("test.txt", "w") as f:
            f.write("this is an artifact")
    
        mlflow.log_artifact("test.txt")
        mlflow.end_run()
Run Code Online (Sandbox Code Playgroud)

这能够将工件文本文件存储在 s3 存储桶上(只要我将 uri 设置为本地路径,而local_data/mlflow不是 s3 存储桶)。

设置 s3 存储桶会导致tracking_uri此错误:

mlflow.tracking.registry.UnsupportedModelRegistryStoreURIException:
Model registry functionality is unavailable; got unsupported URI
's3://bucket_location/mlflow/' for model registry data storage.
Supported URI schemes are: ['', 'file', 'databricks', 'http', 'https',
'postgresql', 'mysql', 'sqlite', 'mssql']. See
https://www.mlflow.org/docs/latest/tracking.html#storage for how to
run an MLflow server against one of the supported backend storage
locations.
Run Code Online (Sandbox Code Playgroud)

有人建议在不设置服务器的情况下解决这个问题吗?我只想要这些指标和参数。

小智 3

S3 不是 MLFlow 指标和参数支持的后端。它是工件受支持的后端。 https://www.mlflow.org/docs/latest/tracking.html#where-runs-are-recorded

如果您愿意,您可以在本地编写指标/参数,然后按计划将其上传到 S3 作为备份。