@red-hat-developer-hub/backstage-plugin-catalog-backend-module-model-catalog 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/dist/clients/BridgeResourceConnector.cjs.js +19 -5
- package/dist/clients/BridgeResourceConnector.cjs.js.map +1 -1
- package/dist/clients/ModelCatalogGenerator.cjs.js +59 -162
- package/dist/clients/ModelCatalogGenerator.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/module.cjs.js +14 -8
- package/dist/module.cjs.js.map +1 -1
- package/dist/providers/ModelCatalogResourceEntityProvider.cjs.js +38 -16
- package/dist/providers/ModelCatalogResourceEntityProvider.cjs.js.map +1 -1
- package/dist/providers/config.cjs.js +0 -2
- package/dist/providers/config.cjs.js.map +1 -1
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @red-hat-developer-hub/backstage-plugin-catalog-backend-module-model-catalog
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 8bf7bc3: Add AiModelServerAPI kind (`spec.type: ai-model-server`) in a dedicated
|
|
8
|
+
catalog-model package with types, JSON schema, KindValidator, type guard,
|
|
9
|
+
and CatalogModelLayer registration. Uses a dedicated kind to avoid
|
|
10
|
+
colliding with the upstream API kind; the schema mirrors
|
|
11
|
+
backstage/backstage#34476 exactly. The backend module registers the
|
|
12
|
+
AiModelServerAPI kind with the catalog via `catalogModelExtensionPoint`.
|
|
13
|
+
|
|
14
|
+
The model catalog entity provider now emits a single AiModelServerAPI
|
|
15
|
+
entity per model server instead of separate Component, Resource, and API
|
|
16
|
+
entities. Model names are collected into `spec.models.available`.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [8bf7bc3]
|
|
21
|
+
- @red-hat-developer-hub/backstage-plugin-catalog-model-ai-model-server@0.2.0
|
|
22
|
+
|
|
23
|
+
## 0.11.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- 6c752b6: K8s credentials (url, serviceAccountToken, skipTLSVerify, caData) are now configurable via app-config.yaml, either directly or via kubernetesPluginRef. The `baseUrl` config field has been removed from model-catalog; the connector base URL is now resolved via Backstage's DiscoveryService.
|
|
28
|
+
|
|
29
|
+
## 0.10.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- 56c40be: Integrate Backstage discovery and auth services for connector communication.
|
|
34
|
+
|
|
35
|
+
The model-catalog entity provider now resolves the connector base URL via the
|
|
36
|
+
discovery service and authenticates with backend-to-backend service tokens
|
|
37
|
+
instead of unauthenticated direct HTTP calls. The `fromConfig` factory method
|
|
38
|
+
accepts `discovery` and `auth` as additional required dependencies.
|
|
39
|
+
|
|
40
|
+
The techdoc URL reader adds bearer-token authentication when fetching model
|
|
41
|
+
cards and replaces hostname-based bridge URL matching with path-based matching
|
|
42
|
+
that uses the connector plugin ID.
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- c2e3749: bump workspace to 1.52.0
|
|
47
|
+
|
|
48
|
+
## 0.9.1
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- 4418084: Upgrade workspace to Backstage 1.49.4
|
|
53
|
+
|
|
3
54
|
## 0.9.0
|
|
4
55
|
|
|
5
56
|
### Minor Changes
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
async function fetchModelCatalogKeys(baseUrl) {
|
|
3
|
+
async function fetchModelCatalogKeys(baseUrl, token) {
|
|
4
4
|
const res = await fetch(`${baseUrl}/list`, {
|
|
5
|
-
method: "GET"
|
|
5
|
+
method: "GET",
|
|
6
|
+
headers: {
|
|
7
|
+
Authorization: `Bearer ${token.token}`,
|
|
8
|
+
"Content-Type": "application/json"
|
|
9
|
+
}
|
|
6
10
|
});
|
|
7
11
|
if (!res.ok) {
|
|
8
12
|
throw new Error(res.statusText);
|
|
@@ -10,9 +14,19 @@ async function fetchModelCatalogKeys(baseUrl) {
|
|
|
10
14
|
const modelCatalogKeys = await res.json();
|
|
11
15
|
return modelCatalogKeys.uris;
|
|
12
16
|
}
|
|
13
|
-
async function fetchModelCatalogFromKey(baseUrl, modelCatalogKey) {
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
async function fetchModelCatalogFromKey(baseUrl, modelCatalogKey, token) {
|
|
18
|
+
let tok = "";
|
|
19
|
+
if (token) {
|
|
20
|
+
tok = token?.token;
|
|
21
|
+
}
|
|
22
|
+
const url = `${baseUrl}/models/${modelCatalogKey}`;
|
|
23
|
+
console.log(`Fetching model catalog key ${url}`);
|
|
24
|
+
const res = await fetch(url, {
|
|
25
|
+
method: "GET",
|
|
26
|
+
headers: {
|
|
27
|
+
Authorization: `Bearer ${tok}`,
|
|
28
|
+
"Content-Type": "application/json"
|
|
29
|
+
}
|
|
16
30
|
});
|
|
17
31
|
if (!res.ok) {
|
|
18
32
|
throw new Error(res.statusText);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BridgeResourceConnector.cjs.js","sources":["../../src/clients/BridgeResourceConnector.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ModelCatalog } from '@redhat-ai-dev/model-catalog-types';\n\n/**\n * ModelCatalogKeys is the object used by the bridge to return the list of keys corresponding to each model catalog entry in the bridge\n * @public\n */\nexport interface ModelCatalogKeys {\n uris: string[];\n}\n\n/**\n * fetchModelCatalogKeys retrieves the keys for each of the model catalog entries in the model catalog bridge service\n * @public\n */\nexport async function fetchModelCatalogKeys(\n baseUrl: string,\n): Promise<string[]> {\n
|
|
1
|
+
{"version":3,"file":"BridgeResourceConnector.cjs.js","sources":["../../src/clients/BridgeResourceConnector.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ModelCatalog } from '@redhat-ai-dev/model-catalog-types';\n\n/**\n * ModelCatalogKeys is the object used by the bridge to return the list of keys corresponding to each model catalog entry in the bridge\n * @public\n */\nexport interface ModelCatalogKeys {\n uris: string[];\n}\n\n/**\n * fetchModelCatalogKeys retrieves the keys for each of the model catalog entries in the model catalog bridge service\n * @public\n */\nexport async function fetchModelCatalogKeys(\n baseUrl: string,\n token: { token: string },\n): Promise<string[]> {\n const res = await fetch(`${baseUrl}/list`, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${token.token}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n\n const modelCatalogKeys: ModelCatalogKeys = await res.json();\n return modelCatalogKeys.uris;\n}\n\n/**\n * fetchModelCatalogFromKey fetches a model catalog JSON object from the bridge based on a given key\n * @public\n */\nexport async function fetchModelCatalogFromKey(\n baseUrl: string,\n modelCatalogKey: string,\n token?: { token: string },\n): Promise<ModelCatalog> {\n let tok = '';\n if (token) {\n tok = token?.token;\n }\n const url = `${baseUrl}/models/${modelCatalogKey}`;\n console.log(`Fetching model catalog key ${url}`);\n const res = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${tok}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n\n const modelCatalog: ModelCatalog = await res.json();\n return modelCatalog;\n}\n"],"names":[],"mappings":";;AA6BA,eAAsB,qBAAA,CACpB,SACA,KAAA,EACmB;AACnB,EAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,CAAA,EAAG,OAAO,CAAA,KAAA,CAAA,EAAS;AAAA,IACzC,MAAA,EAAQ,KAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,aAAA,EAAe,CAAA,OAAA,EAAU,KAAA,CAAM,KAAK,CAAA,CAAA;AAAA,MACpC,cAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AAED,EAAA,IAAI,CAAC,IAAI,EAAA,EAAI;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,GAAA,CAAI,UAAU,CAAA;AAAA,EAChC;AAEA,EAAA,MAAM,gBAAA,GAAqC,MAAM,GAAA,CAAI,IAAA,EAAK;AAC1D,EAAA,OAAO,gBAAA,CAAiB,IAAA;AAC1B;AAMA,eAAsB,wBAAA,CACpB,OAAA,EACA,eAAA,EACA,KAAA,EACuB;AACvB,EAAA,IAAI,GAAA,GAAM,EAAA;AACV,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,GAAA,GAAM,KAAA,EAAO,KAAA;AAAA,EACf;AACA,EAAA,MAAM,GAAA,GAAM,CAAA,EAAG,OAAO,CAAA,QAAA,EAAW,eAAe,CAAA,CAAA;AAChD,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAA,2BAAA,EAA8B,GAAG,CAAA,CAAE,CAAA;AAC/C,EAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,GAAA,EAAK;AAAA,IAC3B,MAAA,EAAQ,KAAA;AAAA,IACR,OAAA,EAAS;AAAA,MACP,aAAA,EAAe,UAAU,GAAG,CAAA,CAAA;AAAA,MAC5B,cAAA,EAAgB;AAAA;AAClB,GACD,CAAA;AAED,EAAA,IAAI,CAAC,IAAI,EAAA,EAAI;AACX,IAAA,MAAM,IAAI,KAAA,CAAM,GAAA,CAAI,UAAU,CAAA;AAAA,EAChC;AAEA,EAAA,MAAM,YAAA,GAA6B,MAAM,GAAA,CAAI,IAAA,EAAK;AAClD,EAAA,OAAO,YAAA;AACT;;;;;"}
|
|
@@ -2,182 +2,82 @@
|
|
|
2
2
|
|
|
3
3
|
var catalogModel = require('@backstage/catalog-model');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
GenerateModelResourceEntities(models, modelCatalog.modelServer)
|
|
10
|
-
);
|
|
11
|
-
if (modelCatalog.modelServer !== void 0) {
|
|
12
|
-
const modelServer = modelCatalog.modelServer;
|
|
13
|
-
modelCatalogEntities.push(
|
|
14
|
-
GenerateModelServerComponentEntity(
|
|
15
|
-
modelServer,
|
|
16
|
-
modelCatalog.models)
|
|
17
|
-
);
|
|
18
|
-
if (modelServer.API !== void 0) {
|
|
19
|
-
const api = modelServer.API;
|
|
20
|
-
modelCatalogEntities.push(
|
|
21
|
-
GenerateModelServerAPI(api, modelServer)
|
|
22
|
-
);
|
|
23
|
-
}
|
|
5
|
+
const TECHDOCS_KEY = "techdocs";
|
|
6
|
+
function GenerateCatalogEntities(modelCatalog, svcUrl, logger) {
|
|
7
|
+
if (!modelCatalog.modelServer) {
|
|
8
|
+
return [];
|
|
24
9
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function GenerateModelResourceEntities(models, modelServer, logger) {
|
|
28
|
-
const modelResourceEntities = [];
|
|
29
|
-
models.forEach((model) => {
|
|
30
|
-
const modelResourceEntity = {
|
|
31
|
-
apiVersion: "backstage.io/v1beta1",
|
|
32
|
-
kind: "Resource",
|
|
33
|
-
metadata: {
|
|
34
|
-
name: sanitizeMetadataName(model.name),
|
|
35
|
-
description: `${model.description}`,
|
|
36
|
-
tags: [],
|
|
37
|
-
links: []
|
|
38
|
-
},
|
|
39
|
-
spec: {
|
|
40
|
-
owner: `user:${model.owner}`,
|
|
41
|
-
type: "ai-model"
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
if (model.tags !== void 0) {
|
|
45
|
-
modelResourceEntity.metadata.tags = sanitizeTags(model.tags);
|
|
46
|
-
}
|
|
47
|
-
if (model.artifactLocationURL !== void 0) {
|
|
48
|
-
modelResourceEntity.metadata.links?.push({
|
|
49
|
-
title: "Artifact Location",
|
|
50
|
-
url: `${model.artifactLocationURL}`
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (model.howToUseURL !== void 0) {
|
|
54
|
-
modelResourceEntity.metadata.links?.push({
|
|
55
|
-
title: "How to use",
|
|
56
|
-
url: `${model.howToUseURL}`
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (model.license !== void 0) {
|
|
60
|
-
modelResourceEntity.metadata.links?.push({
|
|
61
|
-
title: `License`,
|
|
62
|
-
url: `${model.license}`
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
modelResourceEntity.spec.dependencyOf = [];
|
|
66
|
-
if (modelServer !== void 0) {
|
|
67
|
-
modelResourceEntity.spec.dependencyOf?.push(
|
|
68
|
-
`component:${modelServer.name}`
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
if (model.annotations !== void 0) {
|
|
72
|
-
if (modelResourceEntity.metadata.annotations === void 0) {
|
|
73
|
-
modelResourceEntity.metadata.annotations = {};
|
|
74
|
-
}
|
|
75
|
-
Object.keys(model.annotations).forEach((key) => {
|
|
76
|
-
if (key === "TechDocs") {
|
|
77
|
-
let techdocsUrl = model.annotations[key];
|
|
78
|
-
techdocsUrl = techdocsUrl.trim();
|
|
79
|
-
if (techdocsUrl !== "") {
|
|
80
|
-
modelResourceEntity.metadata.annotations["backstage.io/techdocs-ref"] = `url:${techdocsUrl}`;
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
modelResourceEntity.metadata.annotations[key] = model.annotations[key];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
modelResourceEntities.push(modelResourceEntity);
|
|
88
|
-
});
|
|
89
|
-
return modelResourceEntities;
|
|
90
|
-
}
|
|
91
|
-
function GenerateModelServerComponentEntity(modelServer, models, logger) {
|
|
92
|
-
const modelServerComponent = {
|
|
93
|
-
apiVersion: "backstage.io/v1beta1",
|
|
94
|
-
kind: "Component",
|
|
95
|
-
metadata: {
|
|
96
|
-
name: sanitizeMetadataName(modelServer.name),
|
|
97
|
-
description: `${modelServer.description}`,
|
|
98
|
-
tags: [],
|
|
99
|
-
links: []
|
|
100
|
-
},
|
|
101
|
-
spec: {
|
|
102
|
-
type: "model-server",
|
|
103
|
-
lifecycle: `${modelServer.lifecycle}`,
|
|
104
|
-
owner: `user:${modelServer.owner}`
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
modelServerComponent.spec.dependsOn = [];
|
|
108
|
-
models.forEach((model) => {
|
|
109
|
-
modelServerComponent.spec.dependsOn?.push(`resource:${model.name}`);
|
|
110
|
-
});
|
|
111
|
-
if (modelServer.tags !== void 0) {
|
|
112
|
-
modelServerComponent.metadata.tags = sanitizeTags(modelServer.tags);
|
|
10
|
+
if (!modelCatalog.modelServer.API?.url) {
|
|
11
|
+
return [];
|
|
113
12
|
}
|
|
13
|
+
const modelServer = modelCatalog.modelServer;
|
|
14
|
+
const models = modelCatalog.models;
|
|
15
|
+
const tags = sanitizeTags(modelServer.tags ?? []);
|
|
114
16
|
if (modelServer.authentication === void 0 || !modelServer.authentication) {
|
|
115
|
-
|
|
17
|
+
tags.push("auth-not-required");
|
|
116
18
|
} else {
|
|
117
|
-
|
|
19
|
+
tags.push("auth-required");
|
|
20
|
+
}
|
|
21
|
+
const links = [];
|
|
22
|
+
if (modelServer.API) {
|
|
23
|
+
links.push({ title: "API", url: modelServer.API.url });
|
|
118
24
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
25
|
+
if (modelServer.homepageURL) {
|
|
26
|
+
links.push({ title: "Homepage", url: modelServer.homepageURL });
|
|
27
|
+
}
|
|
28
|
+
const annotations = {};
|
|
29
|
+
if (modelServer.API?.annotations) {
|
|
30
|
+
Object.assign(annotations, modelServer.API.annotations);
|
|
31
|
+
}
|
|
32
|
+
if (modelServer.annotations) {
|
|
33
|
+
Object.assign(annotations, modelServer.annotations);
|
|
34
|
+
}
|
|
35
|
+
for (const model of models) {
|
|
36
|
+
if (model.annotations?.[TECHDOCS_KEY]) {
|
|
37
|
+
let techdocsUrl = model.annotations[TECHDOCS_KEY].trim();
|
|
38
|
+
if (techdocsUrl !== "") {
|
|
39
|
+
if (svcUrl && techdocsUrl.startsWith("/")) {
|
|
40
|
+
techdocsUrl = svcUrl + techdocsUrl;
|
|
41
|
+
}
|
|
42
|
+
annotations["backstage.io/techdocs-ref"] = `url:${techdocsUrl}`;
|
|
43
|
+
break;
|
|
129
44
|
}
|
|
130
|
-
Object.keys(modelServer.API.annotations).forEach((key) => {
|
|
131
|
-
modelServerComponent.metadata.annotations[key] = modelServer.API.annotations[key];
|
|
132
|
-
});
|
|
133
45
|
}
|
|
134
46
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (modelServer.annotations !== void 0) {
|
|
142
|
-
if (modelServerComponent.metadata.annotations === void 0) {
|
|
143
|
-
modelServerComponent.metadata.annotations = {};
|
|
47
|
+
for (const model of models) {
|
|
48
|
+
if (model.artifactLocationURL) {
|
|
49
|
+
links.push({
|
|
50
|
+
title: `${model.name} artifact`,
|
|
51
|
+
url: model.artifactLocationURL
|
|
52
|
+
});
|
|
144
53
|
}
|
|
145
|
-
Object.keys(modelServer.annotations).forEach((key) => {
|
|
146
|
-
modelServerComponent.metadata.annotations[key] = modelServer.annotations[key];
|
|
147
|
-
});
|
|
148
54
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const modelServerAPIEntity = {
|
|
153
|
-
apiVersion: `backstage.io/v1beta1`,
|
|
154
|
-
kind: `API`,
|
|
55
|
+
const entity = {
|
|
56
|
+
apiVersion: "backstage.io/v1alpha1",
|
|
57
|
+
kind: "AiModelServerAPI",
|
|
155
58
|
metadata: {
|
|
156
59
|
name: sanitizeMetadataName(modelServer.name),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
title: `API`
|
|
162
|
-
}
|
|
163
|
-
]
|
|
60
|
+
description: modelServer.description,
|
|
61
|
+
tags,
|
|
62
|
+
links,
|
|
63
|
+
...Object.keys(annotations).length > 0 && { annotations }
|
|
164
64
|
},
|
|
165
65
|
spec: {
|
|
166
|
-
type:
|
|
66
|
+
type: "ai-model-server",
|
|
67
|
+
lifecycle: modelServer.lifecycle,
|
|
167
68
|
owner: `user:${modelServer.owner}`,
|
|
168
|
-
|
|
169
|
-
|
|
69
|
+
serverType: modelServer.API?.type ?? "unknown",
|
|
70
|
+
serverUrl: modelServer.API?.url ?? "",
|
|
71
|
+
requiresApiKey: modelServer.authentication ?? false,
|
|
72
|
+
models: {
|
|
73
|
+
available: models.map((m) => sanitizeMetadataName(m.name)),
|
|
74
|
+
...models.length > 0 && {
|
|
75
|
+
default: sanitizeMetadataName(models[0].name)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
170
78
|
}
|
|
171
79
|
};
|
|
172
|
-
|
|
173
|
-
modelServerAPIEntity.metadata.tags = sanitizeTags(api.tags);
|
|
174
|
-
}
|
|
175
|
-
if (modelServer.authentication === void 0 || !modelServer.authentication) {
|
|
176
|
-
modelServerAPIEntity.metadata.tags?.push("auth-not-required");
|
|
177
|
-
} else {
|
|
178
|
-
modelServerAPIEntity.metadata.tags?.push("auth-required");
|
|
179
|
-
}
|
|
180
|
-
return modelServerAPIEntity;
|
|
80
|
+
return [entity];
|
|
181
81
|
}
|
|
182
82
|
function sanitizeMetadataName(modelName) {
|
|
183
83
|
return modelName.replace(/\s/g, "");
|
|
@@ -196,7 +96,4 @@ function sanitizeTags(tags, logger) {
|
|
|
196
96
|
}
|
|
197
97
|
|
|
198
98
|
exports.GenerateCatalogEntities = GenerateCatalogEntities;
|
|
199
|
-
exports.GenerateModelResourceEntities = GenerateModelResourceEntities;
|
|
200
|
-
exports.GenerateModelServerAPI = GenerateModelServerAPI;
|
|
201
|
-
exports.GenerateModelServerComponentEntity = GenerateModelServerComponentEntity;
|
|
202
99
|
//# sourceMappingURL=ModelCatalogGenerator.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelCatalogGenerator.cjs.js","sources":["../../src/clients/ModelCatalogGenerator.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n ModelCatalog,\n Model,\n ModelServer,\n API,\n} from '@redhat-ai-dev/model-catalog-types';\nimport {\n Entity,\n ComponentEntity,\n ApiEntity,\n ResourceEntity,\n makeValidator,\n} from '@backstage/catalog-model';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nfunction isModelCatalog(o: any): o is ModelCatalog {\n return 'models' in o || 'modelServer' in o;\n}\n\nexport function ParseCatalogJSON(jsonStr: string): ModelCatalog {\n const modelCatalog: ModelCatalog = JSON.parse(jsonStr);\n if (isModelCatalog(modelCatalog)) {\n // do something with now correctly typed object\n return modelCatalog;\n }\n throw new Error(`model catalog JSON in unexpected format: ${jsonStr}`);\n}\n\n// Generate the Backstage catalog entities that correspond to the given model catalog json object\n// Note: These entities will need to have their location and origin location annotations set before ingestion into the catalog\n// An optional logger parameter can be passed if you wish log output from the generator\nexport function GenerateCatalogEntities(\n modelCatalog: ModelCatalog,\n logger?: LoggerService,\n): Entity[] {\n // Generate the Resource entities for the Model(s)\n let modelCatalogEntities: Entity[] = [];\n const models: Model[] = modelCatalog.models;\n modelCatalogEntities = modelCatalogEntities.concat(\n GenerateModelResourceEntities(models, modelCatalog.modelServer, logger),\n );\n\n // Generate the Model Server and Model Server APi entity, if present\n if (modelCatalog.modelServer !== undefined) {\n const modelServer = modelCatalog.modelServer;\n modelCatalogEntities.push(\n GenerateModelServerComponentEntity(\n modelServer,\n modelCatalog.models,\n logger,\n ),\n );\n\n // If there's an exposed API present, generate that entity as well, and update the model server entity accordingly\n if (modelServer.API !== undefined) {\n const api: API = modelServer.API;\n modelCatalogEntities.push(\n GenerateModelServerAPI(api, modelServer, logger),\n );\n }\n }\n\n return modelCatalogEntities;\n}\n\nexport function GenerateModelResourceEntities(\n models: Model[],\n modelServer?: ModelServer,\n logger?: LoggerService,\n): ResourceEntity[] {\n const modelResourceEntities: ResourceEntity[] = [];\n models.forEach(model => {\n const modelResourceEntity: ResourceEntity = {\n apiVersion: 'backstage.io/v1beta1',\n kind: 'Resource',\n metadata: {\n name: sanitizeMetadataName(model.name),\n description: `${model.description}`,\n tags: [],\n links: [],\n },\n spec: {\n owner: `user:${model.owner}`,\n type: 'ai-model',\n },\n };\n\n // Set optional parameters, if present\n if (model.tags !== undefined) {\n modelResourceEntity.metadata.tags = sanitizeTags(model.tags, logger);\n }\n if (model.artifactLocationURL !== undefined) {\n modelResourceEntity.metadata.links?.push({\n title: 'Artifact Location',\n url: `${model.artifactLocationURL}`,\n });\n }\n if (model.howToUseURL !== undefined) {\n modelResourceEntity.metadata.links?.push({\n title: 'How to use',\n url: `${model.howToUseURL}`,\n });\n }\n if (model.license !== undefined) {\n modelResourceEntity.metadata.links?.push({\n title: `License`,\n url: `${model.license}`,\n });\n }\n modelResourceEntity.spec.dependencyOf = [];\n if (modelServer !== undefined) {\n modelResourceEntity.spec.dependencyOf?.push(\n `component:${modelServer.name}`,\n );\n }\n\n // Handle any annotations present on the model resource\n if (model.annotations !== undefined) {\n // Initialize annotations object if needed\n if (modelResourceEntity.metadata.annotations === undefined) {\n modelResourceEntity.metadata.annotations = {};\n }\n\n // Copy all annotations from model to resource entity\n Object.keys(model.annotations).forEach(key => {\n // Special handling for TechDocs annotation\n if (key === 'TechDocs') {\n let techdocsUrl: string = model.annotations![key];\n techdocsUrl = techdocsUrl.trim();\n if (techdocsUrl !== '') {\n modelResourceEntity.metadata.annotations![\n 'backstage.io/techdocs-ref'\n ] = `url:${techdocsUrl}`;\n }\n } else {\n // Copy all other annotations as-is\n modelResourceEntity.metadata.annotations![key] =\n model.annotations![key];\n }\n });\n }\n modelResourceEntities.push(modelResourceEntity);\n });\n\n return modelResourceEntities;\n}\n\nexport function GenerateModelServerComponentEntity(\n modelServer: ModelServer,\n models: Model[],\n logger?: LoggerService,\n): ComponentEntity {\n const modelServerComponent: ComponentEntity = {\n apiVersion: 'backstage.io/v1beta1',\n kind: 'Component',\n metadata: {\n name: sanitizeMetadataName(modelServer.name),\n description: `${modelServer.description}`,\n tags: [],\n links: [],\n },\n spec: {\n type: 'model-server',\n lifecycle: `${modelServer.lifecycle}`,\n owner: `user:${modelServer.owner}`,\n },\n };\n\n // Add the models to the model server as dependants\n modelServerComponent.spec.dependsOn = [];\n models.forEach(model => {\n modelServerComponent.spec.dependsOn?.push(`resource:${model.name}`);\n });\n\n // Configure optional parameters\n // Set optional parameters, if present\n if (modelServer.tags !== undefined) {\n modelServerComponent.metadata.tags = sanitizeTags(modelServer.tags, logger);\n }\n // Add authentication tag\n if (modelServer.authentication === undefined || !modelServer.authentication) {\n modelServerComponent.metadata.tags?.push('auth-not-required');\n } else {\n modelServerComponent.metadata.tags?.push('auth-required');\n }\n modelServerComponent.metadata.links = [];\n if (modelServer.API !== undefined) {\n modelServerComponent.metadata.links.push({\n title: `API`,\n url: `${modelServer.API.url}`,\n });\n modelServerComponent.spec.providesApis = [modelServer.name];\n\n // Copy annotations from API to component metadata if they exist\n if (modelServer.API.annotations !== undefined) {\n if (modelServerComponent.metadata.annotations === undefined) {\n modelServerComponent.metadata.annotations = {};\n }\n // Copy all key-value pairs from API annotations to component annotations\n Object.keys(modelServer.API.annotations).forEach(key => {\n modelServerComponent.metadata.annotations![key] =\n modelServer.API!.annotations![key];\n });\n }\n }\n if (modelServer.homepageURL !== undefined) {\n modelServerComponent.metadata.links.push({\n title: 'Homepage',\n url: `${modelServer.homepageURL}`,\n });\n }\n\n // Copy annotations from modelServer to component metadata if they exist\n if (modelServer.annotations !== undefined) {\n if (modelServerComponent.metadata.annotations === undefined) {\n modelServerComponent.metadata.annotations = {};\n }\n // Copy all key-value pairs from modelServer annotations to component annotations\n Object.keys(modelServer.annotations).forEach(key => {\n modelServerComponent.metadata.annotations![key] =\n modelServer.annotations![key];\n });\n }\n\n return modelServerComponent;\n}\n\nexport function GenerateModelServerAPI(\n api: API,\n modelServer: ModelServer,\n logger?: LoggerService,\n): ApiEntity {\n const modelServerAPIEntity: ApiEntity = {\n apiVersion: `backstage.io/v1beta1`,\n kind: `API`,\n metadata: {\n name: sanitizeMetadataName(modelServer.name),\n tags: [],\n links: [\n {\n url: `${api.url}`,\n title: `API`,\n },\n ],\n },\n spec: {\n type: `${api.type}`,\n owner: `user:${modelServer.owner}`,\n lifecycle: `${modelServer.lifecycle}`,\n definition: `${api.spec}`,\n },\n };\n\n if (api.tags !== undefined) {\n modelServerAPIEntity.metadata.tags = sanitizeTags(api.tags, logger);\n }\n // Add authentication tag\n if (modelServer.authentication === undefined || !modelServer.authentication) {\n modelServerAPIEntity.metadata.tags?.push('auth-not-required');\n } else {\n modelServerAPIEntity.metadata.tags?.push('auth-required');\n }\n return modelServerAPIEntity;\n}\n\nfunction sanitizeMetadataName(modelName: string): string {\n return modelName.replace(/\\s/g, '');\n}\n\nfunction sanitizeTags(tags: string[], logger?: LoggerService): string[] {\n const sanitizedTags: string[] = [];\n tags.forEach(tag => {\n let sanitizedTag: string = tag;\n // Replace whitespace with empty character\n sanitizedTag = sanitizedTag.replace(/\\s/g, '');\n\n // Call the Backstage tag validator and check if the tag conforms\n // If the tag is not valid, skip it\n if (!makeValidator().isValidTag(sanitizedTag)) {\n if (logger !== undefined) {\n logger.error(\n `invalid tag: ${sanitizedTag}. Tags are expected to be less than 63 characters and conform to: ^[a-z0-9:+#]+(\\-[a-z0-9:+#]+)*$`,\n );\n }\n return; /* in typescript a return in a foreach skips to the next iteration */\n }\n sanitizedTags.push(sanitizedTag);\n });\n return sanitizedTags;\n}\n"],"names":["makeValidator"],"mappings":";;;;AA8CgB,SAAA,uBAAA,CACd,cACA,MACU,EAAA;AAEV,EAAA,IAAI,uBAAiC,EAAC;AACtC,EAAA,MAAM,SAAkB,YAAa,CAAA,MAAA;AACrC,EAAA,oBAAA,GAAuB,oBAAqB,CAAA,MAAA;AAAA,IAC1C,6BAA8B,CAAA,MAAA,EAAQ,YAAa,CAAA,WAAmB;AAAA,GACxE;AAGA,EAAI,IAAA,YAAA,CAAa,gBAAgB,MAAW,EAAA;AAC1C,IAAA,MAAM,cAAc,YAAa,CAAA,WAAA;AACjC,IAAqB,oBAAA,CAAA,IAAA;AAAA,MACnB,kCAAA;AAAA,QACE,WAAA;AAAA,QACA,YAAa,CAAA,MAEf;AAAA,KACF;AAGA,IAAI,IAAA,WAAA,CAAY,QAAQ,MAAW,EAAA;AACjC,MAAA,MAAM,MAAW,WAAY,CAAA,GAAA;AAC7B,MAAqB,oBAAA,CAAA,IAAA;AAAA,QACnB,sBAAA,CAAuB,GAAK,EAAA,WAAmB;AAAA,OACjD;AAAA;AACF;AAGF,EAAO,OAAA,oBAAA;AACT;AAEgB,SAAA,6BAAA,CACd,MACA,EAAA,WAAA,EACA,MACkB,EAAA;AAClB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A;AACvD,EAAO,OAAA,SAAA,CAAU,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAA;AACpC;AAEA,SAAS,YAAA,CAAa,MAAgB,MAAkC,EAAA;AACtE,EAAA,MAAM,gBAA0B,EAAC;AACjC,EAAA,IAAA,CAAK,QAAQ,CAAO,GAAA,KAAA;AAClB,IAAA,IAAI,YAAuB,GAAA,GAAA;AAE3B,IAAe,YAAA,GAAA,YAAA,CAAa,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAA;AAI7C,IAAA,IAAI,CAACA,0BAAA,EAAgB,CAAA,UAAA,CAAW,YAAY,CAAG,EAAA;AAM7C,MAAA;AAAA;AAEF,IAAA,aAAA,CAAc,KAAK,YAAY,CAAA;AAAA,GAChC,CAAA;AACD,EAAO,OAAA,aAAA;AACT;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"ModelCatalogGenerator.cjs.js","sources":["../../src/clients/ModelCatalogGenerator.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { ModelCatalog } from '@redhat-ai-dev/model-catalog-types';\nimport { Entity, makeValidator } from '@backstage/catalog-model';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport type { AiModelServerApiEntity } from '@red-hat-developer-hub/backstage-plugin-catalog-model-ai-model-server';\n\nconst TECHDOCS_KEY = 'techdocs';\n\nfunction isModelCatalog(o: any): o is ModelCatalog {\n return 'models' in o || 'modelServer' in o;\n}\n\nexport function ParseCatalogJSON(jsonStr: string): ModelCatalog {\n const modelCatalog: ModelCatalog = JSON.parse(jsonStr);\n if (isModelCatalog(modelCatalog)) {\n return modelCatalog;\n }\n throw new Error(`model catalog JSON in unexpected format: ${jsonStr}`);\n}\n\nexport function GenerateCatalogEntities(\n modelCatalog: ModelCatalog,\n svcUrl?: string,\n logger?: LoggerService,\n): Entity[] {\n if (!modelCatalog.modelServer) {\n logger?.debug(\n 'ModelCatalog has no modelServer; skipping AiModelServerAPI generation',\n );\n return [];\n }\n\n if (!modelCatalog.modelServer.API?.url) {\n logger?.debug(\n 'ModelCatalog modelServer has no API url; skipping AiModelServerAPI generation',\n );\n return [];\n }\n\n const modelServer = modelCatalog.modelServer;\n const models = modelCatalog.models;\n\n const tags = sanitizeTags(modelServer.tags ?? [], logger);\n if (modelServer.authentication === undefined || !modelServer.authentication) {\n tags.push('auth-not-required');\n } else {\n tags.push('auth-required');\n }\n\n const links: Array<{ title: string; url: string }> = [];\n if (modelServer.API) {\n links.push({ title: 'API', url: modelServer.API.url });\n }\n if (modelServer.homepageURL) {\n links.push({ title: 'Homepage', url: modelServer.homepageURL });\n }\n\n const annotations: Record<string, string> = {};\n\n // Copy API annotations\n if (modelServer.API?.annotations) {\n Object.assign(annotations, modelServer.API.annotations);\n }\n // Copy model server annotations (overrides API on conflict)\n if (modelServer.annotations) {\n Object.assign(annotations, modelServer.annotations);\n }\n\n // Collect techdocs from models — use the first one found\n for (const model of models) {\n if (model.annotations?.[TECHDOCS_KEY]) {\n let techdocsUrl = model.annotations[TECHDOCS_KEY].trim();\n if (techdocsUrl !== '') {\n if (svcUrl && techdocsUrl.startsWith('/')) {\n techdocsUrl = svcUrl + techdocsUrl;\n }\n annotations['backstage.io/techdocs-ref'] = `url:${techdocsUrl}`;\n break;\n }\n }\n }\n\n // Collect per-model artifact links\n for (const model of models) {\n if (model.artifactLocationURL) {\n links.push({\n title: `${model.name} artifact`,\n url: model.artifactLocationURL,\n });\n }\n }\n\n const entity: AiModelServerApiEntity = {\n apiVersion: 'backstage.io/v1alpha1',\n kind: 'AiModelServerAPI',\n metadata: {\n name: sanitizeMetadataName(modelServer.name),\n description: modelServer.description,\n tags,\n links,\n ...(Object.keys(annotations).length > 0 && { annotations }),\n },\n spec: {\n type: 'ai-model-server',\n lifecycle: modelServer.lifecycle,\n owner: `user:${modelServer.owner}`,\n serverType: modelServer.API?.type ?? 'unknown',\n serverUrl: modelServer.API?.url ?? '',\n requiresApiKey: modelServer.authentication ?? false,\n models: {\n available: models.map(m => sanitizeMetadataName(m.name)),\n ...(models.length > 0 && {\n default: sanitizeMetadataName(models[0].name),\n }),\n },\n },\n };\n\n return [entity];\n}\n\nfunction sanitizeMetadataName(modelName: string): string {\n return modelName.replace(/\\s/g, '');\n}\n\nfunction sanitizeTags(tags: string[], logger?: LoggerService): string[] {\n const sanitizedTags: string[] = [];\n tags.forEach(tag => {\n let sanitizedTag: string = tag;\n sanitizedTag = sanitizedTag.replace(/\\s/g, '');\n\n if (!makeValidator().isValidTag(sanitizedTag)) {\n if (logger !== undefined) {\n logger.error(\n `invalid tag: ${sanitizedTag}. Tags are expected to be less than 63 characters and conform to: ^[a-z0-9:+#]+(\\-[a-z0-9:+#]+)*$`,\n );\n }\n return;\n }\n sanitizedTags.push(sanitizedTag);\n });\n return sanitizedTags;\n}\n"],"names":["makeValidator"],"mappings":";;;;AAoBA,MAAM,YAAA,GAAe,UAAA;AAcd,SAAS,uBAAA,CACd,YAAA,EACA,MAAA,EACA,MAAA,EACU;AACV,EAAA,IAAI,CAAC,aAAa,WAAA,EAAa;AAI7B,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,IAAI,CAAC,YAAA,CAAa,WAAA,CAAY,GAAA,EAAK,GAAA,EAAK;AAItC,IAAA,OAAO,EAAC;AAAA,EACV;AAEA,EAAA,MAAM,cAAc,YAAA,CAAa,WAAA;AACjC,EAAA,MAAM,SAAS,YAAA,CAAa,MAAA;AAE5B,EAAA,MAAM,OAAO,YAAA,CAAa,WAAA,CAAY,IAAA,IAAQ,EAAU,CAAA;AACxD,EAAA,IAAI,WAAA,CAAY,cAAA,K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A;AAC9C;AACF;AACF,GACF;AAEA,EAAA,OAAO,CAAC,MAAM,CAAA;AAChB;AAEA,SAAS,qBAAqB,SAAA,EAA2B;AACvD,EAAA,OAAO,SAAA,CAAU,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AACpC;AAEA,SAAS,YAAA,CAAa,MAAgB,MAAA,EAAkC;AACtE,EAAA,MAAM,gBAA0B,EAAC;AACjC,EAAA,IAAA,CAAK,QAAQ,CAAA,GAAA,KAAO;AAClB,IAAA,IAAI,YAAA,GAAuB,GAAA;AAC3B,IAAA,YAAA,GAAe,YAAA,CAAa,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAE7C,IAAA,IAAI,CAACA,0BAAA,EAAc,CAAE,UAAA,CAAW,YAAY,CAAA,EAAG;AAM7C,MAAA;AAAA,IACF;AACA,IAAA,aAAA,CAAc,KAAK,YAAY,CAAA;AAAA,EACjC,CAAC,CAAA;AACD,EAAA,OAAO,aAAA;AACT;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,12 +19,16 @@ interface ModelCatalogKeys {
|
|
|
19
19
|
* fetchModelCatalogKeys retrieves the keys for each of the model catalog entries in the model catalog bridge service
|
|
20
20
|
* @public
|
|
21
21
|
*/
|
|
22
|
-
declare function fetchModelCatalogKeys(baseUrl: string
|
|
22
|
+
declare function fetchModelCatalogKeys(baseUrl: string, token: {
|
|
23
|
+
token: string;
|
|
24
|
+
}): Promise<string[]>;
|
|
23
25
|
/**
|
|
24
26
|
* fetchModelCatalogFromKey fetches a model catalog JSON object from the bridge based on a given key
|
|
25
27
|
* @public
|
|
26
28
|
*/
|
|
27
|
-
declare function fetchModelCatalogFromKey(baseUrl: string, modelCatalogKey: string
|
|
29
|
+
declare function fetchModelCatalogFromKey(baseUrl: string, modelCatalogKey: string, token?: {
|
|
30
|
+
token: string;
|
|
31
|
+
}): Promise<ModelCatalog>;
|
|
28
32
|
|
|
29
33
|
export { catalogModuleModelCatalogResourceEntityProvider as default, fetchModelCatalogFromKey, fetchModelCatalogKeys };
|
|
30
34
|
export type { ModelCatalogKeys };
|
package/dist/module.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
4
|
-
var
|
|
4
|
+
var pluginCatalogNode = require('@backstage/plugin-catalog-node');
|
|
5
5
|
var ModelCatalogResourceEntityProvider = require('./providers/ModelCatalogResourceEntityProvider.cjs.js');
|
|
6
6
|
|
|
7
7
|
const catalogModuleModelCatalogResourceEntityProvider = backendPluginApi.createBackendModule({
|
|
@@ -10,15 +10,17 @@ const catalogModuleModelCatalogResourceEntityProvider = backendPluginApi.createB
|
|
|
10
10
|
register(env) {
|
|
11
11
|
env.registerInit({
|
|
12
12
|
deps: {
|
|
13
|
-
catalog:
|
|
13
|
+
catalog: pluginCatalogNode.catalogProcessingExtensionPoint,
|
|
14
14
|
config: backendPluginApi.coreServices.rootConfig,
|
|
15
|
+
discovery: backendPluginApi.coreServices.discovery,
|
|
16
|
+
auth: backendPluginApi.coreServices.auth,
|
|
15
17
|
logger: backendPluginApi.coreServices.logger,
|
|
16
18
|
scheduler: backendPluginApi.coreServices.scheduler
|
|
17
19
|
},
|
|
18
|
-
async init({ catalog, config, logger, scheduler }) {
|
|
19
|
-
|
|
20
|
-
ModelCatalogResourceEntityProvider.ModelCatalogResourceEntityProvider.fromConfig(
|
|
21
|
-
{ config, logger },
|
|
20
|
+
async init({ catalog, config, discovery, auth, logger, scheduler }) {
|
|
21
|
+
try {
|
|
22
|
+
const ep = ModelCatalogResourceEntityProvider.ModelCatalogResourceEntityProvider.fromConfig(
|
|
23
|
+
{ config, logger, discovery, auth },
|
|
22
24
|
{
|
|
23
25
|
schedule: scheduler.createScheduledTaskRunner({
|
|
24
26
|
frequency: { seconds: 30 },
|
|
@@ -26,8 +28,12 @@ const catalogModuleModelCatalogResourceEntityProvider = backendPluginApi.createB
|
|
|
26
28
|
}),
|
|
27
29
|
scheduler
|
|
28
30
|
}
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
+
);
|
|
32
|
+
catalog.addEntityProvider(ep);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error(error);
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
});
|
|
33
39
|
}
|
package/dist/module.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node
|
|
1
|
+
{"version":3,"file":"module.cjs.js","sources":["../src/module.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport {\n coreServices,\n createBackendModule,\n} from '@backstage/backend-plugin-api';\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node';\n\nimport { ModelCatalogResourceEntityProvider } from './providers';\n\n/**\n * catalogModuleModelCatalogResourceEntityProvider defines the model catalog entity provider which runs on startup\n *\n * @public\n */\nexport const catalogModuleModelCatalogResourceEntityProvider =\n createBackendModule({\n moduleId: 'catalog-backend-module-model-catalog',\n pluginId: 'catalog',\n register(env) {\n env.registerInit({\n deps: {\n catalog: catalogProcessingExtensionPoint,\n config: coreServices.rootConfig,\n discovery: coreServices.discovery,\n auth: coreServices.auth,\n logger: coreServices.logger,\n scheduler: coreServices.scheduler,\n },\n async init({ catalog, config, discovery, auth, logger, scheduler }) {\n try {\n const ep = ModelCatalogResourceEntityProvider.fromConfig(\n { config, logger, discovery, auth },\n {\n schedule: scheduler.createScheduledTaskRunner({\n frequency: { seconds: 30 },\n timeout: { minutes: 3 },\n }),\n scheduler: scheduler,\n },\n );\n catalog.addEntityProvider(ep);\n } catch (error) {\n console.error(error);\n throw error;\n }\n },\n });\n },\n });\n"],"names":["createBackendModule","catalogProcessingExtensionPoint","coreServices","ModelCatalogResourceEntityProvider"],"mappings":";;;;;;AA4BO,MAAM,kDACXA,oCAAA,CAAoB;AAAA,EAClB,QAAA,EAAU,sCAAA;AAAA,EACV,QAAA,EAAU,SAAA;AAAA,EACV,SAAS,GAAA,EAAK;AACZ,IAAA,GAAA,CAAI,YAAA,CAAa;AAAA,MACf,IAAA,EAAM;AAAA,QACJ,OAAA,EAASC,iDAAA;AAAA,QACT,QAAQC,6BAAA,CAAa,UAAA;AAAA,QACrB,WAAWA,6BAAA,CAAa,SAAA;AAAA,QACxB,MAAMA,6BAAA,CAAa,IAAA;AAAA,QACnB,QAAQA,6BAAA,CAAa,MAAA;AAAA,QACrB,WAAWA,6BAAA,CAAa;AAAA,OAC1B;AAAA,MACA,MAAM,KAAK,EAAE,OAAA,EAAS,QAAQ,SAAA,EAAW,IAAA,EAAM,MAAA,EAAQ,SAAA,EAAU,EAAG;AAClE,QAAA,IAAI;AACF,UAAA,MAAM,KAAKC,qEAAA,CAAmC,UAAA;AAAA,YAC5C,EAAE,MAAA,EAAQ,MAAA,EAAQ,SAAA,EAAW,IAAA,EAAK;AAAA,YAClC;AAAA,cACE,QAAA,EAAU,UAAU,yBAAA,CAA0B;AAAA,gBAC5C,SAAA,EAAW,EAAE,OAAA,EAAS,EAAA,EAAG;AAAA,gBACzB,OAAA,EAAS,EAAE,OAAA,EAAS,CAAA;AAAE,eACvB,CAAA;AAAA,cACD;AAAA;AACF,WACF;AACA,UAAA,OAAA,CAAQ,kBAAkB,EAAE,CAAA;AAAA,QAC9B,SAAS,KAAA,EAAO;AACd,UAAA,OAAA,CAAQ,MAAM,KAAK,CAAA;AACnB,UAAA,MAAM,KAAA;AAAA,QACR;AAAA,MACF;AAAA,KACD,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
|
|
@@ -7,9 +7,10 @@ var errors = require('@backstage/errors');
|
|
|
7
7
|
var ModelCatalogGenerator = require('../clients/ModelCatalogGenerator.cjs.js');
|
|
8
8
|
|
|
9
9
|
class ModelCatalogResourceEntityProvider {
|
|
10
|
-
|
|
11
|
-
baseUrl;
|
|
10
|
+
name;
|
|
12
11
|
logger;
|
|
12
|
+
discovery;
|
|
13
|
+
auth;
|
|
13
14
|
scheduleFn;
|
|
14
15
|
connection;
|
|
15
16
|
/**
|
|
@@ -17,7 +18,7 @@ class ModelCatalogResourceEntityProvider {
|
|
|
17
18
|
* @public
|
|
18
19
|
*/
|
|
19
20
|
static fromConfig(deps, options) {
|
|
20
|
-
const { config: config$1, logger } = deps;
|
|
21
|
+
const { config: config$1, logger, discovery, auth } = deps;
|
|
21
22
|
const providerConfigs = config.readModelCatalogApiEntityConfigs(config$1);
|
|
22
23
|
return providerConfigs.map((providerConfig) => {
|
|
23
24
|
let taskRunner;
|
|
@@ -35,14 +36,17 @@ class ModelCatalogResourceEntityProvider {
|
|
|
35
36
|
return new ModelCatalogResourceEntityProvider(
|
|
36
37
|
providerConfig,
|
|
37
38
|
logger,
|
|
39
|
+
discovery,
|
|
40
|
+
auth,
|
|
38
41
|
taskRunner
|
|
39
42
|
);
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
/** [1]: Set configuration values passed into the entity provider. Fields are defined in types.ts */
|
|
43
|
-
constructor(config, logger, taskRunner) {
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
+
constructor(config, logger, discovery, auth, taskRunner) {
|
|
47
|
+
this.name = config.id;
|
|
48
|
+
this.discovery = discovery;
|
|
49
|
+
this.auth = auth;
|
|
46
50
|
this.logger = logger.child({
|
|
47
51
|
target: this.getProviderName()
|
|
48
52
|
});
|
|
@@ -60,7 +64,7 @@ class ModelCatalogResourceEntityProvider {
|
|
|
60
64
|
} catch (error) {
|
|
61
65
|
if (errors.isError(error)) {
|
|
62
66
|
this.logger.error(
|
|
63
|
-
`Error while syncing resources from Model Catalog ${this.
|
|
67
|
+
`Error while syncing resources from Model Catalog ${this.name}`,
|
|
64
68
|
{
|
|
65
69
|
// Default Error properties:
|
|
66
70
|
name: error.name,
|
|
@@ -78,7 +82,7 @@ class ModelCatalogResourceEntityProvider {
|
|
|
78
82
|
}
|
|
79
83
|
/** [2]: Model Catalog entity provider must have a unique name */
|
|
80
84
|
getProviderName() {
|
|
81
|
-
return `ModelCatalogResourceEntityProvider:${this.
|
|
85
|
+
return `ModelCatalogResourceEntityProvider:${this.name}`;
|
|
82
86
|
}
|
|
83
87
|
/** [3]: Connect Backstage catalog engine to ModelCatalogEntityProvider */
|
|
84
88
|
async connect(connection) {
|
|
@@ -91,22 +95,40 @@ class ModelCatalogResourceEntityProvider {
|
|
|
91
95
|
throw new Error("Not initialized");
|
|
92
96
|
}
|
|
93
97
|
this.logger.info(
|
|
94
|
-
`Discovering
|
|
98
|
+
`Discovering AiModelServerAPI entities from Model Server ${this.name}`
|
|
95
99
|
);
|
|
96
|
-
|
|
100
|
+
const url = await this.discovery.getBaseUrl(this.name);
|
|
101
|
+
const backendToken = await this.auth.getPluginRequestToken({
|
|
102
|
+
onBehalfOf: await this.auth.getOwnServiceCredentials(),
|
|
103
|
+
targetPluginId: this.name
|
|
104
|
+
});
|
|
105
|
+
let catalogKeys;
|
|
106
|
+
try {
|
|
107
|
+
catalogKeys = await BridgeResourceConnector.fetchModelCatalogKeys(url, backendToken);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (errors.isError(error) && error.message === "Not Found") {
|
|
110
|
+
this.logger.debug(
|
|
111
|
+
`Connector plugin '${this.name}' not ready yet (404); will retry on next schedule`
|
|
112
|
+
);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
97
117
|
if (catalogKeys === null || catalogKeys === void 0) {
|
|
98
118
|
catalogKeys = [];
|
|
99
119
|
}
|
|
100
|
-
let entityList = [];
|
|
101
120
|
this.logger.debug(`Found ${catalogKeys.length} model catalogs`);
|
|
102
121
|
this.logger.debug(`Fetched ModelCatalog: ${JSON.stringify(catalogKeys)}`);
|
|
103
|
-
await Promise.all(
|
|
122
|
+
const entityList = (await Promise.all(
|
|
104
123
|
catalogKeys.map(async (key) => {
|
|
105
|
-
const catalog = await BridgeResourceConnector.fetchModelCatalogFromKey(
|
|
106
|
-
|
|
107
|
-
|
|
124
|
+
const catalog = await BridgeResourceConnector.fetchModelCatalogFromKey(
|
|
125
|
+
url,
|
|
126
|
+
key,
|
|
127
|
+
backendToken
|
|
128
|
+
);
|
|
129
|
+
return ModelCatalogGenerator.GenerateCatalogEntities(catalog, url);
|
|
108
130
|
})
|
|
109
|
-
);
|
|
131
|
+
)).flat();
|
|
110
132
|
entityList.forEach((entity) => {
|
|
111
133
|
if (entity.metadata.annotations === void 0) {
|
|
112
134
|
entity.metadata.annotations = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelCatalogResourceEntityProvider.cjs.js","sources":["../../src/providers/ModelCatalogResourceEntityProvider.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type {\n LoggerService,\n SchedulerService,\n SchedulerServiceTaskRunner,\n} from '@backstage/backend-plugin-api';\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-node';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n Entity,\n} from '@backstage/catalog-model';\n\nimport {\n fetchModelCatalogFromKey,\n fetchModelCatalogKeys,\n} from '../clients/BridgeResourceConnector';\nimport { ModelCatalogConfig } from './types';\nimport { readModelCatalogApiEntityConfigs } from './config';\nimport type { Config } from '@backstage/config';\nimport { InputError, isError } from '@backstage/errors';\nimport { GenerateCatalogEntities } from '../clients/ModelCatalogGenerator';\n/**\n * Provides entities from the model catalog service, allowing models and model servers to be imported into RHDH\n *\n * @public\n */\nexport class ModelCatalogResourceEntityProvider implements EntityProvider {\n private readonly env: string;\n private readonly baseUrl: string;\n private readonly logger: LoggerService;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n /**\n * Fetches the configuration values specified for the entity provider in the app-config.yaml\n * @public\n */\n static fromConfig(\n deps: {\n config: Config;\n logger: LoggerService;\n },\n options:\n | { schedule: SchedulerServiceTaskRunner }\n | { scheduler: SchedulerService },\n ): ModelCatalogResourceEntityProvider[] {\n const { config, logger } = deps;\n\n const providerConfigs = readModelCatalogApiEntityConfigs(config);\n\n return providerConfigs.map(providerConfig => {\n let taskRunner;\n if ('scheduler' in options && providerConfig.schedule) {\n taskRunner = options.scheduler.createScheduledTaskRunner(\n providerConfig.schedule,\n );\n } else if ('schedule' in options) {\n taskRunner = options.schedule;\n } else {\n throw new InputError(\n `No schedule provided via config for ModelCatalogResourceEntityProvider:${providerConfig.id}.`,\n );\n }\n\n return new ModelCatalogResourceEntityProvider(\n providerConfig,\n logger,\n taskRunner,\n );\n });\n }\n /** [1]: Set configuration values passed into the entity provider. Fields are defined in types.ts */\n private constructor(\n config: ModelCatalogConfig,\n logger: LoggerService,\n taskRunner: SchedulerServiceTaskRunner,\n ) {\n this.env = config.id;\n this.baseUrl = config.baseUrl;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(taskRunner);\n }\n\n /** Configure the schedule function and its logger */\n createScheduleFn(\n taskRunner: SchedulerServiceTaskRunner,\n ): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:run`;\n return taskRunner.run({\n id: taskId,\n fn: async () => {\n try {\n await this.run();\n } catch (error) {\n if (isError(error)) {\n // Ensure that we don't log any sensitive internal data:\n this.logger.error(\n `Error while syncing resources from Model Catalog ${this.baseUrl}`,\n {\n // Default Error properties:\n name: error.name,\n message: error.message,\n stack: error.stack,\n // Additional status code if available:\n status: (error.response as { status?: string })?.status,\n },\n );\n }\n }\n },\n });\n };\n }\n\n /** [2]: Model Catalog entity provider must have a unique name */\n getProviderName(): string {\n return `ModelCatalogResourceEntityProvider:${this.env}`;\n }\n\n /** [3]: Connect Backstage catalog engine to ModelCatalogEntityProvider */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n /** [4]: Define the function that the entity provider will execute on a set schedule */\n async run(): Promise<void> {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n this.logger.info(\n `Discovering ResourceEntities from Model Server ${this.baseUrl}`,\n );\n\n /** [5]: Fetch the model catalog keys from the bridge and fetch the corresponding catalog entries. */\n let catalogKeys = await fetchModelCatalogKeys(this.baseUrl);\n // If no models are registered yet, the catalogKeys array may be null, so handle it by setting it to be an emptyList\n if (catalogKeys === null || catalogKeys === undefined) {\n catalogKeys = [];\n }\n let entityList: Entity[] = [];\n this.logger.debug(`Found ${catalogKeys.length} model catalogs`);\n this.logger.debug(`Fetched ModelCatalog: ${JSON.stringify(catalogKeys)}`);\n\n await Promise.all(\n catalogKeys.map(async key => {\n const catalog = await fetchModelCatalogFromKey(this.baseUrl, key);\n const catalogEntities = GenerateCatalogEntities(catalog);\n entityList = entityList.concat(catalogEntities);\n }),\n );\n\n entityList.forEach(entity => {\n if (entity.metadata.annotations === undefined) {\n entity.metadata.annotations = {\n [ANNOTATION_LOCATION]: this.getProviderName(),\n [ANNOTATION_ORIGIN_LOCATION]: this.getProviderName(),\n };\n } else {\n entity.metadata.annotations[ANNOTATION_LOCATION] =\n this.getProviderName();\n entity.metadata.annotations[ANNOTATION_ORIGIN_LOCATION] =\n this.getProviderName();\n }\n });\n this.logger.debug(`Found ${entityList.length} entities`);\n this.logger.debug(`Fetched Entities: ${JSON.stringify(entityList)}`);\n /** [6]: Add/update the catalog entities that correspond to the models */\n await this.connection.applyMutation({\n type: 'full',\n entities: entityList.map(entity => ({\n entity,\n locationKey: this.getProviderName(),\n })),\n });\n }\n\n /* private getEntityLocationRef(entity: LocationEntityV1alpha1): string {\n const ref = entity.metadata.annotations?.[ANNOTATION_LOCATION];\n if (!ref) {\n throw new InputError(\n `Entity '${entity.metadata.name}' does not have the annotation ${ANNOTATION_LOCATION}`,\n );\n }\n return ref;\n }\n\n private getLocationEntity(\n urlStr: string,\n ): { entity: LocationEntityV1alpha1; locationKey: string }[] {\n const entity = locationSpecToLocationEntity({\n location: {\n type: 'rhdh-rhoai-bridge',\n target: urlStr,\n },\n });\n const locationKey = this.getEntityLocationRef(entity);\n return [{ entity, locationKey }];\n }*/\n\n /* private convertModelNameToEntityName(modelName: string): string {\n return modelName.replaceAll(/\\:/g, '-');\n }\n\n private convertModeServerName(modelName: string): string {\n return modelName.replaceAll(/\\s/g, '-').toLowerCase();\n }\n\n private buildResourceEntityFromModelEndpoint(\n models: ModelList,\n modelServerName: string,\n ): ResourceEntity[] {\n const modelResources: ResourceEntity[] = [];\n models.data.forEach(model => {\n const modelResourceEntity: ResourceEntity = {\n kind: 'Resource',\n apiVersion: 'backstage.io/v1alpha1',\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: this.getProviderName(),\n [ANNOTATION_ORIGIN_LOCATION]: this.getProviderName(),\n },\n name: `${this.convertModelNameToEntityName(model.id)}`,\n description: `STUB description`,\n links: [\n {\n url: `${this.baseUrl}`,\n title: 'Model API',\n },\n ],\n },\n spec: {\n type: `ai-model`,\n owner: `${this.owner}`,\n dependencyOf: [`component:${modelServerName}`],\n ...(this.system && { system: `${this.system}` }),\n },\n };\n modelResources.push(modelResourceEntity);\n });\n return modelResources;\n }\n\n private buildComponentEntityFromModelEndpoint(\n modelServerName: string,\n ): ComponentEntity {\n const modelServerComponent: ComponentEntity = {\n kind: 'Component',\n apiVersion: 'backstage.io/v1alpha1',\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: this.getProviderName(),\n [ANNOTATION_ORIGIN_LOCATION]: this.getProviderName(),\n },\n name: `${this.convertModeServerName(modelServerName)}`,\n description: `${this.name}`,\n links: [\n {\n url: `${this.baseUrl}`,\n title: 'Model Server API',\n },\n ],\n },\n spec: {\n type: `model-server`,\n lifecycle: 'production',\n owner: `${this.owner}`,\n ...(this.system && { system: `${this.system}` }),\n },\n };\n\n return modelServerComponent;\n }*/\n}\n"],"names":["config","readModelCatalogApiEntityConfigs","InputError","isError","fetchModelCatalogKeys","fetchModelCatalogFromKey","GenerateCatalogEntities","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION"],"mappings":";;;;;;;;AA4CO,MAAM,kCAA6D,CAAA;AAAA,EACvD,GAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACT,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,OAAO,UACL,CAAA,IAAA,EAIA,OAGsC,EAAA;AACtC,IAAM,MAAA,UAAEA,QAAQ,EAAA,MAAA,EAAW,GAAA,IAAA;AAE3B,IAAM,MAAA,eAAA,GAAkBC,wCAAiCD,QAAM,CAAA;AAE/D,IAAO,OAAA,eAAA,CAAgB,I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B;AAAA,OAClC,CAAA;AAAA,KACH,CAAA;AAAA;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkGF;;;;"}
|
|
1
|
+
{"version":3,"file":"ModelCatalogResourceEntityProvider.cjs.js","sources":["../../src/providers/ModelCatalogResourceEntityProvider.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type {\n AuthService,\n DiscoveryService,\n LoggerService,\n SchedulerService,\n SchedulerServiceTaskRunner,\n} from '@backstage/backend-plugin-api';\nimport {\n EntityProvider,\n EntityProviderConnection,\n} from '@backstage/plugin-catalog-node';\nimport {\n ANNOTATION_LOCATION,\n ANNOTATION_ORIGIN_LOCATION,\n} from '@backstage/catalog-model';\n\nimport {\n fetchModelCatalogFromKey,\n fetchModelCatalogKeys,\n} from '../clients/BridgeResourceConnector';\nimport { ModelCatalogConfig } from './types';\nimport { readModelCatalogApiEntityConfigs } from './config';\nimport type { Config } from '@backstage/config';\nimport { InputError, isError } from '@backstage/errors';\nimport { GenerateCatalogEntities } from '../clients/ModelCatalogGenerator';\n/**\n * Provides entities from the model catalog service, allowing models and model servers to be imported into RHDH\n *\n * @public\n */\nexport class ModelCatalogResourceEntityProvider implements EntityProvider {\n private readonly name: string;\n private readonly logger: LoggerService;\n private readonly discovery: DiscoveryService;\n private readonly auth: AuthService;\n private readonly scheduleFn: () => Promise<void>;\n private connection?: EntityProviderConnection;\n\n /**\n * Fetches the configuration values specified for the entity provider in the app-config.yaml\n * @public\n */\n static fromConfig(\n deps: {\n config: Config;\n logger: LoggerService;\n discovery: DiscoveryService;\n auth: AuthService;\n },\n options:\n | { schedule: SchedulerServiceTaskRunner }\n | { scheduler: SchedulerService },\n ): ModelCatalogResourceEntityProvider[] {\n const { config, logger, discovery, auth } = deps;\n\n const providerConfigs = readModelCatalogApiEntityConfigs(config);\n\n return providerConfigs.map(providerConfig => {\n let taskRunner;\n if ('scheduler' in options && providerConfig.schedule) {\n taskRunner = options.scheduler.createScheduledTaskRunner(\n providerConfig.schedule,\n );\n } else if ('schedule' in options) {\n taskRunner = options.schedule;\n } else {\n throw new InputError(\n `No schedule provided via config for ModelCatalogResourceEntityProvider:${providerConfig.id}.`,\n );\n }\n\n return new ModelCatalogResourceEntityProvider(\n providerConfig,\n logger,\n discovery,\n auth,\n taskRunner,\n );\n });\n }\n /** [1]: Set configuration values passed into the entity provider. Fields are defined in types.ts */\n private constructor(\n config: ModelCatalogConfig,\n logger: LoggerService,\n discovery: DiscoveryService,\n auth: AuthService,\n taskRunner: SchedulerServiceTaskRunner,\n ) {\n this.name = config.id;\n this.discovery = discovery;\n this.auth = auth;\n this.logger = logger.child({\n target: this.getProviderName(),\n });\n this.scheduleFn = this.createScheduleFn(taskRunner);\n }\n\n /** Configure the schedule function and its logger */\n createScheduleFn(\n taskRunner: SchedulerServiceTaskRunner,\n ): () => Promise<void> {\n return async () => {\n const taskId = `${this.getProviderName()}:run`;\n return taskRunner.run({\n id: taskId,\n fn: async () => {\n try {\n await this.run();\n } catch (error) {\n if (isError(error)) {\n // Ensure that we don't log any sensitive internal data:\n this.logger.error(\n `Error while syncing resources from Model Catalog ${this.name}`,\n {\n // Default Error properties:\n name: error.name,\n message: error.message,\n stack: error.stack,\n // Additional status code if available:\n status: (error.response as { status?: string })?.status,\n },\n );\n }\n }\n },\n });\n };\n }\n\n /** [2]: Model Catalog entity provider must have a unique name */\n getProviderName(): string {\n return `ModelCatalogResourceEntityProvider:${this.name}`;\n }\n\n /** [3]: Connect Backstage catalog engine to ModelCatalogEntityProvider */\n async connect(connection: EntityProviderConnection): Promise<void> {\n this.connection = connection;\n await this.scheduleFn();\n }\n\n /** [4]: Define the function that the entity provider will execute on a set schedule */\n async run(): Promise<void> {\n if (!this.connection) {\n throw new Error('Not initialized');\n }\n this.logger.info(\n `Discovering AiModelServerAPI entities from Model Server ${this.name}`,\n );\n\n /** [5]: Fetch the model catalog keys from the bridge and fetch the corresponding catalog entries. */\n // the api docs for this method says to run it each time vs. once during init, as the URL can change\n const url = await this.discovery.getBaseUrl(this.name);\n const backendToken = await this.auth.getPluginRequestToken({\n onBehalfOf: await this.auth.getOwnServiceCredentials(),\n targetPluginId: this.name,\n });\n let catalogKeys: string[];\n try {\n catalogKeys = await fetchModelCatalogKeys(url, backendToken);\n } catch (error) {\n // 404 is expected during startup — the connector plugin hasn't\n // registered its routes yet. The scheduler will retry.\n if (isError(error) && error.message === 'Not Found') {\n this.logger.debug(\n `Connector plugin '${this.name}' not ready yet (404); will retry on next schedule`,\n );\n return;\n }\n throw error;\n }\n // If no models are registered yet, the catalogKeys array may be null, so handle it by setting it to be an emptyList\n if (catalogKeys === null || catalogKeys === undefined) {\n catalogKeys = [];\n }\n this.logger.debug(`Found ${catalogKeys.length} model catalogs`);\n this.logger.debug(`Fetched ModelCatalog: ${JSON.stringify(catalogKeys)}`);\n\n const entityList = (\n await Promise.all(\n catalogKeys.map(async key => {\n const catalog = await fetchModelCatalogFromKey(\n url,\n key,\n backendToken,\n );\n return GenerateCatalogEntities(catalog, url);\n }),\n )\n ).flat();\n\n entityList.forEach(entity => {\n if (entity.metadata.annotations === undefined) {\n entity.metadata.annotations = {\n [ANNOTATION_LOCATION]: this.getProviderName(),\n [ANNOTATION_ORIGIN_LOCATION]: this.getProviderName(),\n };\n } else {\n entity.metadata.annotations[ANNOTATION_LOCATION] =\n this.getProviderName();\n entity.metadata.annotations[ANNOTATION_ORIGIN_LOCATION] =\n this.getProviderName();\n }\n });\n this.logger.debug(`Found ${entityList.length} entities`);\n this.logger.debug(`Fetched Entities: ${JSON.stringify(entityList)}`);\n /** [6]: Add/update the catalog entities that correspond to the models */\n await this.connection.applyMutation({\n type: 'full',\n entities: entityList.map(entity => ({\n entity,\n locationKey: this.getProviderName(),\n })),\n });\n }\n\n /* private getEntityLocationRef(entity: LocationEntityV1alpha1): string {\n const ref = entity.metadata.annotations?.[ANNOTATION_LOCATION];\n if (!ref) {\n throw new InputError(\n `Entity '${entity.metadata.name}' does not have the annotation ${ANNOTATION_LOCATION}`,\n );\n }\n return ref;\n }\n\n private getLocationEntity(\n urlStr: string,\n ): { entity: LocationEntityV1alpha1; locationKey: string }[] {\n const entity = locationSpecToLocationEntity({\n location: {\n type: 'rhdh-rhoai-bridge',\n target: urlStr,\n },\n });\n const locationKey = this.getEntityLocationRef(entity);\n return [{ entity, locationKey }];\n }*/\n\n /* private convertModelNameToEntityName(modelName: string): string {\n return modelName.replaceAll(/\\:/g, '-');\n }\n\n private convertModeServerName(modelName: string): string {\n return modelName.replaceAll(/\\s/g, '-').toLowerCase();\n }\n\n private buildResourceEntityFromModelEndpoint(\n models: ModelList,\n modelServerName: string,\n ): ResourceEntity[] {\n const modelResources: ResourceEntity[] = [];\n models.data.forEach(model => {\n const modelResourceEntity: ResourceEntity = {\n kind: 'Resource',\n apiVersion: 'backstage.io/v1alpha1',\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: this.getProviderName(),\n [ANNOTATION_ORIGIN_LOCATION]: this.getProviderName(),\n },\n name: `${this.convertModelNameToEntityName(model.id)}`,\n description: `STUB description`,\n links: [\n {\n url: `${this.baseUrl}`,\n title: 'Model API',\n },\n ],\n },\n spec: {\n type: `ai-model`,\n owner: `${this.owner}`,\n dependencyOf: [`component:${modelServerName}`],\n ...(this.system && { system: `${this.system}` }),\n },\n };\n modelResources.push(modelResourceEntity);\n });\n return modelResources;\n }\n\n private buildComponentEntityFromModelEndpoint(\n modelServerName: string,\n ): ComponentEntity {\n const modelServerComponent: ComponentEntity = {\n kind: 'Component',\n apiVersion: 'backstage.io/v1alpha1',\n metadata: {\n annotations: {\n [ANNOTATION_LOCATION]: this.getProviderName(),\n [ANNOTATION_ORIGIN_LOCATION]: this.getProviderName(),\n },\n name: `${this.convertModeServerName(modelServerName)}`,\n description: `${this.name}`,\n links: [\n {\n url: `${this.baseUrl}`,\n title: 'Model Server API',\n },\n ],\n },\n spec: {\n type: `model-server`,\n lifecycle: 'production',\n owner: `${this.owner}`,\n ...(this.system && { system: `${this.system}` }),\n },\n };\n\n return modelServerComponent;\n }*/\n}\n"],"names":["config","readModelCatalogApiEntityConfigs","InputError","isError","fetchModelCatalogKeys","fetchModelCatalogFromKey","GenerateCatalogEntities","ANNOTATION_LOCATION","ANNOTATION_ORIGIN_LOCATION"],"mappings":";;;;;;;;AA6CO,MAAM,kCAAA,CAA6D;AAAA,EACvD,IAAA;AAAA,EACA,MAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EACA,UAAA;AAAA,EACT,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,OAAO,UAAA,CACL,IAAA,EAMA,OAAA,EAGsC;AACtC,IAAA,MAAM,UAAEA,QAAA,EAAQ,MAAA,EAAQ,SAAA,EAAW,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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkGF;;;;"}
|
|
@@ -14,13 +14,11 @@ function readModelCatalogApiEntityConfigs(config) {
|
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
16
|
function readModelCatalogApiEntityConfig(id, config) {
|
|
17
|
-
const baseUrl = config.getString("baseUrl");
|
|
18
17
|
const schedule = config.has("schedule") ? backendPluginApi.readSchedulerServiceTaskScheduleDefinitionFromConfig(
|
|
19
18
|
config.getConfig("schedule")
|
|
20
19
|
) : void 0;
|
|
21
20
|
return {
|
|
22
21
|
id,
|
|
23
|
-
baseUrl,
|
|
24
22
|
schedule
|
|
25
23
|
};
|
|
26
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs.js","sources":["../../src/providers/config.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { readSchedulerServiceTaskScheduleDefinitionFromConfig } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport type { ModelCatalogConfig } from './types';\n\n/**\n * readModelCatalogApiEntityConfigs reads the configuration for the ModelCatalog provider\n *\n * @public\n */\nexport function readModelCatalogApiEntityConfigs(\n config: Config,\n): ModelCatalogConfig[] {\n const providerConfigs = config.getOptionalConfig(\n 'catalog.providers.modelCatalog',\n );\n if (!providerConfigs) {\n return [];\n }\n return providerConfigs\n .keys()\n .map(id =>\n readModelCatalogApiEntityConfig(id, providerConfigs.getConfig(id)),\n );\n}\n\nfunction readModelCatalogApiEntityConfig(\n id: string,\n config: Config,\n): ModelCatalogConfig {\n const
|
|
1
|
+
{"version":3,"file":"config.cjs.js","sources":["../../src/providers/config.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { readSchedulerServiceTaskScheduleDefinitionFromConfig } from '@backstage/backend-plugin-api';\nimport type { Config } from '@backstage/config';\n\nimport type { ModelCatalogConfig } from './types';\n\n/**\n * readModelCatalogApiEntityConfigs reads the configuration for the ModelCatalog provider\n *\n * @public\n */\nexport function readModelCatalogApiEntityConfigs(\n config: Config,\n): ModelCatalogConfig[] {\n const providerConfigs = config.getOptionalConfig(\n 'catalog.providers.modelCatalog',\n );\n if (!providerConfigs) {\n return [];\n }\n return providerConfigs\n .keys()\n .map(id =>\n readModelCatalogApiEntityConfig(id, providerConfigs.getConfig(id)),\n );\n}\n\nfunction readModelCatalogApiEntityConfig(\n id: string,\n config: Config,\n): ModelCatalogConfig {\n const schedule = config.has('schedule')\n ? readSchedulerServiceTaskScheduleDefinitionFromConfig(\n config.getConfig('schedule'),\n )\n : undefined;\n\n return {\n id,\n schedule,\n };\n}\n"],"names":["readSchedulerServiceTaskScheduleDefinitionFromConfig"],"mappings":";;;;AAyBO,SAAS,iCACd,MAAA,EACsB;AACtB,EAAA,MAAM,kBAAkB,MAAA,CAAO,iBAAA;AAAA,IAC7B;AAAA,GACF;AACA,EAAA,IAAI,CAAC,eAAA,EAAiB;AACpB,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,OAAO,eAAA,CACJ,MAAK,CACL,GAAA;AAAA,IAAI,QACH,+BAAA,CAAgC,EAAA,EAAI,eAAA,CAAgB,SAAA,CAAU,EAAE,CAAC;AAAA,GACnE;AACJ;AAEA,SAAS,+BAAA,CACP,IACA,MAAA,EACoB;AACpB,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,GAAA,CAAI,UAAU,CAAA,GAClCA,qEAAA;AAAA,IACE,MAAA,CAAO,UAAU,UAAU;AAAA,GAC7B,GACA,MAAA;AAEJ,EAAA,OAAO;AAAA,IACL,EAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@red-hat-developer-hub/backstage-plugin-catalog-backend-module-model-catalog",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "The model-catalog backend module for the catalog plugin.",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -36,21 +36,22 @@
|
|
|
36
36
|
"postpack": "backstage-cli package postpack"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@backstage/backend-plugin-api": "^1.
|
|
40
|
-
"@backstage/catalog-client": "^1.
|
|
41
|
-
"@backstage/catalog-model": "^1.
|
|
42
|
-
"@backstage/errors": "^1.
|
|
43
|
-
"@backstage/plugin-catalog-backend": "^3.
|
|
44
|
-
"@backstage/plugin-catalog-common": "^1.1.
|
|
45
|
-
"@backstage/plugin-catalog-node": "^
|
|
39
|
+
"@backstage/backend-plugin-api": "^1.9.2",
|
|
40
|
+
"@backstage/catalog-client": "^1.16.0",
|
|
41
|
+
"@backstage/catalog-model": "^1.9.0",
|
|
42
|
+
"@backstage/errors": "^1.3.1",
|
|
43
|
+
"@backstage/plugin-catalog-backend": "^3.8.0",
|
|
44
|
+
"@backstage/plugin-catalog-common": "^1.1.10",
|
|
45
|
+
"@backstage/plugin-catalog-node": "^2.2.2",
|
|
46
|
+
"@red-hat-developer-hub/backstage-plugin-catalog-model-ai-model-server": "^0.2.0",
|
|
46
47
|
"@redhat-ai-dev/model-catalog-types": "^1.1.0",
|
|
47
48
|
"js-yaml": "^4.1.0",
|
|
48
49
|
"stream": "^0.0.3",
|
|
49
50
|
"yaml": "^2.7.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@backstage/backend-test-utils": "^1.
|
|
53
|
-
"@backstage/cli": "^0.
|
|
53
|
+
"@backstage/backend-test-utils": "^1.11.4",
|
|
54
|
+
"@backstage/cli": "^0.36.3"
|
|
54
55
|
},
|
|
55
56
|
"files": [
|
|
56
57
|
"dist"
|