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 config server side store #5594

Merged
merged 32 commits into from
Dec 18, 2024
Merged

Feat config server side store #5594

merged 32 commits into from
Dec 18, 2024

Conversation

tofarr
Copy link
Collaborator

@tofarr tofarr commented Dec 14, 2024

Infrastructure for saving config on the backend rather than the frontend.

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

  • This is a NoOp for now - a follow up PR will cause this to actually be used.
  • Added endpoints for saving / loading session_init_data on the backend
  • The init operation now loads from this endpoint as a default before overriding data from the incoming message
  • This is a single user solution.

To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0cf87ce-nikolaik   --name openhands-app-0cf87ce   docker.all-hands.dev/all-hands-ai/openhands:0cf87ce

@tofarr tofarr marked this pull request as ready for review December 18, 2024 17:21
Copy link
Collaborator

@rbren rbren left a comment

Choose a reason for hiding this comment

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

mostly just complaints about naming :)

SessionInitStoreImpl = get_impl(SessionInitStore, config.session_init_store_class) # type: ignore


@app.get('/session-init-data')
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's call this /user-config instead of session-init-data

Copy link
Collaborator

Choose a reason for hiding this comment

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

actually maybe /settings is better

Comment on lines 38 to 39
github_token='test-token',
selected_repository='test/repo',
Copy link
Collaborator

Choose a reason for hiding this comment

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

definitely want to remove these two--this config is going to be reused across sessions

IMO the stuff in here should be 1:1 with the stuff in the settings modal

@app.get('/session-init-data')
async def load_session_init_data(
github_auth: Annotated[str | None, Header()] = None,
) -> SessionInitData | None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think probably we should create a new class for this config

@@ -0,0 +1,34 @@
from __future__ import annotations
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this unused?

Copy link
Collaborator Author

@tofarr tofarr Dec 18, 2024

Choose a reason for hiding this comment

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

This is a hint that defers evaluation of annotations. Originally, this was going to be the default for future versions of python from 3.11 onwards, but they keep punting it.

Consider the following code:

from dataclasses import dataclass, field

@dataclass
class Node:
  name: str
  children: list[Node] = field(default_factory=list)

Without the annotation, the python will complain because the type hint for Node is used before the definition is complete. With the annotation, the evaluation for the type hint of Node is deferred until later and the code is accepted.

There are some internal changes on how type hints are processed (As strings), but those don't affect our use case

@@ -0,0 +1,25 @@
from __future__ import annotations
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand the desire for an abstract class, but maybe for simplicity we just have the file implementation, and then any overriders inherit from that? Then we can just call it SettingsStore

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also maybe we put these in a new dir, openhands/storage/settings/...


@classmethod
async def get_instance(cls, config: AppConfig, token: str | None):
file_store = get_file_store(config.file_store, config.file_store_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should just have a singleton file_store. We do this in openhands/server/shared....

Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably want a singleton of this class too...

I'm creating a ConversationStore, which now that I think about it is kind of silly (why give ourselves 10 classes to override instead of 1)...

@tofarr tofarr merged commit fe1bb1c into main Dec 18, 2024
26 checks passed
@tofarr tofarr deleted the feat-config-server-side-store branch December 18, 2024 22:18
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.

4 participants