Fix error message when adding a local path with quotes around the string

This commit is contained in:
David Hauptman 2024-12-03 15:34:49 -06:00 committed by psychedelicious
parent 174ea021a6
commit 6fc6be3aa0

View File

@ -438,9 +438,10 @@ class ModelInstallService(ModelInstallServiceBase):
variants = "|".join(ModelRepoVariant.__members__.values())
hf_repoid_re = f"^([^/:]+/[^/:]+)(?::({variants})?(?::/?([^:]+))?)?$"
source_obj: Optional[StringLikeSource] = None
source_stripped = source.strip('\"') # Strip possible quotes from source string to avoid later errors with local files or directories
if Path(source).exists(): # A local file or directory
source_obj = LocalModelSource(path=Path(source))
if Path(source_stripped).exists(): # A local file or directory
source_obj = LocalModelSource(path=Path(source_stripped))
elif match := re.match(hf_repoid_re, source):
source_obj = HFModelSource(
repo_id=match.group(1),