Skip to content

Commit

Permalink
remove extras
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle committed Oct 12, 2023
1 parent 60567a7 commit 7dd4b35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -750,13 +750,14 @@ private void cacheEvictionListener(RemovalNotification<String, ModelAndConsumer>

@Override
public void clusterChanged(ClusterChangedEvent event) {
// If no changes to ingest pipelines and no model alias changes, nothing to do
if (event.changedCustomMetadataSet().contains(IngestMetadata.TYPE) == false
&& event.changedCustomMetadataSet().contains(ModelAliasMetadata.NAME) == false) {
final boolean prefetchModels = event.state().nodes().getLocalNode().isIngestNode();
// If we are not prefetching models and there were no model alias changes, don't bother handling the changes
if ((prefetchModels == false)
&& (event.changedCustomMetadataSet().contains(IngestMetadata.TYPE) == false)
&& (event.changedCustomMetadataSet().contains(ModelAliasMetadata.NAME) == false)) {
return;
}

final boolean prefetchModels = event.state().nodes().getLocalNode().isIngestNode();
ClusterState state = event.state();
IngestMetadata currentIngestMetadata = state.metadata().custom(IngestMetadata.TYPE);
Set<String> allReferencedModelKeys = event.changedCustomMetadataSet().contains(IngestMetadata.TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,26 +656,6 @@ public void testAliasesGetUpdatedEvenWhenNotIngestNode() throws IOException {
assertThat(modelLoadingService.getModelId("loaded_model_again"), equalTo(model1));
}

public void testEarlyExitOnIrrelevantClusterChangeEvent() {
ModelLoadingService modelLoadingService = new ModelLoadingService(
trainedModelProvider,
auditor,
threadPool,
clusterService,
trainedModelStatsService,
Settings.EMPTY,
"test-node",
circuitBreaker,
mock(XPackLicenseState.class)
);

ClusterChangedEvent event = mock(ClusterChangedEvent.class);
when(event.changedCustomMetadataSet()).thenReturn(Set.of());
modelLoadingService.clusterChanged(event);

verify(event, never()).state();
}

@SuppressWarnings("unchecked")
private void withTrainedModel(String modelId, long size) {
InferenceDefinition definition = mock(InferenceDefinition.class);
Expand Down

0 comments on commit 7dd4b35

Please sign in to comment.