mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Fix double-prefixing of 'ml.inference'
This commit is contained in:
parent
952f57ae72
commit
5c20206ebf
2 changed files with 42 additions and 2 deletions
|
@ -232,6 +232,41 @@ describe('generateMlInferencePipelineBody lib function', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('should return something that safely removes redundant prefixes', () => {
|
||||
const mockTextClassificationModel: MlTrainedModelConfig = {
|
||||
...mockModel,
|
||||
...{ inference_config: { text_classification: {} } },
|
||||
};
|
||||
const actual: MlInferencePipeline = generateMlInferencePipelineBody({
|
||||
description: 'my-description',
|
||||
model: mockTextClassificationModel,
|
||||
pipelineName: 'my-pipeline',
|
||||
fieldMappings: [{ sourceField: 'my-source-field', targetField: 'ml.inference.my-source-field_expanded' }],
|
||||
});
|
||||
|
||||
expect(actual).toEqual(
|
||||
expect.objectContaining({
|
||||
description: expect.any(String),
|
||||
processors: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
remove: {
|
||||
field: 'ml.inference.my-source-field_expanded',
|
||||
ignore_missing: true,
|
||||
},
|
||||
}),
|
||||
expect.objectContaining({
|
||||
inference: expect.objectContaining({
|
||||
field_map: {
|
||||
'my-source-field': 'MODEL_INPUT_FIELD',
|
||||
},
|
||||
target_field: 'ml.inference.my-source-field_expanded',
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should return something expected with multiple fields', () => {
|
||||
const actual: MlInferencePipeline = generateMlInferencePipelineBody({
|
||||
description: 'my-description',
|
||||
|
|
|
@ -224,7 +224,9 @@ export const parseMlInferenceParametersFromPipeline = (
|
|||
return null;
|
||||
}
|
||||
return {
|
||||
destination_field: inferenceProcessor.target_field?.replace('ml.inference.', ''),
|
||||
destination_field: inferenceProcessor.target_field
|
||||
? stripMlInferencePrefix(inferenceProcessor.target_field)
|
||||
: inferenceProcessor.target_field,
|
||||
model_id: inferenceProcessor.model_id,
|
||||
pipeline_name: name,
|
||||
source_field: sourceField,
|
||||
|
@ -258,4 +260,7 @@ export const parseModelStateFromStats = (
|
|||
export const parseModelStateReasonFromStats = (trainedModelStats?: Partial<MlTrainedModelStats>) =>
|
||||
trainedModelStats?.deployment_stats?.reason;
|
||||
|
||||
export const getMlInferencePrefixedFieldName = (fieldName: string) => `ml.inference.${fieldName}`;
|
||||
export const getMlInferencePrefixedFieldName = (fieldName: string) =>
|
||||
`ml.inference.${stripMlInferencePrefix(fieldName)}`; // Strip first, then prepend, to prevent against double-prepending
|
||||
|
||||
const stripMlInferencePrefix = (fieldName: string) => fieldName.replace('ml.inference.', '');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue