Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Remove the 'no.model.state.persist' setting #67240

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ public List<Setting<?>> getSettings() {
MachineLearningField.MAX_MODEL_MEMORY_LIMIT,
MAX_LAZY_ML_NODES,
MAX_MACHINE_MEMORY_PERCENT,
AutodetectBuilder.DONT_PERSIST_MODEL_STATE_SETTING,
AutodetectBuilder.MAX_ANOMALY_RECORDS_SETTING_DYNAMIC,
MAX_OPEN_JOBS_PER_NODE,
MIN_DISK_SPACE_OFF_HEAP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ public class AutodetectBuilder {
public static final Setting<Integer> MAX_ANOMALY_RECORDS_SETTING_DYNAMIC = Setting.intSetting("xpack.ml.max_anomaly_records",
DEFAULT_MAX_NUM_RECORDS, Setting.Property.NodeScope, Setting.Property.Dynamic);

/**
* Config setting storing the flag that disables model persistence
*/
public static final Setting<Boolean> DONT_PERSIST_MODEL_STATE_SETTING = Setting.boolSetting("no.model.state.persist", false,
Setting.Property.NodeScope);

private static final int SECONDS_IN_HOUR = 3600;

/**
Expand Down Expand Up @@ -238,17 +232,11 @@ List<String> buildAutodetectCommand() {
int intervalStagger = calculateStaggeringInterval(job.getId());
logger.debug("[{}] Periodic operations staggered by {} seconds", job.getId(), intervalStagger);

// Supply a URL for persisting/restoring model state unless model
// persistence has been explicitly disabled.
if (DONT_PERSIST_MODEL_STATE_SETTING.get(settings)) {
logger.info("[{}] Will not persist model state - {} setting was set", job.getId(), DONT_PERSIST_MODEL_STATE_SETTING);
} else {
// Persist model state every few hours even if the job isn't closed
long persistInterval = (job.getBackgroundPersistInterval() == null) ?
(DEFAULT_BASE_PERSIST_INTERVAL + intervalStagger) :
job.getBackgroundPersistInterval().getSeconds();
command.add(PERSIST_INTERVAL_ARG + persistInterval);
}
// Persist model state every few hours even if the job isn't closed
long persistInterval = (job.getBackgroundPersistInterval() == null) ?
(DEFAULT_BASE_PERSIST_INTERVAL + intervalStagger) :
job.getBackgroundPersistInterval().getSeconds();
command.add(PERSIST_INTERVAL_ARG + persistInterval);

int maxQuantileInterval = BASE_MAX_QUANTILE_INTERVAL + intervalStagger;
command.add(MAX_QUANTILE_INTERVAL_ARG + maxQuantileInterval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public AutodetectProcess createAutodetectProcess(String pipelineId,
Consumer<String> onProcessCrash) {
List<Path> filesToDelete = new ArrayList<>();
ProcessPipes processPipes = new ProcessPipes(env, NAMED_PIPE_HELPER, processConnectTimeout, AutodetectBuilder.AUTODETECT,
pipelineId, null, false, true, true, params.modelSnapshot() != null,
AutodetectBuilder.DONT_PERSIST_MODEL_STATE_SETTING.get(settings) == false);
pipelineId, null, false, true, true, params.modelSnapshot() != null, true);
createNativeProcess(job, params, processPipes, filesToDelete);
boolean includeTokensField = MachineLearning.CATEGORIZATION_TOKENIZATION_IN_JAVA
&& job.getAnalysisConfig().getCategorizationFieldName() != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,15 @@ public void testBuildAutodetectCommand_defaultTimeField() {
}

public void testBuildAutodetectCommand_givenPersistModelState() {
settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
.put(AutodetectBuilder.DONT_PERSIST_MODEL_STATE_SETTING.getKey(), true).build();

Job.Builder job = buildJobBuilder("unit-test-job");

int expectedPersistInterval = 10800 + AutodetectBuilder.calculateStaggeringInterval(job.getId());

List<String> command = autodetectBuilder(job.build()).buildAutodetectCommand();
assertFalse(command.contains(AutodetectBuilder.PERSIST_INTERVAL_ARG + expectedPersistInterval));

settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
env = TestEnvironment.newEnvironment(settings);

command = autodetectBuilder(job.build()).buildAutodetectCommand();
List<String> command = autodetectBuilder(job.build()).buildAutodetectCommand();
assertTrue(command.contains(AutodetectBuilder.PERSIST_INTERVAL_ARG + expectedPersistInterval));
}

Expand Down