-
Notifications
You must be signed in to change notification settings - Fork 0
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
Io class #55
Io class #55
Conversation
granawkins
commented
Jul 17, 2024
- Run all read/write operations through daemon.io
- Implement LocalIO and DockerIO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces an IO abstraction layer to support both local and Docker-based file operations. It adds a new DockerIO class and modifies existing code to use the new IO interface. The changes look well-structured and consistent across the codebase. However, there are a few areas that could use additional attention, such as updating subclasses of Annotator, improving error messages, and expanding test coverage for DockerIO. Overall, this is a significant enhancement that should improve the flexibility of the system.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
@@ -7,13 +7,14 @@ packages=["ragdaemon"] | |||
|
|||
[project] | |||
name = "ragdaemon" | |||
version = "0.7.8" | |||
version = "0.8.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version bump from 0.7.8 to 0.8.0. Make sure this is intentional and follows semantic versioning principles.
description = "Generate and render a call graph for a Python project." | ||
readme = "README.md" | ||
dependencies = [ | ||
"astroid==3.2.2", | ||
"chromadb==0.4.24", | ||
"dict2xml==1.7.5", | ||
"docker==7.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New dependency added: docker==7.1.0. Ensure this is necessary for the new IO functionality and that it's compatible with other dependencies.
@@ -47,4 +48,4 @@ dev = [ | |||
] | |||
|
|||
[tool.pyright] | |||
ignore = ["tests/sample"] | |||
ignore = ["tests/sample", "venv", ".venv"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 'venv' and '.venv' to the ignore list for pyright. This is good practice to avoid linting virtual environment files.
|
||
|
||
class Annotator: | ||
name: str = "base_annotator" | ||
|
||
def __init__( | ||
self, | ||
io: IO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New parameter 'io: IO' added to the Annotator constructor. Make sure all subclasses of Annotator are updated to include this parameter in their init methods.
spice_client: Optional[Spice] = None, | ||
logging_dir: Optional[Path | str] = None, | ||
model: str = DEFAULT_EMBEDDING_MODEL, | ||
provider: Optional[str] = None, | ||
container: Optional[Container] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New parameter 'container: Optional[Container] = None' added to the Daemon constructor. Ensure this is properly documented and that the usage is clear in the class docstring.
): | ||
self.cwd = cwd | ||
if container is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The IO object is now initialized based on whether a container is provided. This change allows for both local and Docker-based IO operations. Make sure this behavior is documented in the class docstring.
self, path: Optional[Path] = None, exclude_patterns: Set[Path] = set() | ||
) -> Set[Path]: | ||
if not self.is_git_repo(path): | ||
raise RagdaemonError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message mentions 'root' which is not defined in this context. Consider changing it to 'path' or 'self.cwd' for clarity.
tests/test_docker_io.py
Outdated
|
||
@pytest.mark.asyncio | ||
async def test_docker_io(container, path): | ||
daemon = Daemon(Path(path), annotators={"hierarchy": {}}, container=container) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding more specific assertions to test the functionality of DockerIO. The current test only checks if the context message is as expected, but doesn't directly test DockerIO methods.