对服务模型使用set MLFLOW_TRACKING_URI ='http://0.0.0.0:5000'时出错

问题描述

嗨,我需要运行这样的命令

mlflow server --backend-store-uri postgresql://mlflow_user:mlflow@localhost:5433/mlflow --default-artifact-root file:D:/artifact_root --host 0.0.0.0 --port 5000

开始我的服务,我对此没有问题,但是当我尝试运行一个例子时 在从github python开发项目的路线中

mlflow/examples/sklearn_elasticnet_diabetes/linux/train_diabetes.py 0.1 0.9 

我收到此错误

  _model_registry_store_registry.register_entrypoints()
Elasticnet model (alpha=0.100000,l1_ratio=0.900000):
  RMSE: 71.98302888908191
  MAE: 60.5647520017933
  R2: 0.21655161434654602
<function get_tracking_uri at 0x0000017F3AE885E8>
url 'http://0.0.0.0:8001'
url2 'http|//0.0.0.0|8001'
Traceback (most recent call last):
  File "train_diabetes.py",line 90,in <module>
    mlflow.log_param("alpha",alpha)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\fluent.py",line 210,in log_param
    run_id = _get_or_start_run().info.run_id
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\fluent.py",line 508,in _get_or_start_run
    return start_run()
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\fluent.py",line 148,in start_run
    active_run_obj = MlflowClient().create_run(
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\client.py",line 44,in __init__
    self._tracking_client = TrackingServiceClient(final_tracking_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\client.py",line 32,in __init__       
    self.store = utils._get_store(self.tracking_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\utils.py",line 126,in _get_store     
    return _tracking_store_registry.get_store(store_uri,artifact_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\registry.py",line 37,in get_store    
    return builder(store_uri=store_uri,artifact_uri=artifact_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\utils.py",line 81,in _get_file_store 
    return FileStore(store_uri,store_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\store\tracking\file_store.py",line 100,in __init__
    self.root_directory = local_file_uri_to_path(root_directory or _default_root_dir())
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\utils\file_utils.py",line 387,in local_file_uri_to_path
    return urllib.request.url2pathname(path)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\nturl2path.py",line 35,in url2pathname
    raise OSError(error)
OSError: Bad URL: 'http|//0.0.0.0|8001'

在运行python代码之前,我运行此命令来为执行集MLFLOW_TRACKING_URI ='http://0.0.0.0:5000'设置环境跟踪uri

我不知道为什么mlflow替换:为|我需要帮助。在此选项生效之前,但现在失败了

解决方法

这看起来很奇怪,因为如果将MLFLOW_TRACKING_URI设置为http://0.0.0.0:5000,则应使用RestStore,但是您的堆栈跟踪将显示FileStore。您可以运行下面的代码,看看打印出来的内容吗?

from urllib.parse import urlparse
urlparse('http://0.0.0.0:5000')
,

此错误

$ python train_diabetes.py 0.1 0.9
C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_model_registry\utils.py:106: UserWarning: Failure attempting to register store for scheme "file-plugin": No module named 'mlflow_test_plugin.sqlalchemy_store'
  _model_registry_store_registry.register_entrypoints()
Elasticnet model (alpha=0.100000,l1_ratio=0.900000):
  RMSE: 71.98302888908191
  MAE: 60.5647520017933
  R2: 0.21655161434654602
Traceback (most recent call last):
  File "train_diabetes.py",line 88,in <module>
    mlflow.log_param("alpha",alpha)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\fluent.py",line 218,in log_param
    run_id = _get_or_start_run().info.run_id
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\fluent.py",line 573,in _get_or_start_run
    return start_run()
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\fluent.py",line 159,in start_run
    active_run_obj = MlflowClient().create_run(experiment_id=exp_id_for_run,tags=tags)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\client.py",line 54,in __init__
    self._tracking_client = TrackingServiceClient(final_tracking_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\client.py",line 39,in __init__
    self.store = utils._get_store(self.tracking_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\utils.py",line 127,in _get_store
    return _tracking_store_registry.get_store(store_uri,artifact_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\registry.py",line 38,in get_store
    return builder(store_uri=store_uri,artifact_uri=artifact_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\_tracking_service\utils.py",line 81,in _get_file_store
    return FileStore(store_uri,store_uri)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\store\tracking\file_store.py",line 132,in __init__
    self.root_directory = local_file_uri_to_path(root_directory or _default_root_dir())
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\utils\file_utils.py",line 390,in local_file_uri_to_path
    return urllib.request.url2pathname(path)
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\nturl2path.py",line 33,in url2pathname
    raise OSError(error)
OSError: Bad URL: 'http|//0.0.0.0|5000'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tensorflow.py",line 577,in _flush_queue
    client = mlflow.tracking.MlflowClient()
  File "C:\Users\kevin.sanchez\Miniconda3\envs\env_mlflow\lib\site-packages\mlflow\tracking\client.py",in url2pathname
    raise OSError(error)
OSError: Bad URL: 'http|//0.0.0.0|5000'