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

feat: Add bedrock services #1623

Merged
merged 3 commits into from
Mar 29, 2025
Merged

feat: Add bedrock services #1623

merged 3 commits into from
Mar 29, 2025

Conversation

holomekc
Copy link
Contributor

@holomekc holomekc commented Mar 18, 2025

Hi,
When I was adding bedrock it was not really planned to adjust other parts of the project, but I faced some issues with bedrock having two apis (bedrock and bedrock-runtime) and localstack only having a bedrock service. More details in the inline comments. I hope this helps.

Edit:
I am also unsure about the integration tests. Bedrock in localstack requires a pro license. So currently the check is only on the 501 error localstack throws. Which does not really cover much except that it shows that the requests are recognized by localstack and rejected with the mentioned 501 instead of 404. I had the feeling that other pro services like ECR, are not covered in tests at all. Let me know what you think about that.

@holomekc holomekc requested a review from a team as a code owner March 18, 2025 15:18
private String getPropertyConfigurationName(LocalStackContainer.EnabledService enabledService) {
protected String getPropertyConfigurationName(LocalStackContainer.EnabledService enabledService) {
Copy link
Contributor Author

@holomekc holomekc Mar 18, 2025

Choose a reason for hiding this comment

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

Bedrock has two apis:
Bedrock and BedrockRuntime. I think it makes sense to separate them so a user can decide which part is really necessary. This results in the issue that there is not a 1:1 mappings between localStack service and the configurations. Visibility changed to protected, so that bedrock-runtime can override the config name with "bedrock-runtime".

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should use the same quarkus-amazon-devservices-bedrock for both and have overrideDefaultConfig duplicate all the defaultConfig keys.

Copy link
Contributor Author

@holomekc holomekc Mar 19, 2025

Choose a reason for hiding this comment

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

Sure i will take a look. Hmm although. Doesn't that mean that I am importing both modules in the dev-service?
E.g.:

    <artifactId>quarkus-amazon-devservices-bedrock</artifactId>
    <name>Quarkus - Amazon DevServices - Bedrock</name>
    <dependencies>
        <dependency>
            <groupId>io.quarkiverse.amazonservices</groupId>
            <artifactId>quarkus-amazon-common-deployment-devservices-spi</artifactId>
        </dependency>
         <dependency>
            <groupId>io.quarkiverse.amazonservices</groupId>
            <artifactId>quarkus-amazon-bedrock</artifactId>
        </dependency>
       <dependency>
            <groupId>io.quarkiverse.amazonservices</groupId>
            <artifactId>quarkus-amazon-bedrockruntime</artifactId>
        </dependency>
    </dependencies>

Isn't that then creating an issue?

Copy link
Member

Choose a reason for hiding this comment

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

Isn't that then creating an issue?

yes, you are right

Copy link
Member

Choose a reason for hiding this comment

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

I didn't come up with another idea that avoid modifying common classes. As integration tests will not test the dev mode, could you confirm thatrunning the integration-test project in dev mode actually works ?

Also, could you fix the name of the buildstep (setupEcr)) in the bedrockruntime package as it will be part of the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx for the feedback:
Ok. I run mvn quarkus:dev in the integration-tests project:

Start looks fine to me:

[WARNING] [io.quarkus.bootstrap.devmode.DependenciesFilter] Live reload was disabled for the following project artifacts:
- io.quarkiverse.amazonservices:quarkus-amazon-acm:999-SNAPSHOT
- io.quarkiverse.amazonservices:quarkus-amazon-common:999-SNAPSHOT
- io.quarkiverse.amazonservices:quarkus-amazon-common-spi:999-SNAPSHOT
- io.quarkiverse.amazonservices:quarkus-amazon-bedrock:999-SNAPSHOT
- io.quarkiverse.amazonservices:quarkus-amazon-bedrockruntime:999-SNAPSHOT
...

The artifacts above appear to be either dependencies of non-reloadable application dependencies or Quarkus extensions
Listening for transport dt_socket at address: 5005
2025-03-20 21:37:18,177 INFO  [io.qua.sma.dep.processor] (build-35) Configuring the channel 'messages' to be managed by the connector 'smallrye-sqs'
2025-03-20 21:37:19,633 INFO  [io.qua.ama.dev.cog.CognitoUserPoolsDevServicesProcessor] (build-41) Amazon Dev Services for cognito user pools started.
__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2025-03-20 21:37:24,392 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.redshift.endpoint-override" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typoypo
2025-03-20 21:37:24,392 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.redshift.aws.region" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2025-03-20 21:37:24,392 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.redshift.aws.credentials.static-provider.secret-access-key" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2025-03-20 21:37:24,392 WARN  [io.qua.config] (Quarkus Main Thread) Unrecognized configuration key "quarkus.redshift.aws.credentials.static-provider.access-key-id" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2025-03-20 21:37:24,825 INFO  [io.quarkus] (Quarkus Main Thread) quarkus-amazon-services-integration-tests 999-SNAPSHOT on JVM (powered by Quarkus 3.19.2) started in 10.222s. Listening on: http://localhost:8080
2025-03-20 21:37:24,826 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2025-03-20 21:37:24,826 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [amazon-sdk-acm, amazon-sdk-bedrock, amazon-sdk-bedrockruntime, amazon-sdk-cloudwatch, amazon-sdk-cloudwatchlogs, amazon-sdk-cognito-user-pools, amazon-sdk-dynamodb, amazon-sdk-dynamodb-enhanced, amazon-sdk-eventbridge, amazon-sdk-iam, amazon-sdk-kinesis, amazon-sdk-kms, amazon-sdk-lambda, amazon-sdk-s3, amazon-sdk-s3-transfer-manager, amazon-sdk-secretsmanager, amazon-sdk-ses, amazon-sdk-sfn, amazon-sdk-sns, amazon-sdk-sqs, amazon-sdk-ssm, amazon-sdk-sts, cdi, messaging, messaging-amazon-sqs, opentelemetry, rest, rest-jackson, smallrye-context-propagation, vertx]
2025-03-20 21:37:24,855 INFO  [io.sma.rea.mes.aws.sqs] (executor-thread-1) SRMSG19304: Queue URL for channel messages : http://sqs.us-east-1.localstack-9fyqj:4566/000000000000/quarkus-messaging-test-queue

Tests are ok-ish. They fail for me locally the same way as they do before my change. Not sure why is that though.

2 tests failed (54 passing, 0 skipped), 56 tests were run in 45958ms. Tests completed at 21:39:26.

2025-03-20 21:39:26,839 ERROR [io.qua.test] (Test runner thread) ==================== TEST REPORT #1 ====================
2025-03-20 21:39:26,839 ERROR [io.qua.test] (Test runner thread) Test AmazonDynamoDBEnhancedWithoutCustomExtensionsTest#testDynamoDbEnhancedClientWithoutCustomExtensionAsync() failed 
: java.lang.AssertionError: 1 expectation failed.
Response body doesn't match expectation.
Expected: is "INTERCEPTED OK@1"
  Actual: INTERCEPTED EXTENSION OK@1

        at io.restassured.internal.ValidatableResponseOptionsImpl.body(ValidatableResponseOptionsImpl.java:238)
2025-03-20 21:39:26,840 ERROR [io.qua.test] (Test runner thread) Test AmazonDynamoDBEnhancedWithoutCustomExtensionsTest#testDynamoDbEnhancedClientWithoutCustomExtensionBlocking() failed est.java:17)
: java.lang.AssertionError: 1 expectation failed.
Response body doesn't match expectation.
Expected: is "INTERCEPTED OK@1"
  Actual: INTERCEPTED EXTENSION OK@1

        at io.restassured.internal.ValidatableResponseOptionsImpl.body(ValidatableResponseOptionsImpl.java:238)
        at io.quarkiverse.it.amazon.AmazonDynamoDBEnhancedWithoutCustomExtensionsTest.testDynamoDbEnhancedClientWithoutCustomExtensionBlocking(AmazonDynamoDBEnhancedWithoutCustomExtensionsTest.java:22)

I pushed the requested changes in a dedicated commit, so that it is easier to see. If I should squash the commits before merge let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also added two docu pages.
Btw. I also did the renaming from bedrock-runtime to bedrockruntime, but I am not sure, because there are also a lot of other References, where it is written BedrockRuntim, bedrock-runtime, etc. See the Models from the sdk and boto3: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime.html.

Nevertheless, I am fine with both.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines -204 to +205
if (maybeNewDevService == null || !preMatchCondition || !match(oldDevServiceConfig, maybeNewDevService)) {
if (maybeNewDevService == null || !preMatchCondition || i.matchesOtherConfig(maybeNewDevService)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the last check to the RunningDevServicesWithConfig, so that the transformation to the comparable format is in one location only

Comment on lines +394 to +404
private Map<String, Set<LocalStackDevServicesBaseConfig>> createComparableConfigGroup(
List<DevServicesLocalStackProviderBuildItem> servicesGroup) {
Map<String, Set<LocalStackDevServicesBaseConfig>> configMap = new HashMap<>();
for (DevServicesLocalStackProviderBuildItem item : servicesGroup) {
configMap.computeIfAbsent(item.getService().getName(), k -> new HashSet<>()).add(item.getConfig());
}
return configMap;
}

public boolean matchesOtherConfig(List<DevServicesLocalStackProviderBuildItem> otherServiceList) {
return this.config.equals(createComparableConfigGroup(otherServiceList));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed that, because Bedrock and Bedrock-Runtime both uses the lcoalstack bedrock service. With the old approach the transformation failed with duplicate key failure. The usage of map and set ensures that the equals check should still work.

@WithDefault(value = "localstack/localstack:3.7.2")
@WithDefault(value = "localstack/localstack:4.2.0")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The bedrock service was added in a later localstack version. I updated to 4.2.0

Copy link
Member

@scrocquesel scrocquesel left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution. I left some remarks.

For documentation, if you can add a page (and include a link in the nav) with a very short introduction (like for ecr or more with a sample, that would be very helpfull for users.

Regarding integration tests, I plan to have a pro licence one day. Meanwhile, we don't add them for other extensions but keep them now there are written.

private String getPropertyConfigurationName(LocalStackContainer.EnabledService enabledService) {
protected String getPropertyConfigurationName(LocalStackContainer.EnabledService enabledService) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should use the same quarkus-amazon-devservices-bedrock for both and have overrideDefaultConfig duplicate all the defaultConfig keys.

@scrocquesel
Copy link
Member

I couldn't push directly to your branch due to permission issues. I created a new branch (bedrock) with my changes. Please pull them into your branch to update this PR and we will be good to merge.

@holomekc
Copy link
Contributor Author

Hi @scrocquesel,
Thx! Branch is merged.

@scrocquesel scrocquesel merged commit 80e0cc0 into quarkiverse:main Mar 29, 2025
5 checks passed
@scrocquesel
Copy link
Member

@all-contributors please add @holomekc for code

Copy link
Contributor

@scrocquesel

@holomekc already contributed before to code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants