Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix github ci linux build and RAG tool missing return #477

Merged
merged 6 commits into from
Jan 16, 2025
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
47 changes: 14 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,31 @@ on:

jobs:
Get-CI-Image-Tag:
runs-on: ubuntu-latest
outputs:
ci-image-version-linux: ${{ steps.step-ci-image-version-linux.outputs.ci-image-version-linux }}
steps:
- name: Install crane
uses: iarekylew00t/crane-installer@v1
with:
crane-release: v0.15.2
- name: Checkout opensearch-build repository
uses: actions/checkout@v3
with:
repository: 'opensearch-project/opensearch-build'
ref: 'main'
path: 'opensearch-build'
- name: Get ci image version from opensearch-build repository scripts
id: step-ci-image-version-linux
run: |
crane version
CI_IMAGE_VERSION=`opensearch-build/docker/ci/get-ci-images.sh -p centos7 -u opensearch -t build | head -1`
echo $CI_IMAGE_VERSION
echo "ci-image-version-linux=$CI_IMAGE_VERSION" >> $GITHUB_OUTPUT
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch

build-linux:
needs: Get-CI-Image-Tag
strategy:
matrix:
java: [21]
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
name: Build and Test skills plugin on Linux
runs-on: ubuntu-latest
container:
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}

steps:
- name: Run start commands
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: temurin
Expand All @@ -64,7 +45,7 @@ jobs:
./gradlew publishToMavenLocal"

- name: Upload Coverage Report
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -79,9 +60,9 @@ jobs:

steps:
- name: Checkout skills
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: temurin
Expand All @@ -103,10 +84,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: temurin
Expand All @@ -120,7 +101,7 @@ jobs:
./gradlew publishToMavenLocal

- name: Upload Coverage Report
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

9 changes: 5 additions & 4 deletions .github/workflows/test_security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ jobs:
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}

steps:
- name: Run start commands
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
- name: Checkout Skills
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ dependencies {
compileOnly("com.google.guava:guava:33.2.1-jre")
compileOnly group: 'org.apache.commons', name: 'commons-lang3', version: '3.16.0'
compileOnly group: 'org.apache.commons', name: 'commons-text', version: '1.12.0'
compileOnly("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
compileOnly("com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}")

// Plugin dependencies
compileOnly group: 'org.opensearch', name:'opensearch-ml-client', version: "${opensearch_build}"
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/opensearch/agent/tools/RAGTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public <T> void run(Map<String, String> parameters, ActionListener<T> listener)
T queryToolOutput;
if (!this.enableContentGeneration) {
listener.onResponse(r);
return;
}
if (r.equals("Can not get any match from search result.")) {
queryToolOutput = (T) "";
Expand Down
13 changes: 10 additions & 3 deletions src/test/java/org/opensearch/integTest/BaseAgentToolsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ protected void updateClusterSettings(String settingKey, Object value) {

@SneakyThrows
private Map<String, Object> parseResponseToMap(Response response) {
Map<String, Object> responseInMap = XContentHelper
.convertToMap(XContentType.JSON.xContent(), EntityUtils.toString(response.getEntity()), false);
return responseInMap;
String responseBody = EntityUtils.toString(response.getEntity());
try {
return XContentHelper.convertToMap(XContentType.JSON.xContent(), responseBody, false);
} catch (Exception e) {
logger.error("failed to parse response to map: {}", responseBody, e);
return Collections.emptyMap();
}
}

@SneakyThrows
Expand Down Expand Up @@ -337,8 +341,11 @@ private String parseStringResponseFromExecuteAgentResponse(Response response) {

// execute the agent, and return the String response from the json structure
// {"inference_results": [{"output": [{"name": "response","result": "the result to return."}]}]}
@SneakyThrows
public String executeAgent(String agentId, String requestBody) {
Response response = makeRequest(client(), "POST", "/_plugins/_ml/agents/" + agentId + "/_execute", null, requestBody, null);
String responseBody = EntityUtils.toString(response.getEntity());
logger.info("responseBody for agent execution: {}, agentId: {}", responseBody, agentId);
return parseStringResponseFromExecuteAgentResponse(response);
}

Expand Down
Loading