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(backend): Introduce executors shared DB connection #8340

Merged
merged 15 commits into from
Oct 16, 2024

Conversation

majdyz
Copy link
Contributor

@majdyz majdyz commented Oct 15, 2024

Background

Currently, each execution worker initiates their own DB connection, and the number of DB connections linearly scales with the number of workers. This is problematic when the database we are using has a limited number of DB connections.

Changes 🏗️

  • Introduced the DatabaseAPI process that exposes prisma queries that will be used by executors in the execution managers.
  • Removed db connections from ExecutionManager.
  • Added thread_cached_property for caching pyro client on a thread level.

Testing 🔍

Note

Only for the new autogpt platform, currently in autogpt_platform/

  • Create from scratch and execute an agent with at least 3 blocks
  • Import an agent from file upload, and confirm it executes correctly
  • Upload agent to marketplace
  • Import an agent from marketplace and confirm it executes correctly
  • Edit an agent from monitor, and confirm it executes correctly

@majdyz majdyz requested a review from a team as a code owner October 15, 2024 10:48
@github-actions github-actions bot added platform/backend AutoGPT Platform - Back end size/xl labels Oct 15, 2024
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Race Condition
The new implementation uses a thread-local db_client, which could potentially lead to race conditions if not properly managed across threads.

Code Duplication
The exposed_run_and_wait decorator is creating wrapper functions for each database operation. This could lead to code duplication and maintenance issues.

Complex Type Handling
The _pydantic_models_from_type_annotation function has become more complex with the addition of handling for various collection types. This might make it harder to maintain and debug.

Copy link

netlify bot commented Oct 15, 2024

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit b8c1a3b
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/670e4a51217403000845a9d9

@aarushik93
Copy link
Contributor

this should be against dev

@Pwuts Pwuts changed the title feat(platform): Introduce executors shared DB connection feat(backend): Introduce executors shared DB connection Oct 15, 2024
@majdyz majdyz changed the base branch from master to dev October 15, 2024 13:47
@majdyz majdyz requested a review from Pwuts October 15, 2024 13:50
@majdyz majdyz requested a review from aarushik93 October 15, 2024 14:07
@majdyz majdyz requested a review from Pwuts October 15, 2024 14:47
@majdyz majdyz merged commit 6f07d24 into dev Oct 16, 2024
7 checks passed
@majdyz majdyz deleted the zamilmajdy/unified-db-service branch October 16, 2024 14:15
aarushik93 added a commit that referenced this pull request Oct 16, 2024
* feat(platform): List and revoke credentials in user profile (#8207)

Display existing credentials (OAuth and API keys) for all current providers: Google, Github, Notion and allow user to remove them. For providers that support it, we also revoke the tokens through the API: of the providers we currently have, Google and GitHub support it; Notion doesn't.

- Add credentials list and `Delete` button in `/profile`
- Add `revoke_tokens` abstract method to `BaseOAuthHandler` and implement it in each provider
- Revoke OAuth tokens for providers on `DELETE` `/{provider}/credentials/{cred_id}`, and return whether tokens could be revoked
   - Update `autogpt-server-api/baseClient.ts:deleteCredentials` with `CredentialsDeleteResponse` return type

Bonus:
- Update `autogpt-server-api/baseClient.ts:_request` to properly handle empty server responses

* fix(backend): Lower the number of node workers to save DB connections (#8331)

Change [graph]×[node] worker limit from 10×5 to 10×3

---------

Co-authored-by: Reinier van der Leer <[email protected]>

* fix(ci,platform): Add dev branch trigger to all ci (#8339)

* update ci for dev

* update classic

* remove duplicate dev

* fix(frontend): Fix styling inconsistencies in input elements (#8337)

- Apply consistent border styling to `Input`, `Select`, and `Textarea`
   - Remove `rounded-xl` from node input elements

- Add `whitespace-nowrap` to `CustomNode` header category tags

---------

Co-authored-by: Zamil Majdy <[email protected]>

* feat(builder): Use configmap for builder (#8343)

use configmap in builder

* fix(platform,infra): Checkin non secret values  (#8344)

checkin non secrets

* security(platform): Add sealed secrets (#8342)

* add sealed secrets

* add encrypted secrets

* remove extra space

* Tf public media buckets (#8324)

* fix(infra): Fix sealed secret names  (#8350)

* fix sealed secret names

* fix names and add annotation

* feat(backend): Introduce executors shared DB connection (#8340)

* update health checkendpoint

---------

Co-authored-by: Krzysztof Czerwinski <[email protected]>
Co-authored-by: Reinier van der Leer <[email protected]>
Co-authored-by: Zamil Majdy <[email protected]>
Co-authored-by: Swifty <[email protected]>
aarushik93 added a commit that referenced this pull request Oct 16, 2024
* feat(platform): List and revoke credentials in user profile (#8207)

Display existing credentials (OAuth and API keys) for all current providers: Google, Github, Notion and allow user to remove them. For providers that support it, we also revoke the tokens through the API: of the providers we currently have, Google and GitHub support it; Notion doesn't.

- Add credentials list and `Delete` button in `/profile`
- Add `revoke_tokens` abstract method to `BaseOAuthHandler` and implement it in each provider
- Revoke OAuth tokens for providers on `DELETE` `/{provider}/credentials/{cred_id}`, and return whether tokens could be revoked
   - Update `autogpt-server-api/baseClient.ts:deleteCredentials` with `CredentialsDeleteResponse` return type

Bonus:
- Update `autogpt-server-api/baseClient.ts:_request` to properly handle empty server responses

* fix(backend): Lower the number of node workers to save DB connections (#8331)

Change [graph]×[node] worker limit from 10×5 to 10×3

---------

Co-authored-by: Reinier van der Leer <[email protected]>

* fix(ci,platform): Add dev branch trigger to all ci (#8339)

* update ci for dev

* update classic

* remove duplicate dev

* fix(frontend): Fix styling inconsistencies in input elements (#8337)

- Apply consistent border styling to `Input`, `Select`, and `Textarea`
   - Remove `rounded-xl` from node input elements

- Add `whitespace-nowrap` to `CustomNode` header category tags

---------

Co-authored-by: Zamil Majdy <[email protected]>

* feat(builder): Use configmap for builder (#8343)

use configmap in builder

* fix(platform,infra): Checkin non secret values  (#8344)

checkin non secrets

* security(platform): Add sealed secrets (#8342)

* add sealed secrets

* add encrypted secrets

* remove extra space

* Tf public media buckets (#8324)

* fix(infra): Fix sealed secret names  (#8350)

* fix sealed secret names

* fix names and add annotation

* feat(backend): Introduce executors shared DB connection (#8340)

* update health checkendpoint

---------

Co-authored-by: Krzysztof Czerwinski <[email protected]>
Co-authored-by: Reinier van der Leer <[email protected]>
Co-authored-by: Zamil Majdy <[email protected]>
Co-authored-by: Swifty <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants