Skip to content
Snippets Groups Projects
Commit 77aca6fd authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Catch discrepancy in UNIX v. Windows-style paths

parent a44e8a96
No related branches found
No related tags found
No related merge requests found
import logging
import os
from pathlib import Path
from pathlib import Path, PureWindowsPath
from pydantic import BaseModel
from time import strftime, localtime
from typing import Union
......@@ -183,7 +183,7 @@ class Session(object, metaclass=Singleton):
models = self.describe_loaded_models()
for mid, det in models.items():
if is_path:
if Path(det.get('params').get(key)) == Path(value):
if PureWindowsPath(det.get('params').get(key)).as_posix() == Path(value).as_posix():
return mid
else:
if det.get('params').get(key) == value:
......
import json
from os.path import exists
import pathlib
from pydantic import BaseModel
......@@ -6,7 +5,6 @@ import unittest
from model_server.base.models import DummySemanticSegmentationModel
from model_server.base.session import Session
from model_server.base.workflows import WorkflowRunRecord
class TestGetSessionObject(unittest.TestCase):
def setUp(self) -> None:
......@@ -117,11 +115,11 @@ class TestGetSessionObject(unittest.TestCase):
class _PM(BaseModel):
path: str
p1 = _PM(path='c:\\windows\\dummy.pa')
p2 = _PM(path='c:/windows/dummy.pa')
mid = self.sesh.load_model(MC, params=p1)
assert pathlib.Path(p1.path) == pathlib.Path(p2.path)
find_mid = self.sesh.find_param_in_loaded_models('path', p2.path, is_path=True)
mod_pw = _PM(path='c:\\windows\\dummy.pa')
mod_pu = _PM(path='c:/windows/dummy.pa')
mid = self.sesh.load_model(MC, params=mod_pw)
find_mid = self.sesh.find_param_in_loaded_models('path', mod_pu.path, is_path=True)
self.assertEqual(mid, find_mid)
def test_change_output_path(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment