Add implementation to update service settings method for Alibaba Cloud Search service#142738
Conversation
…ceSettings and related classes
|
Pinging @elastic/search-inference-team (Team:Search - Inference) |
…ice-settings-method-alibabacloudsearch
| public static final String NAME = "alibabacloud_search_completion_service_settings"; | ||
|
|
||
| public static AlibabaCloudSearchCompletionServiceSettings fromMap(Map<String, Object> map, ConfigurationParseContext context) { | ||
| ValidationException validationException = new ValidationException(); |
There was a problem hiding this comment.
ValidationException was not passed anywhere and couldn't be filled out with any validation errors. Actual validation was performed only within the AlibabaCloudSearchServiceSettings.fromMap method
| public static AlibabaCloudSearchEmbeddingsServiceSettings fromMap(Map<String, Object> map, ConfigurationParseContext context) { | ||
| ValidationException validationException = new ValidationException(); | ||
| var validationException = new ValidationException(); | ||
| var commonServiceSettings = AlibabaCloudSearchServiceSettings.fromMap(map, context); |
There was a problem hiding this comment.
As you may see, the validation is happening in 2 steps here. If AlibabaCloudSearchServiceSettings.fromMap introduces validation fails - it will fail early without checking embedding specific fields and without filling out the potential errors in these fields.
I don't see this approach as optimal. We could alter the signature of the AlibabaCloudSearchServiceSettings.fromMap to take validation exception as param and fill it out with validation errors for the common fields while keeping the responsibility of throwing the exception on task specific classes. I implemented that locally. If it is decided that we would want to go with this approach I can push it here.
CC @DonalEvans
There was a problem hiding this comment.
I like the idea of passing the ValidationException into AlibabaCloudSearchServiceSettings.fromMap(). The purpose of the way we use ValidationException is to allow us to capture ALL of the validation problems with a given input, so having two places we can throw while parsing a single object feels wrong.
There was a problem hiding this comment.
Done!
...ticsearch/xpack/inference/services/alibabacloudsearch/AlibabaCloudSearchServiceSettings.java
Show resolved
Hide resolved
DonalEvans
left a comment
There was a problem hiding this comment.
A few suggestions for minor test improvements, but nothing worth holding the PR up for if you don't feel like implementing the changes.
| ); | ||
| } | ||
|
|
||
| public void testUpdateServiceSettings_EmptyMap_Success() { |
There was a problem hiding this comment.
Rather than simply *_Success this test might be better named something like *_DoesNotChangeSettings
There was a problem hiding this comment.
Done. Also changed it for AI21 so the approach is the same for both services. I want to keep same more or less unified across the services.
| var serviceSettings = new AlibabaCloudSearchCompletionServiceSettings( | ||
| new AlibabaCloudSearchServiceSettings( | ||
| INITIAL_TEST_SERVICE_ID, | ||
| INITIAL_TEST_HOST, | ||
| INITIAL_TEST_WORKSPACE_NAME, | ||
| INITIAL_TEST_HTTP_SCHEMA, | ||
| new RateLimitSettings(INITIAL_TEST_RATE_LIMIT) | ||
| ) | ||
| ).updateServiceSettings(new HashMap<>()); | ||
|
|
||
| assertThat( | ||
| serviceSettings, | ||
| is( | ||
| new AlibabaCloudSearchCompletionServiceSettings( | ||
| new AlibabaCloudSearchServiceSettings( | ||
| INITIAL_TEST_SERVICE_ID, | ||
| INITIAL_TEST_HOST, | ||
| INITIAL_TEST_WORKSPACE_NAME, | ||
| INITIAL_TEST_HTTP_SCHEMA, | ||
| new RateLimitSettings(INITIAL_TEST_RATE_LIMIT) | ||
| ) | ||
| ) | ||
| ) | ||
| ); |
There was a problem hiding this comment.
This test can be simplified/clarified a little if we do:
var originalServiceSettings = new AlibabaCloudSearchCompletionServiceSettings(
new AlibabaCloudSearchServiceSettings(
INITIAL_TEST_SERVICE_ID,
INITIAL_TEST_HOST,
INITIAL_TEST_WORKSPACE_NAME,
INITIAL_TEST_HTTP_SCHEMA,
new RateLimitSettings(INITIAL_TEST_RATE_LIMIT)
)
);
var updatedServiceSettings = originalServiceSettings.updateServiceSettings(new HashMap<>());
assertThat(updatedServiceSettings, is(originalServiceSettings));
There was a problem hiding this comment.
Good idea. Done that for AI21 as well.
...services/alibabacloudsearch/completion/AlibabaCloudSearchCompletionServiceSettingsTests.java
Show resolved
Hide resolved
| ); | ||
| } | ||
|
|
||
| public void testUpdateServiceSettings_EmptyMap_Success() { |
There was a problem hiding this comment.
See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()
There was a problem hiding this comment.
Done.
...services/alibabacloudsearch/embeddings/AlibabaCloudSearchEmbeddingsServiceSettingsTests.java
Show resolved
Hide resolved
| ); | ||
| } | ||
|
|
||
| public void testUpdateServiceSettings_EmptyMap_Success() { |
There was a problem hiding this comment.
See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()
There was a problem hiding this comment.
Done!
| ); | ||
| } | ||
|
|
||
| public void testUpdateServiceSettings_EmptyMap_Success() { |
There was a problem hiding this comment.
See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()
There was a problem hiding this comment.
Done!
| ); | ||
| } | ||
|
|
||
| public void testUpdateServiceSettings_EmptyMap_Success() { |
There was a problem hiding this comment.
See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()
There was a problem hiding this comment.
Done!
|
Hi @DonalEvans ! Thank you for your comments and approval. I implemented the proposed fixes and a few more. Also unified testing approaches with the one taken for AI21. I want to keep everything more or less the same across the implementations. |
…on-sliced-reindex * upstream/main: (110 commits) Add search task watchdog to log hot threads on slow search (elastic#142746) Fix return_intermediate_results query param on get async search results (elastic#142875) Mute org.elasticsearch.compute.operator.exchange.BatchDriverTests testSinglePageSingleBatch elastic#142895 Cancel reindex body always has status (elastic#142766) Fix built-in roles sync losing updates (elastic#142433) ESQL: Clarify docs and add csv test for WHERE in STATS (elastic#133629) Fix and unmute ReindexResumeIT (elastic#142788) Fix broken release notes Mute org.elasticsearch.benchmark.vector.scorer.VectorScorerOSQBenchmarkTests testSingleScalarVsVectorized {p0=384 p1=4 p2=NIO p3=COSINE} elastic#142883 ES|QL: fix Generative tests for commands that don't change the output schema (elastic#142864) Mute org.elasticsearch.benchmark.vector.scorer.VectorScorerOSQBenchmarkTests testSingleScalarVsVectorized {p0=1024 p1=1 p2=NIO p3=DOT_PRODUCT} elastic#142881 SQL: Fix QlIllegalArgumentException with non-foldable date range queries (elastic#142386) Add more errors to the allowed_errors with github issue links (elastic#142862) ESQL: reapply "NDJSON datasource" (elastic#142855) Add implementation to update service settings method for Alibaba Cloud Search service (elastic#142738) Mute org.elasticsearch.snapshots.SnapshotShutdownIT testStartRemoveNodeButDoNotComplete elastic#142871 Mute org.elasticsearch.snapshots.SnapshotShutdownIT testDeleteSnapshotWithPausedShardSnapshots elastic#142870 Mute org.elasticsearch.snapshots.SnapshotShutdownIT testAbortSnapshotWhileRemovingNode elastic#142869 Mute org.elasticsearch.snapshots.SnapshotShutdownIT testRemoveNodeDuringSnapshot elastic#142868 ES|QL: Guard exponential_histogram TO_STRING against too large inputs (elastic#140718) ...
…d Search service (elastic#142738) * Add updateServiceSettings method to AlibabaCloudSearchCompletionServiceSettings and related classes * Fix unit tests and add changelog * Fix validation exception handling * Refactor updateServiceSettings tests to improve clarity and consistency
…d Search service (elastic#142738) * Add updateServiceSettings method to AlibabaCloudSearchCompletionServiceSettings and related classes * Fix unit tests and add changelog * Fix validation exception handling * Refactor updateServiceSettings tests to improve clarity and consistency
This PR is a part of a broader initiative related to endpoint _update operation: #122356
In particular - this PR provides implementation for
updateServiceSettingsmethod used in_updateoperation for Alibaba Cloud Search service.Initially the changes present in this PR were a part of a bigger PR #140082.
API reference for the update operation can be found here: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-update.
service_id,host,workspace,similarityanddimensionsin service settings map are immutable, meaning they cannot be updated with_updateoperation.gradle check?