Skip to content

Commit c5779bf

Browse files
committed
Resturcture the files
Signed-off-by: ppadti <ppadti@redhat.com>
1 parent 6da3e38 commit c5779bf

23 files changed

Lines changed: 474 additions & 277 deletions

clients/ui/api/openapi/mod-arch.yaml

Lines changed: 130 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -10,119 +10,6 @@ servers:
1010
- url: "https://localhost:8080"
1111
- url: "http://localhost:8080"
1212
paths:
13-
/api/v1/settings/model_catalog/source_configs:
14-
summary: Path used to managae Model catalog sources.
15-
description: The REST endpoint/path used to list and create model catalog sources.
16-
get:
17-
tags:
18-
- K8SOperation
19-
parameters:
20-
- $ref: "#/components/parameters/kubeflowUserId"
21-
responses:
22-
"200":
23-
$ref: "#/components/responses/CatalogSourceConfigListResponse"
24-
"401":
25-
$ref: "#/components/responses/Unauthorized"
26-
"500":
27-
$ref: "#/components/responses/InternalServerError"
28-
operationId: getCatalogSources
29-
summary: List ALL the catalog sources.
30-
description: Gets a list of all catalog sources.
31-
post:
32-
requestBody:
33-
description: A new catalog source to be created, potentially including credentials/yaml.
34-
content:
35-
application/json:
36-
schema:
37-
$ref: "#/components/schemas/CatalogSourceConfigPayload"
38-
required: true
39-
tags:
40-
- K8SOperation
41-
parameters:
42-
- $ref: "#/components/parameters/kubeflowUserId"
43-
responses:
44-
"201":
45-
$ref: "#/components/responses/CatalogSourceConfigResponse"
46-
"400":
47-
$ref: "#/components/responses/BadRequest"
48-
"401":
49-
$ref: "#/components/responses/Unauthorized"
50-
"500":
51-
$ref: "#/components/responses/InternalServerError"
52-
operationId: createCatalogSource
53-
summary: Create Catalog source
54-
description: Creates a new model catalog source.
55-
/api/v1/settings/model_catalog/source_configs/{sourceId}:
56-
summary: Path used to manage Model catalog sources.
57-
description: >-
58-
The REST endpoint/path used to get, update and delete a single ModelCatalog Source.
59-
# Add GET operation
60-
get:
61-
tags:
62-
- K8SOperation
63-
parameters:
64-
- $ref: "#/components/parameters/kubeflowUserId"
65-
- $ref: "#/components/parameters/sourceId" # Use the correct parameter name
66-
responses:
67-
"200":
68-
$ref: "#/components/responses/CatalogSourceConfigResponse"
69-
"401":
70-
$ref: "#/components/responses/Unauthorized"
71-
"404":
72-
$ref: "#/components/responses/NotFound"
73-
"500":
74-
$ref: "#/components/responses/InternalServerError"
75-
operationId: getCatalogSource
76-
summary: Get Model Catalog Source
77-
description: Gets the details of a single Model Catalog source potentially including related credentials.
78-
patch:
79-
requestBody:
80-
description: Updated Model Catalog Source information.
81-
content:
82-
application/json:
83-
schema:
84-
$ref: "#/components/schemas/CatalogSourceConfigPayload"
85-
required: true
86-
tags:
87-
- K8SOperation
88-
parameters:
89-
- $ref: "#/components/parameters/kubeflowUserId"
90-
- $ref: "#/components/parameters/sourceId"
91-
responses:
92-
"200":
93-
$ref: "#/components/responses/CatalogSourceConfigResponse"
94-
"400":
95-
$ref: "#/components/responses/BadRequest"
96-
"401":
97-
$ref: "#/components/responses/Unauthorized"
98-
"404":
99-
$ref: "#/components/responses/NotFound"
100-
"500":
101-
$ref: "#/components/responses/InternalServerError"
102-
operationId: updateModelCatalogSource
103-
summary: Update Model Catalog Sources
104-
description: Updates an existing Model Catalog source.
105-
delete:
106-
tags:
107-
- K8SOperation
108-
parameters:
109-
- $ref: "#/components/parameters/kubeflowUserId"
110-
- $ref: "#/components/parameters/sourceId"
111-
responses:
112-
"204":
113-
description: Successfully deleted
114-
"400":
115-
$ref: "#/components/responses/BadRequest"
116-
"401":
117-
$ref: "#/components/responses/Unauthorized"
118-
"404":
119-
$ref: "#/components/responses/NotFound"
120-
"500":
121-
$ref: "#/components/responses/InternalServerError"
122-
operationId: deleteModelCatalogSource
123-
summary: Delete Model Catalog source
124-
description: Deletes an existing Model Catalog Source.
125-
12613
/healthcheck:
12714
summary: Path targeted for healthcheck purposes.
12815
description: >-
@@ -962,6 +849,120 @@ paths:
962849
$ref: "#/components/responses/InternalServerError"
963850
operationId: getAllModelArtifacts
964851

852+
# Model catalog settings endpoints
853+
/api/v1/settings/model_catalog/source_configs:
854+
summary: Path used to managae Model catalog sources.
855+
description: The REST endpoint/path used to list and create model catalog sources.
856+
get:
857+
tags:
858+
- K8SOperation
859+
parameters:
860+
- $ref: "#/components/parameters/kubeflowUserId"
861+
responses:
862+
"200":
863+
$ref: "#/components/responses/CatalogSourceConfigListResponse"
864+
"401":
865+
$ref: "#/components/responses/Unauthorized"
866+
"500":
867+
$ref: "#/components/responses/InternalServerError"
868+
operationId: getCatalogSources
869+
summary: List ALL the catalog sources.
870+
description: Gets a list of all catalog sources.
871+
post:
872+
requestBody:
873+
description: A new catalog source to be created, potentially including credentials/yaml.
874+
content:
875+
application/json:
876+
schema:
877+
$ref: "#/components/schemas/CatalogSourceConfigPayload"
878+
required: true
879+
tags:
880+
- K8SOperation
881+
parameters:
882+
- $ref: "#/components/parameters/kubeflowUserId"
883+
responses:
884+
"201":
885+
$ref: "#/components/responses/CatalogSourceConfigResponse"
886+
"400":
887+
$ref: "#/components/responses/BadRequest"
888+
"401":
889+
$ref: "#/components/responses/Unauthorized"
890+
"500":
891+
$ref: "#/components/responses/InternalServerError"
892+
operationId: createCatalogSource
893+
summary: Create a Catalog source
894+
description: Creates a new model catalog source.
895+
/api/v1/settings/model_catalog/source_configs/{sourceId}:
896+
summary: Path used to manage Model catalog sources.
897+
description: >-
898+
The REST endpoint/path used to get, update and delete a single ModelCatalog Source.
899+
# Add GET operation
900+
get:
901+
tags:
902+
- K8SOperation
903+
parameters:
904+
- $ref: "#/components/parameters/kubeflowUserId"
905+
- $ref: "#/components/parameters/sourceId" # Use the correct parameter name
906+
responses:
907+
"200":
908+
$ref: "#/components/responses/CatalogSourceConfigResponse"
909+
"401":
910+
$ref: "#/components/responses/Unauthorized"
911+
"404":
912+
$ref: "#/components/responses/NotFound"
913+
"500":
914+
$ref: "#/components/responses/InternalServerError"
915+
operationId: getCatalogSource
916+
summary: Get a Model Catalog Source
917+
description: Gets the details of a single Model Catalog source potentially including related credentials.
918+
patch:
919+
requestBody:
920+
description: Updated Model Catalog Source information.
921+
content:
922+
application/json:
923+
schema:
924+
$ref: "#/components/schemas/CatalogSourceConfigPayload"
925+
required: true
926+
tags:
927+
- K8SOperation
928+
parameters:
929+
- $ref: "#/components/parameters/kubeflowUserId"
930+
- $ref: "#/components/parameters/sourceId"
931+
responses:
932+
"200":
933+
$ref: "#/components/responses/CatalogSourceConfigResponse"
934+
"400":
935+
$ref: "#/components/responses/BadRequest"
936+
"401":
937+
$ref: "#/components/responses/Unauthorized"
938+
"404":
939+
$ref: "#/components/responses/NotFound"
940+
"500":
941+
$ref: "#/components/responses/InternalServerError"
942+
operationId: updateModelCatalogSource
943+
summary: Update a Model Catalog Sources
944+
description: Updates an existing Model Catalog source.
945+
delete:
946+
tags:
947+
- K8SOperation
948+
parameters:
949+
- $ref: "#/components/parameters/kubeflowUserId"
950+
- $ref: "#/components/parameters/sourceId"
951+
responses:
952+
"204":
953+
description: Successfully deleted
954+
"400":
955+
$ref: "#/components/responses/BadRequest"
956+
"401":
957+
$ref: "#/components/responses/Unauthorized"
958+
"404":
959+
$ref: "#/components/responses/NotFound"
960+
"500":
961+
$ref: "#/components/responses/InternalServerError"
962+
operationId: deleteModelCatalogSource
963+
summary: Delete a Model Catalog source
964+
description: Deletes an existing Model Catalog Source.
965+
965966
components:
966967
schemas:
967968
Config:
@@ -2190,27 +2191,30 @@ components:
21902191
type: array
21912192
items:
21922193
type: string
2193-
includedModels:
2194-
type: array
2195-
items:
2196-
type: string
2197-
example: rhelai1/modelcar-granite-7b-starter
2198-
excludedModels:
2199-
type: array
2200-
items:
2201-
type: string
2202-
example: model-a:1.0
2203-
description: list of models name, that will be excluded.
2194+
isDefault:
2195+
type: boolean
2196+
example: true
22042197
properties:
22052198
type: object
22062199
properties:
22072200
yamlCatalogPath:
22082201
type: string
22092202
example: sample-catalog.yaml
2210-
accessToken:
2203+
apiKey:
22112204
type: string
22122205
description: HuggingFace access token - should be stored in a Kubernetes secret and referenced here, or set via environment variable
2213-
example: "accessToken"
2206+
example: "apiKey"
2207+
includedModels:
2208+
type: array
2209+
items:
2210+
type: string
2211+
example: rhelai1/modelcar-granite-7b-starter
2212+
excludedModels:
2213+
type: array
2214+
items:
2215+
type: string
2216+
example: model-a:1.0
2217+
description: list of models name, that will be excluded.
22142218
allowedOrganization:
22152219
type: string
22162220
description: name of the organization that need to ingest from the source.

clients/ui/bff/internal/api/app.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,23 @@ func NewApp(cfg config.EnvConfig, logger *slog.Logger) (*App, error) {
177177
return nil, fmt.Errorf("failed to create ModelRegistry Catalog client: %w", err)
178178
}
179179

180+
var modelCatalogSettingsRepository repositories.ModelCatalogSettingsRepositoryInterface
181+
182+
if cfg.MockK8Client {
183+
modelCatalogSettingsRepository, err = mocks.NewModelCatalogSettingsRepository(logger)
184+
} else {
185+
modelCatalogSettingsRepository, err = repositories.NewModelCatalogSettingsRepository(logger)
186+
}
187+
188+
if err != nil {
189+
return nil, fmt.Errorf("failed to create ModelCatalogSettings client: %w", err)
190+
}
191+
180192
app := &App{
181193
config: cfg,
182194
logger: logger,
183195
kubernetesClientFactory: k8sFactory,
184-
repositories: repositories.NewRepositories(mrClient, modelCatalogClient),
196+
repositories: repositories.NewRepositories(mrClient, modelCatalogClient, modelCatalogSettingsRepository),
185197
testEnv: testEnv,
186198
rootCAs: rootCAs,
187199
}
@@ -230,7 +242,7 @@ func (app *App) Routes() http.Handler {
230242
apiRouter.GET(CatalogSourceListPath, app.AttachNamespace(app.AttachModelCatalogRESTClient(app.GetAllCatalogSourcesHandler)))
231243
apiRouter.GET(CatalogFilterOptionListPath, app.AttachNamespace(app.AttachModelCatalogRESTClient(app.GetCatalogFilterListHandler)))
232244
apiRouter.GET(CatalogSourceModelCatchAllPath, app.AttachNamespace(app.AttachModelCatalogRESTClient(app.GetCatalogSourceModelHandler)))
233-
apiRouter.GET(CatalogSourceModelArtifactsCatchAll, app.AttachNamespace(app.AttachModelCatalogRESTClient(app.GetCatalogSourceModelArtifactHandler)))
245+
apiRouter.GET(CatalogSourceModelArtifactsCatchAll, app.AttachNamespace(app.AttachModelCatalogRESTClient(app.GetCatalogSourceModelArtifactsHandler)))
234246
// Kubernetes routes
235247
apiRouter.GET(UserPath, app.UserHandler)
236248
apiRouter.GET(ModelRegistryListPath, app.AttachNamespace(app.RequireListServiceAccessInNamespace(app.GetAllModelRegistriesHandler)))

clients/ui/bff/internal/api/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var _ = Describe("Static File serving Test", func() {
2525
}
2626
app := &App{
2727
kubernetesClientFactory: kubernetesMockedStaticClientFactory,
28-
repositories: repositories.NewRepositories(mockMRClient, mockModelCatalogClient),
28+
repositories: repositories.NewRepositories(mockMRClient, mockModelCatalogClient, modelCatalogSettingsRepository),
2929
logger: logger,
3030
config: envConfig,
3131
}

clients/ui/bff/internal/api/catalog_models_handler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
type CatalogModelListEnvelope Envelope[*models.CatalogModelList, None]
1414

1515
func (app *App) GetAllCatalogModelsAcrossSourcesHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
16-
1716
client, ok := r.Context().Value(constants.ModelCatalogHttpClientKey).(httpclient.HTTPClientInterface)
1817
if !ok {
1918
app.serverErrorResponse(w, r, errors.New("catalog REST client not found"))

clients/ui/bff/internal/api/catalog_sources_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (app *App) GetCatalogSourceModelHandler(w http.ResponseWriter, r *http.Requ
6969
}
7070
}
7171

72-
func (app *App) GetCatalogSourceModelArtifactHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
72+
func (app *App) GetCatalogSourceModelArtifactsHandler(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
7373
client, ok := r.Context().Value(constants.ModelCatalogHttpClientKey).(httpclient.HTTPClientInterface)
7474
if !ok {
7575
app.serverErrorResponse(w, r, errors.New("catalog REST client not found"))
@@ -81,7 +81,7 @@ func (app *App) GetCatalogSourceModelArtifactHandler(w http.ResponseWriter, r *h
8181

8282
newModelName := url.PathEscape(modelName)
8383

84-
catalogModelArtifacts, err := app.repositories.ModelCatalogClient.GetCatalogModelArtifacts(client, ps.ByName(CatalogSourceId), newModelName)
84+
catalogModelArtifacts, err := app.repositories.ModelCatalogClient.GetCatalogSourceModelArtifacts(client, ps.ByName(CatalogSourceId), newModelName)
8585

8686
if err != nil {
8787
app.serverErrorResponse(w, r, err)

clients/ui/bff/internal/api/healthcheck__handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestHealthCheckHandler(t *testing.T) {
2020
app := App{config: config.EnvConfig{
2121
Port: 4000,
2222
},
23-
repositories: repositories.NewRepositories(mockMRClient, mockModelCatalogClient),
23+
repositories: repositories.NewRepositories(mockMRClient, mockModelCatalogClient, modelCatalogSettingsRepository),
2424
}
2525

2626
rr := httptest.NewRecorder()

0 commit comments

Comments
 (0)