remove source filtering from list_models()

This commit is contained in:
Lincoln Stein
2023-12-06 22:23:08 -05:00
parent 3bfaee9c57
commit 6e1e67aa72
3 changed files with 5 additions and 16 deletions

View File

@ -271,19 +271,14 @@ async def import_model(
"/import", "/import",
operation_id="list_model_install_jobs", operation_id="list_model_install_jobs",
) )
async def list_model_install_jobs( async def list_model_install_jobs() -> List[ModelInstallJob]:
source: Optional[str] = Query(
description="Filter list by install source, partial string match.",
default=None,
),
) -> List[ModelInstallJob]:
""" """
Return list of model install jobs. Return list of model install jobs.
If the optional 'source' argument is provided, then the list will be filtered If the optional 'source' argument is provided, then the list will be filtered
for partial string matches against the install source. for partial string matches against the install source.
""" """
jobs: List[ModelInstallJob] = ApiDependencies.invoker.services.model_install.list_jobs(source) jobs: List[ModelInstallJob] = ApiDependencies.invoker.services.model_install.list_jobs()
return jobs return jobs

View File

@ -277,11 +277,9 @@ class ModelInstallServiceBase(ABC):
"""Return the ModelInstallJob(s) corresponding to the provided source.""" """Return the ModelInstallJob(s) corresponding to the provided source."""
@abstractmethod @abstractmethod
def list_jobs(self, source: Optional[ModelSource | str] = None) -> List[ModelInstallJob]: # noqa D102 def list_jobs(self) -> List[ModelInstallJob]: # noqa D102
""" """
List active and complete install jobs. List active and complete install jobs.
:param source: Filter by jobs whose sources are a partial match to the argument.
""" """
@abstractmethod @abstractmethod

View File

@ -199,12 +199,8 @@ class ModelInstallService(ModelInstallServiceBase):
else: # here is where we'd download a URL or repo_id. Implementation pending download queue. else: # here is where we'd download a URL or repo_id. Implementation pending download queue.
raise UnknownModelException("File or directory not found") raise UnknownModelException("File or directory not found")
def list_jobs(self, source: Optional[ModelSource | str] = None) -> List[ModelInstallJob]: # noqa D102 def list_jobs(self) -> List[ModelInstallJob]: # noqa D102
jobs = self._install_jobs return self._install_jobs
if not source:
return jobs
else:
return [x for x in jobs if str(source) in str(x)]
def get_job(self, source: ModelSource) -> List[ModelInstallJob]: # noqa D102 def get_job(self, source: ModelSource) -> List[ModelInstallJob]: # noqa D102
return [x for x in self._install_jobs if x.source == source] return [x for x in self._install_jobs if x.source == source]