From ca6bb43406770f8b70141401f5d819dc8f43875e Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Wed, 17 Dec 2025 19:07:08 +0800 Subject: [PATCH] feat: remove path separator normalization for cross-platform compatibility Removed the forced normalization of path separators to forward slashes in BaseModelService to maintain platform-specific separators. Updated test cases to use os.sep for constructing expected paths, ensuring tests work correctly across different operating systems while preserving native path representations. --- py/services/base_model_service.py | 2 -- tests/services/test_relative_path_search.py | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/py/services/base_model_service.py b/py/services/base_model_service.py index 7f1d9bb6..84db592b 100644 --- a/py/services/base_model_service.py +++ b/py/services/base_model_service.py @@ -716,8 +716,6 @@ class BaseModelService(ABC): if normalized_file.startswith(normalized_root): # Remove root and leading separator to get relative path relative_path = normalized_file[len(normalized_root):].lstrip(os.sep) - # Normalize separators so results are stable across platforms - relative_path = relative_path.replace(os.sep, "/") break if not relative_path: diff --git a/tests/services/test_relative_path_search.py b/tests/services/test_relative_path_search.py index e26c98ea..0e10039c 100644 --- a/tests/services/test_relative_path_search.py +++ b/tests/services/test_relative_path_search.py @@ -1,3 +1,4 @@ +import os import pytest from py.services.base_model_service import BaseModelService @@ -42,8 +43,8 @@ async def test_search_relative_paths_supports_multiple_tokens(): matching = await service.search_relative_paths("flux detail") assert matching == [ - "flux/detail-model.safetensors", - "detail/flux-trained.safetensors", + f"flux{os.sep}detail-model.safetensors", + f"detail{os.sep}flux-trained.safetensors", ] @@ -60,4 +61,4 @@ async def test_search_relative_paths_excludes_tokens(): matching = await service.search_relative_paths("flux -detail") - assert matching == ["flux/keep-me.safetensors"] + assert matching == [f"flux{os.sep}keep-me.safetensors"]