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

Add more UT for remote inference classes #1077

Merged
merged 4 commits into from
Jul 12, 2023

Conversation

b4sjoo
Copy link
Collaborator

@b4sjoo b4sjoo commented Jul 11, 2023

Description

This PR will add test coverage to remote inference classes and some of the other classes.

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #1077 (6bdd594) into 2.x (e3cb2e3) will increase coverage by 0.85%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##                2.x    #1077      +/-   ##
============================================
+ Coverage     77.95%   78.80%   +0.85%     
- Complexity     2071     2102      +31     
============================================
  Files           167      167              
  Lines          8558     8567       +9     
  Branches        857      862       +5     
============================================
+ Hits           6671     6751      +80     
+ Misses         1503     1423      -80     
- Partials        384      393       +9     
Flag Coverage Δ
ml-commons 78.80% <ø> (+0.85%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes

Signed-off-by: Sicheng Song <[email protected]>
@b4sjoo b4sjoo marked this pull request as ready for review July 12, 2023 00:08
String postProcessFunction = MLPostProcessFunction.OPENAI_EMBEDDING;
ConnectorAction action = new ConnectorAction(actionType, method, url, headers, mlCreateConnectorRequestBody, preProcessFunction, postProcessFunction);

// java.lang.IllegalStateException: unexpected byte [0x6f] will be thrown if we specify backendRoles field.
Copy link
Collaborator

@ylwu-amzn ylwu-amzn Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change line 230 of MLCreateConnectorInput

output.writeOptionalStringCollection(backendRoles);

to

output.writeStringCollection(backendRoles);

Tested with this, it can work, won't throw such error

        MLCreateConnectorInput input = MLCreateConnectorInput.builder()
                .name("test_connector_name")
                .description("this is a test connector")
                .version("1")
                .protocol("http")
                .parameters(Map.of("input", "test input value"))
                .credential(Map.of("key", "test_key_value"))
                .access(AccessMode.PUBLIC)
                .addAllBackendRoles(true)
                .backendRoles(Arrays.asList("r1"))
                .build();
        BytesStreamOutput output = new BytesStreamOutput();
        input.writeTo(output);
        MLCreateConnectorInput input2 = new MLCreateConnectorInput(output.bytes().streamInput());
        Assert.assertNotNull(input2);

Copy link
Collaborator

@Zhangxunmt Zhangxunmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we increase the line and branch coverage back to 0.7 or 0.8 in the gradle file?

rbhavna
rbhavna previously approved these changes Jul 12, 2023
Signed-off-by: Sicheng Song <[email protected]>
MLConnectorGetResponse parsedResponse = new MLConnectorGetResponse(bytesStreamOutput.bytes().streamInput());
assertNotEquals(response, parsedResponse);
assertNotSame(response.mlConnector, parsedResponse.mlConnector);
assertEquals(response.mlConnector, parsedResponse.mlConnector);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@b4sjoo b4sjoo merged commit daab3b7 into opensearch-project:2.x Jul 12, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 12, 2023
@b4sjoo b4sjoo deleted the 2.x_RIUnit branch July 12, 2023 03:56
b4sjoo added a commit to b4sjoo/ml-commons that referenced this pull request Jul 12, 2023
b4sjoo added a commit that referenced this pull request Jul 12, 2023
zane-neo pushed a commit to zane-neo/ml-commons that referenced this pull request Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants