Skip to content

Commit c7a2391

Browse files
authored
remove catalog process and associated entity provider form catalog-backend-model-catalog (#1375)
1 parent 84f6b42 commit c7a2391

9 files changed

Lines changed: 3 additions & 821 deletions

File tree

workspaces/ai-integrations/packages/backend/src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
*/
1616

1717
import { createBackend } from '@backstage/backend-defaults';
18-
import {
19-
catalogModuleRHDHRHOAIReaderProcessor,
20-
catalogModuleRHDHRHOAILocationsExtensionPoint,
21-
catalogModuleRHDHRHOAIEntityProvider,
22-
} from '@red-hat-developer-hub/backstage-plugin-catalog-backend-module-model-catalog';
2318

2419
const backend = createBackend();
2520

@@ -69,9 +64,7 @@ backend.add(
6964
'@red-hat-developer-hub/backstage-plugin-catalog-backend-module-model-catalog'
7065
),
7166
);
72-
backend.add(catalogModuleRHDHRHOAILocationsExtensionPoint);
73-
backend.add(catalogModuleRHDHRHOAIReaderProcessor);
74-
backend.add(catalogModuleRHDHRHOAIEntityProvider);
67+
7568
backend.add(
7669
import('@red-hat-developer-hub/backstage-plugin-ai-experience-backend'),
7770
);

workspaces/ai-integrations/plugins/catalog-backend-module-model-catalog/report.api.md

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,12 @@
44
55
```ts
66
import { BackendFeature } from '@backstage/backend-plugin-api';
7-
import { CatalogProcessor } from '@backstage/plugin-catalog-node';
8-
import { CatalogProcessorEmit } from '@backstage/plugin-catalog-node';
9-
import type { Config } from '@backstage/config';
10-
import { EntityProvider } from '@backstage/plugin-catalog-node';
11-
import { EntityProviderConnection } from '@backstage/plugin-catalog-node';
12-
import { LocationSpec } from '@backstage/plugin-catalog-common';
13-
import { LoggerService } from '@backstage/backend-plugin-api';
147
import { ModelCatalog } from '@redhat-ai-dev/model-catalog-types';
15-
import { RootConfigService } from '@backstage/backend-plugin-api';
16-
import type { SchedulerService } from '@backstage/backend-plugin-api';
17-
import type { SchedulerServiceTaskRunner } from '@backstage/backend-plugin-api';
18-
import type { SchedulerServiceTaskScheduleDefinition } from '@backstage/backend-plugin-api';
19-
import { UrlReaderService } from '@backstage/backend-plugin-api';
208

219
// @public
2210
const catalogModuleModelCatalogResourceEntityProvider: BackendFeature;
2311
export default catalogModuleModelCatalogResourceEntityProvider;
2412

25-
// @public
26-
export const catalogModuleRHDHRHOAIEntityProvider: BackendFeature;
27-
28-
// @public
29-
export const catalogModuleRHDHRHOAILocationsExtensionPoint: BackendFeature;
30-
31-
// @public
32-
export const catalogModuleRHDHRHOAIReaderProcessor: BackendFeature;
33-
3413
// @public
3514
export function fetchModelCatalogFromKey(
3615
baseUrl: string,
@@ -40,57 +19,9 @@ export function fetchModelCatalogFromKey(
4019
// @public
4120
export function fetchModelCatalogKeys(baseUrl: string): Promise<string[]>;
4221

43-
// @public
44-
export type ModelCatalogConfig = {
45-
id: string;
46-
baseUrl: string;
47-
schedule?: SchedulerServiceTaskScheduleDefinition;
48-
};
49-
5022
// @public
5123
export interface ModelCatalogKeys {
5224
// (undocumented)
5325
uris: string[];
5426
}
55-
56-
// @public
57-
export class ModelCatalogResourceEntityProvider implements EntityProvider {
58-
connect(connection: EntityProviderConnection): Promise<void>;
59-
createScheduleFn(taskRunner: SchedulerServiceTaskRunner): () => Promise<void>;
60-
static fromConfig(
61-
deps: {
62-
config: Config;
63-
logger: LoggerService;
64-
},
65-
options:
66-
| {
67-
schedule: SchedulerServiceTaskRunner;
68-
}
69-
| {
70-
scheduler: SchedulerService;
71-
},
72-
): ModelCatalogResourceEntityProvider[];
73-
getProviderName(): string;
74-
run(): Promise<void>;
75-
}
76-
77-
// @public
78-
export function readModelCatalogApiEntityConfigs(
79-
config: Config,
80-
): ModelCatalogConfig[];
81-
82-
// @public
83-
export class RHDHRHOAIReaderProcessor implements CatalogProcessor {
84-
constructor(
85-
reader: UrlReaderService,
86-
config: RootConfigService,
87-
logger: LoggerService,
88-
);
89-
getProcessorName(): string;
90-
readLocation(
91-
location: LocationSpec,
92-
_optional: boolean,
93-
emit: CatalogProcessorEmit,
94-
): Promise<boolean>;
95-
}
9627
```

workspaces/ai-integrations/plugins/catalog-backend-module-model-catalog/src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,4 @@
2222

2323
// export * from './clients';
2424
export { catalogModuleModelCatalogResourceEntityProvider as default } from './module';
25-
export { catalogModuleRHDHRHOAIReaderProcessor } from './module';
26-
export { catalogModuleRHDHRHOAILocationsExtensionPoint } from './module';
27-
export { catalogModuleRHDHRHOAIEntityProvider } from './module';
28-
export * from './providers';
29-
export * from './processors';
3025
export * from './clients';

workspaces/ai-integrations/plugins/catalog-backend-module-model-catalog/src/module.test.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {
18-
catalogModuleModelCatalogResourceEntityProvider,
19-
catalogModuleRHDHRHOAIReaderProcessor,
20-
catalogModuleRHDHRHOAILocationsExtensionPoint,
21-
catalogModuleRHDHRHOAIEntityProvider,
22-
} from './module';
17+
import { catalogModuleModelCatalogResourceEntityProvider } from './module';
2318

2419
describe('model-catalog', () => {
2520
it('should export entity providers and processor', () => {
2621
expect(catalogModuleModelCatalogResourceEntityProvider).toBeDefined();
27-
expect(catalogModuleRHDHRHOAIReaderProcessor).toBeDefined();
28-
expect(catalogModuleRHDHRHOAILocationsExtensionPoint).toBeDefined();
29-
expect(catalogModuleRHDHRHOAIEntityProvider).toBeDefined();
3022
});
3123
});

workspaces/ai-integrations/plugins/catalog-backend-module-model-catalog/src/module.ts

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ import {
1717
coreServices,
1818
createBackendModule,
1919
} from '@backstage/backend-plugin-api';
20-
import {
21-
catalogProcessingExtensionPoint,
22-
catalogLocationsExtensionPoint,
23-
} from '@backstage/plugin-catalog-node/alpha';
20+
import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';
2421

2522
import { ModelCatalogResourceEntityProvider } from './providers';
26-
import { RHDHRHOAIReaderProcessor } from './processors';
27-
import { RHDHRHOAIEntityProvider } from './providers/RHDHRHOAIEntityProvider';
2823

2924
/**
3025
* catalogModuleModelCatalogResourceEntityProvider defines the model catalog entity provider which runs on startup
@@ -60,96 +55,3 @@ export const catalogModuleModelCatalogResourceEntityProvider =
6055
});
6156
},
6257
});
63-
64-
/**
65-
* catalogModuleRHDHRHOAIReaderProcessor defines the custom processor used to ingest updated/newly
66-
* discovered model catalog entities
67-
*
68-
* @public
69-
*/
70-
export const catalogModuleRHDHRHOAIReaderProcessor = createBackendModule({
71-
pluginId: 'catalog',
72-
moduleId: 'rhdh-rhoai-bridge-reader-processor',
73-
register(env) {
74-
env.registerInit({
75-
deps: {
76-
catalog: catalogProcessingExtensionPoint,
77-
reader: coreServices.urlReader,
78-
config: coreServices.rootConfig,
79-
logger: coreServices.logger,
80-
},
81-
async init({ catalog, reader, config, logger }) {
82-
catalog.addProcessor(
83-
new RHDHRHOAIReaderProcessor(reader, config, logger),
84-
);
85-
},
86-
});
87-
},
88-
});
89-
90-
/** so a `CatalogProcessor` does not need to also provide a `CatalogLocationsExtensionPoint` if it only supports imports of locations
91-
* from the app-config.yaml on startup, but if you want to dynamically add Locations via the catalog's REST API (like what the UI does for import
92-
* of catalog-info.yaml from git repos) then you need to also provide a `CatalogLocationsExtension` point to add your type to the default list of 'url' and 'file';
93-
* fwiw in examining the core Backstage code, none of the default `CatalogProcessors` bother to also provide a `CatalogLocationsExtension`; however,
94-
* we want to allow our RHDH bridge to import new locations dynamically
95-
*
96-
* @public
97-
*/
98-
export const catalogModuleRHDHRHOAILocationsExtensionPoint =
99-
createBackendModule({
100-
pluginId: 'catalog',
101-
moduleId: 'rhdh-rhoai-bridge-location-extension-point',
102-
register(env) {
103-
env.registerInit({
104-
deps: {
105-
catalog: catalogLocationsExtensionPoint,
106-
logger: coreServices.logger,
107-
},
108-
async init({ catalog, logger }) {
109-
// setAllowedLocationTypes does not add to the list but replaces it, so we preserve the default options of 'file' and 'url'
110-
logger
111-
.child({ source: 'catalog-backend-module-model-catalog"' })
112-
.info("Registering the 'rhdh-rhoai-bridge' location type");
113-
const allowedLocationTypes = ['file', 'url', 'rhdh-rhoai-bridge'];
114-
catalog.setAllowedLocationTypes(allowedLocationTypes);
115-
},
116-
});
117-
},
118-
});
119-
120-
/**
121-
* catalogModuleRHDHRHOAIEntityProvider defines the entity provider used to handle ingestion/cleanup of locations in the model catalog
122-
*
123-
* @public
124-
*/
125-
export const catalogModuleRHDHRHOAIEntityProvider = createBackendModule({
126-
pluginId: 'catalog',
127-
moduleId: 'rhdh-rhoai-bridge-entiry-provider',
128-
register(env) {
129-
env.registerInit({
130-
deps: {
131-
catalog: catalogProcessingExtensionPoint,
132-
config: coreServices.rootConfig,
133-
discovery: coreServices.discovery,
134-
logger: coreServices.logger,
135-
scheduler: coreServices.scheduler,
136-
reader: coreServices.urlReader,
137-
},
138-
async init({ catalog, config, logger, scheduler, discovery, reader }) {
139-
const runner = scheduler.createScheduledTaskRunner({
140-
frequency: { seconds: 30 },
141-
timeout: { minutes: 3 },
142-
});
143-
catalog.addEntityProvider(
144-
new RHDHRHOAIEntityProvider(
145-
discovery,
146-
config,
147-
logger,
148-
runner,
149-
reader,
150-
),
151-
);
152-
},
153-
});
154-
},
155-
});

0 commit comments

Comments
 (0)