-
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
write to docker as tar file #56
Conversation
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 changes in this pull request improve the file writing mechanism in Docker by using a tar archive instead of directly writing to the container. This approach is more robust and efficient. The version bump in pyproject.toml and init.py is appropriate for this feature update. Overall, the changes look good, but there are a few minor suggestions for error handling and code cleanup.
Thanks for using MentatBot. Give comments a 👍 or 👎 to help me improve!
raise IOError( | ||
f"Failed to write file {self.path} in container: {result.stderr.decode('utf-8')}" | ||
) | ||
|
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 error handling for the case where the temporary file creation fails.
tar_stream.seek(0) | ||
|
||
# Put the archive into the container | ||
self.container.put_archive(os.path.dirname(self.path), tar_stream) |
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.
It might be a good idea to add error handling here in case the put_archive
operation fails.
self.container.put_archive(os.path.dirname(self.path), tar_stream) | ||
|
||
# Clean up the temporary file | ||
os.remove(temp_file_path) |
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 using a context manager (like with tempfile.NamedTemporaryFile() as temp_file:
) to ensure the temporary file is always deleted, even if an exception occurs.
ragdaemon/io/docker_io.py
Outdated
@@ -153,3 +171,10 @@ def rename(self, src: Path | str, dst: Path | str): | |||
def exists(self, path: Path | str) -> bool: | |||
result = self.container.exec_run(f"test -e {self.cwd / path}") | |||
return result.exit_code == 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.
This commented-out code block at the end of the file seems unnecessary. Consider removing it if it's not needed.
No description provided.