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

Added deployment cache #53

Merged
merged 43 commits into from
Oct 17, 2024
Merged

Added deployment cache #53

merged 43 commits into from
Oct 17, 2024

Conversation

CharlesDuboisSAP
Copy link
Contributor

@CharlesDuboisSAP CharlesDuboisSAP commented Sep 6, 2024

Context

AI/ai-sdk-java-backlog#54.

The lookup of deployments should be more efficient & resilient.

Note for reviewers:

The filter for Orchestration and OpenAI deployments has been removed since the new AiCoreService allows to fetch all deployments

Feature scope:

  • Cache for deployments
    • Initialized lazily or eagerly whenever the customer calls new AiCoreService().forDeployment...
    • No timeout
    • Customers can call DeploymentCache.resetCache() whenever they delete a deployment

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Aligned changes with the JavaScript SDK
  • Documentation updated
  • Release notes updated

@CharlesDuboisSAP CharlesDuboisSAP changed the title Added query filters for Orchestration and OpenAI deployments Added deployment cache Sep 6, 2024
# Conflicts:
#	core/src/test/java/com/sap/ai/sdk/core/WireMockTestServer.java
#	core/src/test/java/com/sap/ai/sdk/core/client/ScenarioUnitTest.java
#	foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java
#	orchestration/src/test/java/com/sap/ai/sdk/orchestration/client/OrchestrationUnitTest.java
#	sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/ConfigurationController.java
@CharlesDuboisSAP CharlesDuboisSAP marked this pull request as ready for review October 15, 2024 08:28
# Conflicts:
#	core/src/main/java/com/sap/ai/sdk/core/AiCoreDeployment.java
#	core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java
class Application {
public class Application {
/** The API client connected to the AI Core service. */
public static final ApiClient API_CLIENT = new AiCoreService().client();
Copy link
Contributor

@newtork newtork Oct 16, 2024

Choose a reason for hiding this comment

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

(Minor)

I'm not a fan of this implementation/declaration as it's unusual for SpringBoot application development.

More common approach would be to define a @Bean here and @Autowired it when using in controller classes.

@Bean
public ApiClient getApiCoreClient() {
  return new AiCoreService().client();
}

But we can also do this in a separate PR. That'll be fine.

newtork
newtork previously approved these changes Oct 16, 2024
# Conflicts:
#	core/src/main/java/com/sap/ai/sdk/core/AiCoreService.java
#	core/src/test/java/com/sap/ai/sdk/core/client/WireMockTestServer.java
@CharlesDuboisSAP CharlesDuboisSAP mentioned this pull request Oct 17, 2024
6 tasks
@newtork newtork dismissed their stale review October 17, 2024 07:57

code chandes

Copy link
Contributor

@newtork newtork left a comment

Choose a reason for hiding this comment

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

Users can call DeploymentCache.resetCache

Currently, they can't and shouldn't (?).

@newtork newtork merged commit 9b7abb8 into refactor-core3 Oct 17, 2024
3 checks passed
@newtork newtork deleted the query-filter branch October 17, 2024 11:00
newtork added a commit that referenced this pull request Oct 17, 2024
CharlesDuboisSAP added a commit that referenced this pull request Oct 17, 2024
* intermediate

* ready-to-discuss state

* Fix merge; Format

* Add javadoc

* Fix PMD warnings

* Initial change of draft

* Initial API change

* Fix merge conflicts

* Update readme

* Fix PMD

* Formatting

* Apply suggestions from code review

Co-authored-by: Charles Dubois <[email protected]>

* Defuse functions

* Update core/src/main/java/com/sap/ai/sdk/core/AiCoreServiceWithDeployment.java

Co-authored-by: Charles Dubois <[email protected]>

* Make service binding accessor changeable, e.g. for future testing

* Rename methods and types; Fix merge

* Formatting

* Fix code, tests are working

* Fix header provisioning

* Add tests; Move stuff around

* make base class extensible

* work in progress

* refine work in progress

* Fix tests

* Update test

* Add annotations

* Format

* Format; JavaDoc

* Restructure code

* Fix PMD

* Fix PMD

* Fix test

* Fix test

* Apply review comments

* Apply review comments

* Add assertion on AI-Client-Type header

* Minor JavaDoc fix

* Formatting

* Added deployment cache (#53)

* Added query filters for Orchestration and OpenAI deployments

* Added deployment cache

* Added cache reset

* Added unit tests

* Fixed unit tests

* PMD

* Refactor to fix tests

* fix tests for real

* PMD + added clearCache and loadCache

* PMD again

* Added query filters for Orchestration and OpenAI deployments

* Added deployment cache

* Added cache reset

* Added unit tests

* Fixed unit tests

* PMD

* Refactor to fix tests

* fix tests for real

* PMD + added clearCache and loadCache

* PMD again

* WiP

* Delete Core

* Formatting

* Fixed tests

* Single cache

* Added clearCache test

* Fix tests

* Added resetCache

* Merged

* spotless

* Reduced code

* Added throws

* Added API client to application startup

* Make DeploymentCache package private and an instance

* Merged main

* Changed cache to a Set

---------

Co-authored-by: SAP Cloud SDK Bot <[email protected]>

---------

Co-authored-by: Alexander Dümont <[email protected]>
Co-authored-by: SAP Cloud SDK Bot <[email protected]>
Co-authored-by: Charles Dubois <[email protected]>
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.

3 participants