Skip to content

Commit

Permalink
Merge branch 'main' into auto-ops/service-account
Browse files Browse the repository at this point in the history
  • Loading branch information
pickypg committed Jul 26, 2024
2 parents 2313b94 + cf480a5 commit 81f89a7
Show file tree
Hide file tree
Showing 65 changed files with 626 additions and 276 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/111366.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 111366
summary: "[Inference API] Replace `model_id` with `inference_id` in inference API\
\ except when stored"
area: Machine Learning
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;

@ESIntegTestCase.SuiteScopeTestCase
Expand Down Expand Up @@ -93,6 +92,7 @@ public void testRandomSamplerConsistentSeed() {
double[] sampleMonotonicValue = new double[1];
double[] sampleNumericValue = new double[1];
long[] sampledDocCount = new long[1];
double tolerance = 1e-14;
// initialize the values
assertResponse(
prepareSearch("idx").setPreference("shard:0")
Expand Down Expand Up @@ -123,9 +123,12 @@ public void testRandomSamplerConsistentSeed() {
),
response -> {
InternalRandomSampler sampler = response.getAggregations().get("sampler");
assertThat(((Avg) sampler.getAggregations().get("mean_monotonic")).getValue(), equalTo(sampleMonotonicValue[0]));
assertThat(((Avg) sampler.getAggregations().get("mean_numeric")).getValue(), equalTo(sampleNumericValue[0]));
assertThat(sampler.getDocCount(), equalTo(sampledDocCount[0]));
double monotonicValue = ((Avg) sampler.getAggregations().get("mean_monotonic")).getValue();
double numericValue = ((Avg) sampler.getAggregations().get("mean_numeric")).getValue();
long docCount = sampler.getDocCount();
assertEquals(monotonicValue, sampleMonotonicValue[0], tolerance);
assertEquals(numericValue, sampleNumericValue[0], tolerance);
assertEquals(docCount, sampledDocCount[0]);
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

public class ModelConfigurations implements ToFilteredXContentObject, VersionedNamedWriteable {

public static final String MODEL_ID = "model_id";
// Due to refactoring, we now have different field names for the inference ID when it is serialized and stored to an index vs when it
// is returned as part of a GetInferenceModelAction
public static final String INDEX_ONLY_ID_FIELD_NAME = "model_id";
public static final String INFERENCE_ID_FIELD_NAME = "inference_id";
public static final String USE_ID_FOR_INDEX = "for_index";
public static final String SERVICE = "service";
public static final String SERVICE_SETTINGS = "service_settings";
public static final String TASK_SETTINGS = "task_settings";
Expand Down Expand Up @@ -119,7 +123,11 @@ public TaskSettings getTaskSettings() {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(MODEL_ID, inferenceEntityId);
if (params.paramAsBoolean(USE_ID_FOR_INDEX, false)) {
builder.field(INDEX_ONLY_ID_FIELD_NAME, inferenceEntityId);
} else {
builder.field(INFERENCE_ID_FIELD_NAME, inferenceEntityId);
}
builder.field(TaskType.NAME, taskType.toString());
builder.field(SERVICE, service);
builder.field(SERVICE_SETTINGS, serviceSettings);
Expand All @@ -131,7 +139,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
@Override
public XContentBuilder toFilteredXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(MODEL_ID, inferenceEntityId);
if (params.paramAsBoolean(USE_ID_FOR_INDEX, false)) {
builder.field(INDEX_ONLY_ID_FIELD_NAME, inferenceEntityId);
} else {
builder.field(INFERENCE_ID_FIELD_NAME, inferenceEntityId);
}
builder.field(TaskType.NAME, taskType.toString());
builder.field(SERVICE, service);
builder.field(SERVICE_SETTINGS, serviceSettings.getFilteredXContentObject());
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/esql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ dependencies {
}

tasks.named("compileJava").configure {
options.compilerArgs.addAll(["-s", "src/main/generated"])
options.compilerArgs.addAll(["-s", "$projectDir/src/main/generated"])
// IntelliJ sticks generated files here and we can't stop it....
exclude { it.file.toString().contains("src/main/generated-src/generated") }
exclude { it.file.toString().contains("$projectDir/src/main/generated-src/generated") }
}

interface Injected {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugin/esql/compute/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {
}

tasks.named("compileJava").configure {
options.compilerArgs.addAll(["-s", "src/main/generated"])
options.compilerArgs.addAll(["-s", "$projectDir/src/main/generated"])
}

tasks.named('checkstyleMain').configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ public void unpackValues(MethodSpec.Builder builder, boolean blockStyle) {

@Override
public void buildInvocation(StringBuilder pattern, List<Object> args, boolean blockStyle) {
pattern.append("$L");
pattern.append("this.$L");
args.add(name);
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 81f89a7

Please sign in to comment.