Невозможно загрузить артефакты с FTP-сервера, используя MLFLOW - PullRequest
0 голосов
/ 20 января 2020

Я не могу загрузить свою модель sklearn, используя mlflow.sklearn.load_model. Внутренне mlflow использует функцию _download_artifact_from_uri из модуля mlflow.tracking.artifact_utils.

. Если я пытаюсь загрузить всю папку с артефактами, я получаю следующее сообщение об ошибке: PermissionError: [Errno 13] Permission denied: '/0'.

Если я пытаюсь извлечь один файл из папки артефактов, я не получаю сообщение об ошибке и могу создать папку с помощью модуля os.

Ниже приводится конвертированная тетрадь Юпитер, которую я использовал.

import os

import mlflow
from mlflow.tracking.artifact_utils import _download_artifact_from_uri
mlflow.set_tracking_uri("file:mlruns")
artifact_uri = 'ftp://user:pass@ftp/0/69a874f1f8a6474cae6bca5b3b5f9ffc/artifacts'
model_uri = 'ftp://user:pass@ftp/0/25f46678f1d44842910f185672ca852c/artifacts/linear model/model/MLmodel'
_download_artifact_from_uri(artifact_uri, "./mlruns")
---------------------------------------------------------------------------

PermissionError                           Traceback (most recent call last)

<ipython-input-14-834201128eef> in <module>
----> 1 _download_artifact_from_uri(artifact_uri, "./mlruns")


/opt/conda/lib/python3.7/site-packages/mlflow/tracking/artifact_utils.py in _download_artifact_from_uri(artifact_uri, output_path)
     73 
     74     return get_artifact_repository(artifact_uri=root_uri).download_artifacts(
---> 75         artifact_path=artifact_path, dst_path=output_path)


/opt/conda/lib/python3.7/site-packages/mlflow/store/artifact/artifact_repo.py in download_artifacts(self, artifact_path, dst_path)
    135         # Check if the artifacts points to a directory
    136         if self._is_directory(artifact_path):
--> 137             return download_artifact_dir(artifact_path)
    138         else:
    139             return download_file(artifact_path)


/opt/conda/lib/python3.7/site-packages/mlflow/store/artifact/artifact_repo.py in download_artifact_dir(dir_path)
    116                 for file_info in dir_content:
    117                     if file_info.is_dir:
--> 118                         download_artifact_dir(dir_path=file_info.path)
    119                     else:
    120                         download_file(file_info.path)


/opt/conda/lib/python3.7/site-packages/mlflow/store/artifact/artifact_repo.py in download_artifact_dir(dir_path)
    116                 for file_info in dir_content:
    117                     if file_info.is_dir:
--> 118                         download_artifact_dir(dir_path=file_info.path)
    119                     else:
    120                         download_file(file_info.path)


/opt/conda/lib/python3.7/site-packages/mlflow/store/artifact/artifact_repo.py in download_artifact_dir(dir_path)
    118                         download_artifact_dir(dir_path=file_info.path)
    119                     else:
--> 120                         download_file(file_info.path)
    121             return local_dir
    122         if not os.path.exists(dst_path):


/opt/conda/lib/python3.7/site-packages/mlflow/store/artifact/artifact_repo.py in download_file(fullpath)
    101             local_file_path = os.path.join(dst_path, fullpath)
    102             if not os.path.exists(local_dir_path):
--> 103                 os.makedirs(local_dir_path)
    104             self._download_file(remote_file_path=fullpath, local_path=local_file_path)
    105             return local_file_path


/opt/conda/lib/python3.7/os.py in makedirs(name, mode, exist_ok)
    209     if head and tail and not path.exists(head):
    210         try:
--> 211             makedirs(head, exist_ok=exist_ok)
    212         except FileExistsError:
    213             # Defeats race condition when another thread created the path


/opt/conda/lib/python3.7/os.py in makedirs(name, mode, exist_ok)
    209     if head and tail and not path.exists(head):
    210         try:
--> 211             makedirs(head, exist_ok=exist_ok)
    212         except FileExistsError:
    213             # Defeats race condition when another thread created the path


/opt/conda/lib/python3.7/os.py in makedirs(name, mode, exist_ok)
    209     if head and tail and not path.exists(head):
    210         try:
--> 211             makedirs(head, exist_ok=exist_ok)
    212         except FileExistsError:
    213             # Defeats race condition when another thread created the path


/opt/conda/lib/python3.7/os.py in makedirs(name, mode, exist_ok)
    209     if head and tail and not path.exists(head):
    210         try:
--> 211             makedirs(head, exist_ok=exist_ok)
    212         except FileExistsError:
    213             # Defeats race condition when another thread created the path


/opt/conda/lib/python3.7/os.py in makedirs(name, mode, exist_ok)
    219             return
    220     try:
--> 221         mkdir(name, mode)
    222     except OSError:
    223         # Cannot rely on checking for EEXIST, since the operating system


PermissionError: [Errno 13] Permission denied: '/0'
_download_artifact_from_uri(model_uri, "./mlruns")
'/home/jovyan/notebooks/mlruns/MLmodel'
os.mkdir("mlruns/0")

...