Skip to content

Commit

Permalink
Introduce MLFeatureEnabledSetting to MLModelManager
Browse files Browse the repository at this point in the history
Signed-off-by: b4sjoo <[email protected]>
  • Loading branch information
b4sjoo committed Sep 19, 2024
1 parent d59fced commit e184239
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
import org.opensearch.ml.engine.indices.MLIndicesHandler;
import org.opensearch.ml.engine.utils.FileUtils;
import org.opensearch.ml.profile.MLModelProfile;
import org.opensearch.ml.settings.MLFeatureEnabledSetting;
import org.opensearch.ml.stats.ActionName;
import org.opensearch.ml.stats.MLActionLevelStat;
import org.opensearch.ml.stats.MLNodeLevelStat;
Expand Down Expand Up @@ -178,6 +179,7 @@ public class MLModelManager {
private final MLTaskManager mlTaskManager;
private final MLEngine mlEngine;
private final DiscoveryNodeHelper nodeHelper;
private final MLFeatureEnabledSetting mlFeatureEnabledSetting;

private volatile Integer maxModelPerNode;
private volatile Integer maxRegisterTasksPerNode;
Expand Down Expand Up @@ -208,7 +210,8 @@ public MLModelManager(
MLTaskManager mlTaskManager,
MLModelCacheHelper modelCacheHelper,
MLEngine mlEngine,
DiscoveryNodeHelper nodeHelper
DiscoveryNodeHelper nodeHelper,
MLFeatureEnabledSetting mlFeatureEnabledSetting
) {
this.client = client;
this.sdkClient = sdkClient;
Expand All @@ -224,6 +227,7 @@ public MLModelManager(
this.mlTaskManager = mlTaskManager;
this.mlEngine = mlEngine;
this.nodeHelper = nodeHelper;
this.mlFeatureEnabledSetting = mlFeatureEnabledSetting;

this.maxModelPerNode = ML_COMMONS_MAX_MODELS_PER_NODE.get(settings);
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_MAX_MODELS_PER_NODE, it -> maxModelPerNode = it);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ public Collection<Object> createComponents(
mlTaskManager,
modelCacheHelper,
mlEngine,
nodeHelper
nodeHelper,
mlFeatureEnabledSetting
);
mlInputDatasetHandler = new MLInputDatasetHandler(client);
modelAccessControlHelper = new ModelAccessControlHelper(clusterService, settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
import org.opensearch.ml.engine.encryptor.EncryptorImpl;
import org.opensearch.ml.engine.indices.MLIndicesHandler;
import org.opensearch.ml.sdkclient.SdkClientFactory;
import org.opensearch.ml.settings.MLFeatureEnabledSetting;
import org.opensearch.ml.stats.ActionName;
import org.opensearch.ml.stats.MLActionLevelStat;
import org.opensearch.ml.stats.MLNodeLevelStat;
Expand Down Expand Up @@ -208,6 +209,8 @@ public class MLModelManagerTests extends OpenSearchTestCase {

@Mock
private MLTask pretrainedMLTask;
@Mock
MLFeatureEnabledSetting mlFeatureEnabledSetting;

@Before
public void setup() throws URISyntaxException, IOException {
Expand Down Expand Up @@ -301,7 +304,8 @@ public void setup() throws URISyntaxException, IOException {
mlTaskManager,
modelCacheHelper,
mlEngine,
nodeHelper
nodeHelper,
mlFeatureEnabledSetting
)
);

Expand Down

0 comments on commit e184239

Please sign in to comment.