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",
operation_id="list_model_install_jobs",
)
async def list_model_install_jobs(
source: Optional[str] = Query(
description="Filter list by install source, partial string match.",
default=None,
),
) -> List[ModelInstallJob]:
async def list_model_install_jobs() -> List[ModelInstallJob]:
"""
Return list of model install jobs.
If the optional 'source' argument is provided, then the list will be filtered
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

View File

@ -277,11 +277,9 @@ class ModelInstallServiceBase(ABC):
"""Return the ModelInstallJob(s) corresponding to the provided source."""
@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.
:param source: Filter by jobs whose sources are a partial match to the argument.
"""
@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.
raise UnknownModelException("File or directory not found")
def list_jobs(self, source: Optional[ModelSource | str] = None) -> List[ModelInstallJob]: # noqa D102
jobs = self._install_jobs
if not source:
return jobs
else:
return [x for x in jobs if str(source) in str(x)]
def list_jobs(self) -> List[ModelInstallJob]: # noqa D102
return self._install_jobs
def get_job(self, source: ModelSource) -> List[ModelInstallJob]: # noqa D102
return [x for x in self._install_jobs if x.source == source]