From 56a833e02c3abed11cd962814354fad26435e20c Mon Sep 17 00:00:00 2001 From: Andy Ganse Date: Mon, 31 Aug 2026 16:23:36 -0700 Subject: [PATCH 1/3] Fix artifact download to work with S3 and remote stores --- VERSION | 2 +- python/vim_mlflow.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 9084fa2..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1 diff --git a/python/vim_mlflow.py b/python/vim_mlflow.py index 5ababbc..50aea60 100644 --- a/python/vim_mlflow.py +++ b/python/vim_mlflow.py @@ -3,6 +3,7 @@ import json import math import os +from urllib.parse import urlencode from urllib.request import urlopen import mlflow @@ -411,15 +412,17 @@ def walk(nodes, depth): def download_artifact_file(tracking_uri, run_id, artifact_path, target_dir): """Download one artifact file for local viewing.""" - mlflow.set_tracking_uri(tracking_uri) - client = MlflowClient() + if not tracking_uri.startswith(("http://", "https://")): + raise ValueError(f"tracking_uri must be http:// or https://, got: {tracking_uri!r}") os.makedirs(target_dir, exist_ok=True) - with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr( - io.StringIO() - ): - local_path = client.download_artifacts( - run_id, artifact_path, dst_path=target_dir - ) + params = urlencode({"run_uuid": run_id, "path": artifact_path}) + url = f"{tracking_uri.rstrip('/')}/get-artifact?{params}" + local_path = os.path.join(target_dir, run_id, *artifact_path.split("/")) + os.makedirs(os.path.dirname(local_path), exist_ok=True) + with urlopen(url) as response: + content = response.read() + with open(local_path, "wb") as f: + f.write(content) if os.path.isdir(local_path): raise IsADirectoryError(f"{artifact_path} is a directory") return local_path From 9b73950168578cc30e65bb618c0e3bda87bbbef7 Mon Sep 17 00:00:00 2001 From: Andy Ganse Date: Mon, 31 Aug 2026 18:52:29 -0700 Subject: [PATCH 2/3] Fix artifact listing to work with S3 and remote stores --- VERSION | 2 +- python/vim_mlflow.py | 26 ++++++++++++++------------ python/vim_mlflow_cache.py | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/VERSION b/VERSION index 524cb55..45a1b3f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.1 +1.1.2 diff --git a/python/vim_mlflow.py b/python/vim_mlflow.py index 50aea60..e3d348e 100644 --- a/python/vim_mlflow.py +++ b/python/vim_mlflow.py @@ -317,27 +317,29 @@ def _downsample_points(points, target_len): return downsampled -def _collect_artifacts(client, run_id, path="", depth=0, max_depth=50): +def _collect_artifacts(tracking_uri, run_id, path="", depth=0, max_depth=50): """Collect an artifact tree for one run up to the requested depth.""" nodes = [] try: - actual_path = path or None - if actual_path is None: - artifacts = client.list_artifacts(run_id) - else: - artifacts = client.list_artifacts(run_id, actual_path) + params = {"run_id": run_id} + if path: + params["path"] = path + url = f"{tracking_uri.rstrip('/')}/api/2.0/mlflow/artifacts/list?{urlencode(params)}" + with urlopen(url) as response: + data = json.loads(response.read()) + artifacts = data.get("files", []) except Exception: return nodes - for item in sorted(artifacts, key=lambda a: a.path): + for item in sorted(artifacts, key=lambda a: a["path"]): node = { - "path": item.path, - "name": item.path.rsplit("/", 1)[-1], - "is_dir": item.is_dir, + "path": item["path"], + "name": item["path"].rsplit("/", 1)[-1], + "is_dir": item.get("is_dir", False), "children": [], } - if item.is_dir and depth < max_depth: + if item.get("is_dir") and depth < max_depth: node["children"] = _collect_artifacts( - client, run_id, item.path, depth + 1, max_depth + tracking_uri, run_id, item["path"], depth + 1, max_depth ) nodes.append(node) return nodes diff --git a/python/vim_mlflow_cache.py b/python/vim_mlflow_cache.py index e206916..39000a9 100644 --- a/python/vim_mlflow_cache.py +++ b/python/vim_mlflow_cache.py @@ -266,7 +266,7 @@ def get_artifact_tree( self.artifacts_by_run.pop(key, None) if key not in self.artifacts_by_run: self.artifacts_by_run[key] = collector( - self.client, str(run_id), max_depth=int(max_depth) + self.tracking_uri, str(run_id), max_depth=int(max_depth) ) return self.artifacts_by_run[key] From 02b7a7fae17028d257737d15b2035e4fef13fcbd Mon Sep 17 00:00:00 2001 From: Andy Ganse Date: Mon, 31 Aug 2026 18:58:47 -0700 Subject: [PATCH 3/3] Cleanup unused imports and flake8 workflow failure --- .github/workflows/codestyle-python-flake8.yml | 4 ++-- python/vim_mlflow.py | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codestyle-python-flake8.yml b/.github/workflows/codestyle-python-flake8.yml index f9a2dd8..86f6ae0 100644 --- a/.github/workflows/codestyle-python-flake8.yml +++ b/.github/workflows/codestyle-python-flake8.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.11" - - name: Install dependencies - run: pip install -r dev-requirements.txt + - name: Install Flake8 + run: pip install flake8 - name: Run Flake8 run: flake8 python tests/python tests/fixtures diff --git a/python/vim_mlflow.py b/python/vim_mlflow.py index e3d348e..df1ca86 100644 --- a/python/vim_mlflow.py +++ b/python/vim_mlflow.py @@ -1,15 +1,11 @@ -import contextlib -import io import json import math import os from urllib.parse import urlencode from urllib.request import urlopen -import mlflow import vim from mlflow.entities import ViewType -from mlflow.tracking import MlflowClient from vim_mlflow_cache import get_session