Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Use Opendal driver in Tftp driver#313

Merged
mangelajo merged 7 commits intomainfrom
opendal-in-tftp
Feb 27, 2025
Merged

Use Opendal driver in Tftp driver#313
mangelajo merged 7 commits intomainfrom
opendal-in-tftp

Conversation

@NickCao
Copy link
Copy Markdown
Collaborator

@NickCao NickCao commented Feb 26, 2025

Summary by CodeRabbit

  • Refactor

    • Transitioned to an operator-based file handling approach, streamlining TFTP operations by removing several legacy file management capabilities.
  • Tests

    • Simplified and updated test configurations and fixtures to align with the new file handling structure, including assertions for file integrity using hash values.
  • Chores

    • Updated project dependencies by replacing an older file management library with a modern composite solution.
  • Documentation

    • Revised TFTP server usage examples to reflect new context manager implementation and updated file access methods.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 26, 2025

Warning

Rate limit exceeded

@NickCao has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 2 minutes and 37 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between f4d5e35 and 2526e39.

📒 Files selected for processing (4)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/client.py (6 hunks)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/common.py (1 hunks)
  • packages/jumpstarter-driver-opendal/jumpstarter_driver_opendal/driver_test.py (2 hunks)
  • pyproject.toml (1 hunks)

Walkthrough

The changes refactor the TFTP driver by removing direct file management methods from both client and server classes. The TftpServerClient now inherits from CompositeClient, and multiple file operations methods (e.g., file listing, uploading, deletion, and checksum computation) have been eliminated. The server classes have been updated to use an Operator from the opendal library for file handling instead of relying on local filesystem paths. Associated tests and dependency configurations have been updated to reflect these design changes.

Changes

File(s) Change Summary
packages/jumpstarter-driver-tftp/.../client.py
packages/jumpstarter-driver-tftp/.../driver.py
Refactored TFTP client and driver classes: changed inheritance (to CompositeClient), removed file management methods and checksum computations, and updated server instantiation to pass an operator instead of a root directory.
packages/jumpstarter-driver-tftp/.../driver_test.py
packages/jumpstarter-driver-tftp/.../server_test.py
Updated test fixtures and signatures: replaced the old temp_dir/server fixtures with a new tftp fixture using the serve function and configured the server instantiation to use an opendal Operator.
packages/jumpstarter-driver-tftp/.../server.py Modified server and transfer classes: constructors and helper methods now accept an Operator for file operations, with file paths handled as strings instead of pathlib.Path objects, and asynchronous file reading is performed through the operator.
packages/jumpstarter-driver-tftp/pyproject.toml Updated dependencies by removing "aiofiles>=24.1.0" and adding "jumpstarter-driver-composite", while retaining the dependency on "jumpstarter-driver-opendal".
packages/jumpstarter-driver-opendal/.../client.py
packages/jumpstarter-driver-opendal/.../driver.py
Added new hash method to OpendalClient and Opendal classes for computing file hashes using MD5 or SHA-256.
packages/jumpstarter-driver-opendal/.../driver_test.py Enhanced tests to verify hash values of files stored in the client, ensuring integrity checks for file content.

Possibly related PRs

Suggested reviewers

  • bennyz
  • mangelajo

Poem

I hop through lines of refactored code,
Leaving old file methods down the road.
A composite tune, an operator’s delight,
Files now flow with a new insight.
Hoppy updates from this rabbit tonight! 🐰


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 26, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 2526e39
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67bf62d76dd56e00076a190d
😎 Deploy Preview https://deploy-preview-313--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
packages/jumpstarter-driver-tftp/pyproject.toml (1)

13-14: Consider pinning versions for new dependencies.

Having unpinned dependencies can lead to non-deterministic builds if upstream releases introduce breaking changes. To ensure stability and reproducibility, consider pinning or specifying version constraints for jumpstarter-driver-composite and jumpstarter-driver-opendal.

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/server_test.py (1)

17-17: Consider parametrizing the operator backend in tests.

Using Operator("fs", root=str(temp_dir)) is great for local filesystem tests. If you plan to support multiple backends, consider a parameterized fixture or test suite to verify that the server behaves consistently across different operator backends (e.g., S3, memory, etc.).

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py (1)

7-7: Revise docstring to reflect current responsibilities.

The docstring references file management, yet the methods for file operations have been removed. Update the class docstring to avoid confusion:

-    This client provides methods to control a TFTP server and manage files on it.
-    Supports file operations like uploading from various storage backends through OpenDAL.
+    This client provides an interface to control a TFTP server by delegating
+    file operations to a composite architecture, where actual file handling
+    is managed through OpenDAL.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 115351d and 4063979.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py (1 hunks)
  • packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver.py (3 hunks)
  • packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver_test.py (1 hunks)
  • packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/server.py (7 hunks)
  • packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/server_test.py (2 hunks)
  • packages/jumpstarter-driver-tftp/pyproject.toml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver.py (1)
Learnt from: bennyz
PR: jumpstarter-dev/jumpstarter#267
File: packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver.py:32-40
Timestamp: 2025-02-08T16:08:34.616Z
Learning: In the TFTP driver (jumpstarter_driver_tftp), the TFTP server component is read-only, while file management operations (upload, delete) are handled through the driver's client interface, not through the TFTP protocol itself.
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: e2e
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
🔇 Additional comments (22)
packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/server_test.py (1)

6-6: New import aligns with Operator-based file handling.

Importing Operator from opendal is consistent with the new approach for handling file operations. Looks good!

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/client.py (1)

3-3: Import switch is aligned with composite approach.

Switching from your old base to CompositeClient is consistent with the refactor away from direct file operations in this driver. No concerns here.

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver_test.py (11)

3-3: No issues found.


5-5: Import looks good.


9-10: Fixture usage is valid.


14-19: The new fixture syntax is perfectly valid.


23-24: Async test definition looks consistent.


28-28: Writing test data to the local file is correct.


34-34: Checking the file list is correct.


37-38: File deletion test logic is valid.


41-41: Test declaration is clear.


43-43: Creating a Tftp instance with a custom host is correct.


47-50: Root directory creation is handled properly.

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/driver.py (3)

8-8: Imported Opendal reference looks good.


53-55: Good approach to register Opendal as a child storage provider.


76-76: Verify usage of self.operator.

Ensure that self.operator is properly initialized and references the same Opendal storage provider set in self.children["storage"].

packages/jumpstarter-driver-tftp/jumpstarter_driver_tftp/server.py (6)

7-7: Successful integration of opendal Operator import.


36-37: Constructor signature update is consistent with the new approach.


40-40: Storing the operator instance.


221-235: File resolution logic with opendal.

Ensure that stat.mode.is_file robustly confirms the object is a file in all environments. If opendal distinguishes directories or links differently, please verify accordingly.


289-291: Signature refactoring is consistent with the read-only TFTP approach.


355-355: Switched to a string filepath to align with opendal usage.

Copy link
Copy Markdown
Member

@mangelajo mangelajo left a comment

Choose a reason for hiding this comment

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

@mangelajo mangelajo merged commit f14366f into main Feb 27, 2025
@mangelajo
Copy link
Copy Markdown
Member

merged, and we can follow up on docs, etc :)

@NickCao
Copy link
Copy Markdown
Collaborator Author

NickCao commented Feb 27, 2025

The doc/examples would need update: https://docs.jumpstarter.dev/main/api-reference/drivers/tftp.html

It's already updated? (To make doctest pass)

@NickCao NickCao deleted the opendal-in-tftp branch February 27, 2025 20:37
@mangelajo mangelajo added this to the 0.6.0 milestone May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants