Skip to content
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 @@ -304,6 +304,9 @@ public static MlConfigVersion getMlConfigVersionForNode(DiscoveryNode node) {
return fromId(node.getPre811VersionId().orElseThrow(() -> new IllegalStateException("getting legacy version id not possible")));
}

// supports fromString below
private static final Pattern ML_VERSION_PATTERN = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)(?:-\\w+)?$");

// Parse an MlConfigVersion from a string.
// Note that version "8.10.x" and "8.11.0" are silently converted to "10.0.0".
// This is to support upgrade scenarios in pre-prod QA environments.
Expand All @@ -319,7 +322,7 @@ public static MlConfigVersion fromString(String str) {
if (str.startsWith("8.10.") || str.equals("8.11.0")) {
return V_10;
}
Matcher matcher = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)(?:-\\w+)?$").matcher(str);
Matcher matcher = ML_VERSION_PATTERN.matcher(str);
if (matcher.matches() == false) {
throw new IllegalArgumentException("ML config version [" + str + "] not valid");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,6 @@ public static class TrainedModelStats implements ToXContentObject, Writeable {
private final AssignmentStats deploymentStats;
private final int pipelineCount;

private static final IngestStats EMPTY_INGEST_STATS = new IngestStats(
IngestStats.Stats.IDENTITY,
Collections.emptyList(),
Collections.emptyMap()
);

public TrainedModelStats(
String modelId,
TrainedModelSizeStats modelSizeStats,
Expand All @@ -107,7 +101,7 @@ public TrainedModelStats(
) {
this.modelId = Objects.requireNonNull(modelId);
this.modelSizeStats = modelSizeStats;
this.ingestStats = ingestStats == null ? EMPTY_INGEST_STATS : ingestStats;
this.ingestStats = ingestStats == null ? IngestStats.IDENTITY : ingestStats;
if (pipelineCount < 0) {
throw new ElasticsearchException("[{}] must be a greater than or equal to 0", PIPELINE_COUNT.getPreferredName());
}
Expand Down