Skip to content

Commit

Permalink
[ML] Removing log error statements when no ingest pipelines exist (#1…
Browse files Browse the repository at this point in the history
…17281)

* [ML] Removing log error statements when no ingest pipileins exist

* removing non 200 status code check
  • Loading branch information
jgowdyelastic authored Nov 3, 2021
1 parent 7432b9b commit 2cd007e
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,31 @@ export function modelsProvider(
modelIds.map((id: string) => [id, null])
);

const { body, statusCode } = await client.asCurrentUser.ingest.getPipeline();

if (statusCode !== 200) {
return modelIdsMap;
}

for (const [pipelineName, pipelineDefinition] of Object.entries(body)) {
const { processors } = pipelineDefinition as { processors: Array<Record<string, any>> };

for (const processor of processors) {
const id = processor.inference?.model_id;
if (modelIdsMap.has(id)) {
const obj = modelIdsMap.get(id);
if (obj === null) {
modelIdsMap.set(id, { [pipelineName]: pipelineDefinition });
} else {
obj![pipelineName] = pipelineDefinition;
try {
const { body } = await client.asCurrentUser.ingest.getPipeline();

for (const [pipelineName, pipelineDefinition] of Object.entries(body)) {
const { processors } = pipelineDefinition as { processors: Array<Record<string, any>> };

for (const processor of processors) {
const id = processor.inference?.model_id;
if (modelIdsMap.has(id)) {
const obj = modelIdsMap.get(id);
if (obj === null) {
modelIdsMap.set(id, { [pipelineName]: pipelineDefinition });
} else {
obj![pipelineName] = pipelineDefinition;
}
}
}
}
} catch (error) {
if (error.statusCode === 404) {
// ES returns 404 when there are no pipelines
// Instead, we should return the modelIdsMap and a 200
return modelIdsMap;
}
throw error;
}

return modelIdsMap;
Expand Down

0 comments on commit 2cd007e

Please sign in to comment.