Experiment with using absolute paths within model management

This commit is contained in:
Brandon Rising 2024-03-07 13:55:10 -05:00 committed by Brandon
parent 66f0ff5b13
commit e52274ecac
4 changed files with 5 additions and 6 deletions

View File

@ -581,9 +581,7 @@ class ModelInstallService(ModelInstallServiceBase):
info = info or ModelProbe.probe(model_path, config)
model_path = model_path.absolute()
if model_path.is_relative_to(self.app_config.models_path):
model_path = model_path.relative_to(self.app_config.models_path)
model_path = model_path.resolve()
info.path = model_path.as_posix()

View File

@ -60,7 +60,7 @@ class ModelLoaderRegistryBase(ABC):
TModelLoader = TypeVar("TModelLoader", bound=ModelLoaderBase)
class ModelLoaderRegistry:
class ModelLoaderRegistry(ModelLoaderRegistryBase):
"""
This class allows model loaders to register their type, base and format.
"""

View File

@ -129,6 +129,8 @@ class ModelProbe(object):
if fields is None:
fields = {}
model_path = model_path.resolve()
format_type = ModelFormat.Diffusers if model_path.is_dir() else ModelFormat.Checkpoint
model_info = None
model_type = None

View File

@ -137,8 +137,7 @@ class ModelSearch(ModelSearchBase):
def search(self, directory: Union[Path, str]) -> Set[Path]:
self._directory = Path(directory)
if not self._directory.is_absolute():
self._directory = self.config.models_path / self._directory
self._directory = self._directory.resolve()
self.stats = SearchStats() # zero out
self.search_started() # This will initialize _models_found to empty
self._walk_directory(self._directory)