66from models_library .products import ProductName
77from models_library .rest_pagination import (
88 MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE ,
9+ PageMetaInfoLimitOffset ,
910 PageOffsetInt ,
1011)
11- from models_library .rpc .webserver .projects import PageRpcProjectRpcGet
1212from models_library .rpc_pagination import PageLimitInt
1313from models_library .services_enums import ServiceType
1414from models_library .services_history import ServiceRelease
1515from models_library .users import UserID
1616from packaging .version import Version
17+ from simcore_service_api_server .models .schemas .jobs import Job
1718
1819from .models .schemas .solvers import Solver , SolverKeyId
1920from .services_rpc .catalog import CatalogService
@@ -29,10 +30,10 @@ class SolverService:
2930 def __init__ (
3031 self ,
3132 catalog_service : Annotated [CatalogService , Depends ()],
32- wb_api_client : Annotated [WbApiRpcClient , Depends ()],
33+ webserver_client : Annotated [WbApiRpcClient , Depends ()],
3334 ):
3435 self ._catalog_service = catalog_service
35- self ._webserver_client = wb_api_client
36+ self ._webserver_client = webserver_client
3637
3738 async def get_solver (
3839 self ,
@@ -61,6 +62,7 @@ async def get_latest_release(
6162 solver_key : SolverKeyId ,
6263 product_name : str ,
6364 ) -> Solver :
65+ # TODO: Mads, this is not necessary. The first item is the latest!
6466 service_releases : list [ServiceRelease ] = []
6567 for page_params in iter_pagination_params (limit = DEFAULT_PAGINATION_LIMIT ):
6668 releases , page_meta = await self ._catalog_service .list_release_history (
@@ -90,23 +92,32 @@ async def list_jobs(
9092 product_name : ProductName ,
9193 offset : PageOffsetInt = 0 ,
9294 limit : PageLimitInt = DEFAULT_PAGINATION_LIMIT ,
93- ) -> PageRpcProjectRpcGet :
94- """Lists solver jobs for a user with pagination
95-
96- Args:
97- user_id: The ID of the user
98- product_name: The product name
99- offset: Pagination offset
100- limit: Pagination limit
101- job_parent_resource_name_filter: Optional filter for job parent resource name
102-
103- Returns:
104- Paginated response with projects marked as jobs
105- """
106- return await self ._webserver_client .list_projects_marked_as_jobs (
95+ ) -> tuple [list [Job ], PageMetaInfoLimitOffset ]:
96+ """Lists all solver jobs for a user with pagination"""
97+
98+ # NOTE: perhaps we should get comp_tasks instead of projects! or a combinatino of both?
99+ # I need inputs_checksum and job_parent_source_name!
100+
101+ projects_page = await self ._webserver_client .list_projects_marked_as_jobs (
107102 product_name = product_name ,
108103 user_id = user_id ,
109104 offset = offset ,
110105 limit = limit ,
111- job_parent_resource_name_filter = "solvers" , # TODO: use a constant from models_library
106+ job_parent_resource_name_filter = "solvers" , # TODO: project shouldr eturn parent resource name and workbench
112107 )
108+
109+ solver = None # TODO
110+ url_for = None # TODO
111+
112+ jobs : list [Job ] = [
113+ Job (
114+ id = prj .uuid ,
115+ name = prj .name ,
116+ inputs_checksum = prj .inputs_checksum ,
117+ created_at = prj .creation_date , # type: ignore[arg-type]
118+ runner_name = prj .job_parent_resource_name ,
119+ # TODO: url_ parts missing
120+ )
121+ for prj in projects_page .data
122+ ]
123+ return jobs , projects_page .meta
0 commit comments