[ML] deprecate estimated_heap_memory_usage_bytes and replace with model_size_bytes (#80545)

This deprecates estimated_heap_memory_usage_bytes on model put and replaces it with model_size_bytes.

On GET, both fields are returned (unless storing in the index) and are populated with the same field.

For the ml/info API, both fields are returned as well.
This commit is contained in:
Benjamin Trent 2021-11-10 11:24:04 -05:00 committed by GitHub
parent 7c8a37e3d2
commit 4724553d91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 150 additions and 81 deletions

View file

@ -42,7 +42,9 @@ public class TrainedModelConfig implements ToXContentObject {
public static final ParseField TAGS = new ParseField("tags");
public static final ParseField METADATA = new ParseField("metadata");
public static final ParseField INPUT = new ParseField("input");
@Deprecated
public static final ParseField ESTIMATED_HEAP_MEMORY_USAGE_BYTES = new ParseField("estimated_heap_memory_usage_bytes");
public static final ParseField MODEL_SIZE_BYTES = new ParseField("model_size_bytes", "estimated_heap_memory_usage_bytes");
public static final ParseField ESTIMATED_OPERATIONS = new ParseField("estimated_operations");
public static final ParseField LICENSE_LEVEL = new ParseField("license_level");
public static final ParseField DEFAULT_FIELD_MAP = new ParseField("default_field_map");
@ -65,7 +67,7 @@ public class TrainedModelConfig implements ToXContentObject {
PARSER.declareStringArray(TrainedModelConfig.Builder::setTags, TAGS);
PARSER.declareObject(TrainedModelConfig.Builder::setMetadata, (p, c) -> p.map(), METADATA);
PARSER.declareObject(TrainedModelConfig.Builder::setInput, (p, c) -> TrainedModelInput.fromXContent(p), INPUT);
PARSER.declareLong(TrainedModelConfig.Builder::setEstimatedHeapMemory, ESTIMATED_HEAP_MEMORY_USAGE_BYTES);
PARSER.declareLong(TrainedModelConfig.Builder::setModelSize, MODEL_SIZE_BYTES);
PARSER.declareLong(TrainedModelConfig.Builder::setEstimatedOperations, ESTIMATED_OPERATIONS);
PARSER.declareString(TrainedModelConfig.Builder::setLicenseLevel, LICENSE_LEVEL);
PARSER.declareObject(TrainedModelConfig.Builder::setDefaultFieldMap, (p, c) -> p.mapStrings(), DEFAULT_FIELD_MAP);
@ -90,7 +92,7 @@ public class TrainedModelConfig implements ToXContentObject {
private final List<String> tags;
private final Map<String, Object> metadata;
private final TrainedModelInput input;
private final Long estimatedHeapMemory;
private final Long modelSize;
private final Long estimatedOperations;
private final String licenseLevel;
private final Map<String, String> defaultFieldMap;
@ -107,7 +109,7 @@ public class TrainedModelConfig implements ToXContentObject {
List<String> tags,
Map<String, Object> metadata,
TrainedModelInput input,
Long estimatedHeapMemory,
Long modelSize,
Long estimatedOperations,
String licenseLevel,
Map<String, String> defaultFieldMap,
@ -123,7 +125,7 @@ public class TrainedModelConfig implements ToXContentObject {
this.tags = tags == null ? null : Collections.unmodifiableList(tags);
this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
this.input = input;
this.estimatedHeapMemory = estimatedHeapMemory;
this.modelSize = modelSize;
this.estimatedOperations = estimatedOperations;
this.licenseLevel = licenseLevel;
this.defaultFieldMap = defaultFieldMap == null ? null : Collections.unmodifiableMap(defaultFieldMap);
@ -170,16 +172,36 @@ public class TrainedModelConfig implements ToXContentObject {
return input;
}
/**
* @deprecated use {@link TrainedModelConfig#getModelSize()} instead
* @return the {@link ByteSizeValue} of the model size if available.
*/
@Deprecated
public ByteSizeValue getEstimatedHeapMemory() {
return estimatedHeapMemory == null ? null : new ByteSizeValue(estimatedHeapMemory);
return modelSize == null ? null : new ByteSizeValue(modelSize);
}
/**
* @deprecated use {@link TrainedModelConfig#getModelSizeBytes()} instead
* @return the model size in bytes if available.
*/
@Deprecated
public Long getEstimatedHeapMemoryBytes() {
return estimatedHeapMemory;
return modelSize;
}
public Long getEstimatedOperations() {
return estimatedOperations;
/**
* @return the {@link ByteSizeValue} of the model size if available.
*/
public ByteSizeValue getModelSize() {
return modelSize == null ? null : new ByteSizeValue(modelSize);
}
/**
* @return the model size in bytes if available.
*/
public Long getModelSizeBytes() {
return modelSize;
}
public String getLicenseLevel() {
@ -228,8 +250,8 @@ public class TrainedModelConfig implements ToXContentObject {
if (input != null) {
builder.field(INPUT.getPreferredName(), input);
}
if (estimatedHeapMemory != null) {
builder.field(ESTIMATED_HEAP_MEMORY_USAGE_BYTES.getPreferredName(), estimatedHeapMemory);
if (modelSize != null) {
builder.field(MODEL_SIZE_BYTES.getPreferredName(), modelSize);
}
if (estimatedOperations != null) {
builder.field(ESTIMATED_OPERATIONS.getPreferredName(), estimatedOperations);
@ -269,7 +291,7 @@ public class TrainedModelConfig implements ToXContentObject {
&& Objects.equals(compressedDefinition, that.compressedDefinition)
&& Objects.equals(tags, that.tags)
&& Objects.equals(input, that.input)
&& Objects.equals(estimatedHeapMemory, that.estimatedHeapMemory)
&& Objects.equals(modelSize, that.modelSize)
&& Objects.equals(estimatedOperations, that.estimatedOperations)
&& Objects.equals(licenseLevel, that.licenseLevel)
&& Objects.equals(defaultFieldMap, that.defaultFieldMap)
@ -288,7 +310,7 @@ public class TrainedModelConfig implements ToXContentObject {
compressedDefinition,
description,
tags,
estimatedHeapMemory,
modelSize,
estimatedOperations,
metadata,
licenseLevel,
@ -310,7 +332,7 @@ public class TrainedModelConfig implements ToXContentObject {
private TrainedModelDefinition definition;
private String compressedDefinition;
private TrainedModelInput input;
private Long estimatedHeapMemory;
private Long modelSize;
private Long estimatedOperations;
private String licenseLevel;
private Map<String, String> defaultFieldMap;
@ -379,8 +401,8 @@ public class TrainedModelConfig implements ToXContentObject {
return this;
}
private Builder setEstimatedHeapMemory(Long estimatedHeapMemory) {
this.estimatedHeapMemory = estimatedHeapMemory;
private Builder setModelSize(Long modelSize) {
this.modelSize = modelSize;
return this;
}
@ -416,7 +438,7 @@ public class TrainedModelConfig implements ToXContentObject {
tags,
metadata,
input,
estimatedHeapMemory,
modelSize,
estimatedOperations,
licenseLevel,
defaultFieldMap,