Skip to content

Commit

Permalink
Use default elser deployment for product documentation (#204760)
Browse files Browse the repository at this point in the history
## Summary

Fix #204559

Use the default ELSER deployment (`.elser-2-elasticsearch`) for the
product documentation semantic_text fields instead of maintaining our
own custom deployment.

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
pgayvallet and kibanamachine authored Jan 8, 2025
1 parent ad3b988 commit 015911d
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ export {
isSupportedConnector,
type InferenceConnector,
} from './src/connectors';
export { defaultInferenceEndpoints } from './src/inference_endpoints';
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* 2.0.
*/

export { waitUntilModelDeployed } from './wait_until_model_deployed';
export { getModelInstallStatus } from './get_model_install_status';
export { installElser } from './install_elser';
/**
* Constants for all default (preconfigured) inference endpoints.
*/
export const defaultInferenceEndpoints = {
ELSER: '.elser-2-elasticsearch',
MULTILINGUAL_E5_SMALL: '.multilingual-e5-small-elasticsearch',
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* 2.0.
*/

import { defaultInferenceEndpoints } from '@kbn/inference-common';

export const productDocInstallStatusSavedObjectTypeName = 'product-doc-install-status';

/**
* The id of the inference endpoint we're creating for our product doc indices.
* Could be replaced with the default elser 2 endpoint once the default endpoint feature is available.
*/
export const internalElserInferenceId = 'kibana-internal-elser2';
export const internalElserInferenceId = defaultInferenceEndpoints.ELSER;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
} from './types';
import { productDocInstallStatusSavedObjectType } from './saved_objects';
import { PackageInstaller } from './services/package_installer';
import { InferenceEndpointManager } from './services/inference_endpoint';
import { ProductDocInstallClient } from './services/doc_install_status';
import { DocumentationManager } from './services/doc_manager';
import { SearchService } from './services/search';
Expand Down Expand Up @@ -79,15 +78,9 @@ export class ProductDocBasePlugin
);
const productDocClient = new ProductDocInstallClient({ soClient });

const endpointManager = new InferenceEndpointManager({
esClient: core.elasticsearch.client.asInternalUser,
logger: this.logger.get('endpoint-manager'),
});

const packageInstaller = new PackageInstaller({
esClient: core.elasticsearch.client.asInternalUser,
productDocClient,
endpointManager,
kibanaVersion: this.context.env.packageInfo.version,
artifactsFolder: Path.join(getDataPath(), 'ai-kb-artifacts'),
artifactRepositoryUrl: this.context.config.get().artifactRepositoryUrl,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jest.doMock('./steps', () => {
export const downloadToDiskMock = jest.fn();
export const openZipArchiveMock = jest.fn();
export const loadMappingFileMock = jest.fn();
export const ensureDefaultElserDeployedMock = jest.fn();

jest.doMock('./utils', () => {
const actual = jest.requireActual('./utils');
Expand All @@ -32,5 +33,6 @@ jest.doMock('./utils', () => {
downloadToDisk: downloadToDiskMock,
openZipArchive: openZipArchiveMock,
loadMappingFile: loadMappingFileMock,
ensureDefaultElserDeployed: ensureDefaultElserDeployedMock,
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
openZipArchiveMock,
validateArtifactArchiveMock,
fetchArtifactVersionsMock,
ensureDefaultElserDeployedMock,
} from './package_installer.test.mocks';

import {
Expand All @@ -24,7 +25,6 @@ import {
import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
import { loggerMock, type MockedLogger } from '@kbn/logging-mocks';
import { installClientMock } from '../doc_install_status/service.mock';
import { inferenceManagerMock } from '../inference_endpoint/service.mock';
import type { ProductInstallState } from '../../../common/install_status';
import { PackageInstaller } from './package_installer';

Expand All @@ -40,21 +40,18 @@ describe('PackageInstaller', () => {
let logger: MockedLogger;
let esClient: ReturnType<typeof elasticsearchServiceMock.createElasticsearchClient>;
let productDocClient: ReturnType<typeof installClientMock.create>;
let endpointManager: ReturnType<typeof inferenceManagerMock.create>;

let packageInstaller: PackageInstaller;

beforeEach(() => {
logger = loggerMock.create();
esClient = elasticsearchServiceMock.createElasticsearchClient();
productDocClient = installClientMock.create();
endpointManager = inferenceManagerMock.create();
packageInstaller = new PackageInstaller({
artifactsFolder,
logger,
esClient,
productDocClient,
endpointManager,
artifactRepositoryUrl,
kibanaVersion,
});
Expand All @@ -68,6 +65,7 @@ describe('PackageInstaller', () => {
openZipArchiveMock.mockReset();
validateArtifactArchiveMock.mockReset();
fetchArtifactVersionsMock.mockReset();
ensureDefaultElserDeployedMock.mockReset();
});

describe('installPackage', () => {
Expand All @@ -87,7 +85,7 @@ describe('PackageInstaller', () => {
productVersion: '8.16',
});
const indexName = getProductDocIndexName('kibana');
expect(endpointManager.ensureInternalElserInstalled).toHaveBeenCalledTimes(1);
expect(ensureDefaultElserDeployedMock).toHaveBeenCalledTimes(1);

expect(downloadToDiskMock).toHaveBeenCalledTimes(1);
expect(downloadToDiskMock).toHaveBeenCalledWith(
Expand Down Expand Up @@ -128,9 +126,7 @@ describe('PackageInstaller', () => {
it('executes the steps in the right order', async () => {
await packageInstaller.installPackage({ productName: 'kibana', productVersion: '8.16' });

expect(callOrder(endpointManager.ensureInternalElserInstalled)).toBeLessThan(
callOrder(downloadToDiskMock)
);
expect(callOrder(ensureDefaultElserDeployedMock)).toBeLessThan(callOrder(downloadToDiskMock));
expect(callOrder(downloadToDiskMock)).toBeLessThan(callOrder(openZipArchiveMock));
expect(callOrder(openZipArchiveMock)).toBeLessThan(callOrder(loadMappingFileMock));
expect(callOrder(loadMappingFileMock)).toBeLessThan(callOrder(createIndexMock));
Expand Down
Loading

0 comments on commit 015911d

Please sign in to comment.