Skip to content

Commit

Permalink
Avoid passing a relative path to pkg_resources.resource_filename (#…
Browse files Browse the repository at this point in the history
…4967)

* Avoid using relative path in resource_filename

Signed-off-by: harupy <hkawamura0130@gmail.com>

* Fix _load_version_file_as_dict

Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
  • Loading branch information
harupy committed Nov 1, 2021
1 parent 90a50e9 commit b945297
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mlflow/utils/autologging_utils/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from packaging.version import Version, InvalidVersion
from pkg_resources import resource_filename

import mlflow
from mlflow.utils.databricks_utils import is_in_databricks_runtime


Expand Down Expand Up @@ -45,7 +46,7 @@ def _strip_dev_version_suffix(version):


def _load_version_file_as_dict():
version_file_path = resource_filename(__name__, "../../ml-package-versions.yml")
version_file_path = resource_filename(mlflow.__name__, "ml-package-versions.yml")
with open(version_file_path) as f:
return yaml.load(f, Loader=yaml.SafeLoader)

Expand Down
3 changes: 2 additions & 1 deletion mlflow/utils/requirements_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging
import re

import mlflow
from mlflow.exceptions import MlflowException
from mlflow.tracking.artifact_utils import _download_artifact_from_uri
from mlflow.utils.autologging_utils.versioning import _strip_dev_version_suffix
Expand Down Expand Up @@ -259,7 +260,7 @@ def _capture_imported_modules(model_uri, flavor):


def _load_pypi_package_index():
pypi_index_path = pkg_resources.resource_filename(__name__, "../pypi_package_index.json")
pypi_index_path = pkg_resources.resource_filename(mlflow.__name__, "pypi_package_index.json")
with open(pypi_index_path, "r") as f:
index_dict = json.load(f)

Expand Down

0 comments on commit b945297

Please sign in to comment.