Skip to content

Commit

Permalink
Merge branch 'main' into feature/normalization
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski committed Aug 3, 2023
2 parents b867e69 + 2ff58a9 commit dbaa1c9
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Releases

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: GitHub App token
id: github_app_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: 22958780
- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
- uses: actions/checkout@v2
- uses: ncipollo/release-action@v1
with:
github_token: ${{ steps.github_app_token.outputs.token }}
bodyFile: release-notes/opensearch-neural-search.release-notes-${{steps.tag.outputs.tag}}.md
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Enhancements
### Bug Fixes
### Infrastructure
* Bump gradle version to 8.1.1 ([#169](https://github.com/opensearch-project/neural-search/pull/169))
### Documentation
### Maintenance
### Refactoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Version 2.8.0.0 Release Notes

Compatible with OpenSearch 2.8.0

### Infrastructure

* Bump gradle version to 8.1.1 ([#169](https://github.com/opensearch-project/neural-search/pull/169))
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Version 2.9.0.0 Release Notes

Compatible with OpenSearch 2.9.0

### Maintenance
Increment version to 2.9.0-SNAPSHOT ([#191](https://github.com/opensearch-project/neural-search/pull/191))

### Bug Fixes
Fix update document with knnn_vector size not matching issue ([#208](https://github.com/opensearch-project/neural-search/pull/208))
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void execute(IngestDocument ingestDocument, BiConsumer<IngestDocument, Ex
handler.accept(ingestDocument, null);
} else {
mlCommonsClientAccessor.inferenceSentences(this.modelId, inferenceList, ActionListener.wrap(vectors -> {
appendVectorFieldsToDocument(ingestDocument, knnMap, vectors);
setVectorFieldsToDocument(ingestDocument, knnMap, vectors);
handler.accept(ingestDocument, null);
}, e -> { handler.accept(null, e); }));
}
Expand All @@ -115,11 +115,11 @@ public void execute(IngestDocument ingestDocument, BiConsumer<IngestDocument, Ex

}

void appendVectorFieldsToDocument(IngestDocument ingestDocument, Map<String, Object> knnMap, List<List<Float>> vectors) {
void setVectorFieldsToDocument(IngestDocument ingestDocument, Map<String, Object> knnMap, List<List<Float>> vectors) {
Objects.requireNonNull(vectors, "embedding failed, inference returns null result!");
log.debug("Text embedding result fetched, starting build vector output!");
Map<String, Object> textEmbeddingResult = buildTextEmbeddingResult(knnMap, vectors, ingestDocument.getSourceAndMetadata());
textEmbeddingResult.forEach(ingestDocument::appendFieldValue);
textEmbeddingResult.forEach(ingestDocument::setFieldValue);
}

@SuppressWarnings({ "unchecked" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,5 +677,4 @@ protected String getDeployedModelId() {
assertEquals(1, modelIds.size());
return modelIds.iterator().next();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public void testProcessResponse_successful() throws Exception {
Map<String, Object> knnMap = processor.buildMapWithKnnKeyAndOriginalValue(ingestDocument);

List<List<Float>> modelTensorList = createMockVectorResult();
processor.appendVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList);
processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList);
assertEquals(12, ingestDocument.getSourceAndMetadata().size());
}

Expand Down Expand Up @@ -398,6 +398,20 @@ public void testBuildVectorOutput_withNestedMap_successful() {
assertNotNull(actionGamesKnn);
}

public void test_updateDocument_appendVectorFieldsToDocument_successful() {
Map<String, Object> config = createPlainStringConfiguration();
IngestDocument ingestDocument = createPlainIngestDocument();
TextEmbeddingProcessor processor = createInstanceWithNestedMapConfiguration(config);
Map<String, Object> knnMap = processor.buildMapWithKnnKeyAndOriginalValue(ingestDocument);
List<List<Float>> modelTensorList = createMockVectorResult();
processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList);

List<List<Float>> modelTensorList1 = createMockVectorResult();
processor.setVectorFieldsToDocument(ingestDocument, knnMap, modelTensorList1);
assertEquals(12, ingestDocument.getSourceAndMetadata().size());
assertEquals(2, ((List<?>) ingestDocument.getSourceAndMetadata().get("oriKey6_knn")).size());
}

private List<List<Float>> createMockVectorResult() {
List<List<Float>> modelTensorList = new ArrayList<>();
List<Float> number1 = ImmutableList.of(1.234f, 2.354f);
Expand Down

0 comments on commit dbaa1c9

Please sign in to comment.