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: on demand retrieval (via symlinking) in case input is annotated as on-demand eligible by Snakemake (e.g. because of sequential access being annotated by the developer #32

Merged
merged 1 commit into from
Mar 20, 2025

Conversation

johanneskoester
Copy link
Contributor

@johanneskoester johanneskoester commented Mar 19, 2025

Summary by CodeRabbit

  • New Features
    • Introduced an on-demand file retrieval pathway that detects if a file qualifies for faster access.
    • For eligible files, the system now creates a link-based mechanism for quicker retrieval while retaining the standard method for others.

… as on-demand eligible by Snakemake (e.g. because of sequential access being annotated by the developer
Copy link

coderabbitai bot commented Mar 19, 2025

📝 Walkthrough

Walkthrough

The retrieve_object method in the StorageObject class has been updated. It now first checks whether an object is eligible for on-demand retrieval via the is_ondemand_eligible attribute. If eligible, the method logs an informational message and creates a symlink from the source to the local path. Otherwise, it retains its original behavior by constructing and executing an rsync command.

Changes

File Path Change Summary
snakemake_storage_plugin_fs/init.py Updated retrieve_object to conditionally check is_ondemand_eligible. If true, logs and creates a symlink; if false, uses rsync.

Sequence Diagram(s)

sequenceDiagram
    participant S as StorageObject.retrieve_object
    participant L as Logger
    participant OS as os.symlink
    participant R as sysrsync.get_rsync_command
    participant C as _run_cmd

    S->>S: Check is_ondemand_eligible
    alt Eligible for on-demand retrieval
        S->>L: Log "Creating symlink for on-demand retrieval"
        S->>OS: Create symlink from query_path to local_path
    else Not eligible for on-demand retrieval
        S->>R: Construct rsync command
        S->>C: Execute rsync command via _run_cmd
    end
Loading

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Copy link

@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 (2)
snakemake_storage_plugin_fs/__init__.py (2)

206-210: Add error handling for symlink creation

The symlink creation doesn't have error handling for cases where it might fail (e.g., permission issues, crossing filesystem boundaries, or if the target already exists).

-            os.symlink(
-                self.query_path,
-                self.local_path(),
-                target_is_directory=self.query_path.is_dir(),
-            )
+            try:
+                os.symlink(
+                    self.query_path,
+                    self.local_path(),
+                    target_is_directory=self.query_path.is_dir(),
+                )
+            except OSError as e:
+                self.provider.logger.warning(
+                    f"Failed to create symlink for on-demand retrieval of {self.query_path}. "
+                    f"Falling back to rsync: {e}"
+                )
+                cmd = sysrsync.get_rsync_command(
+                    str(self.query_path), str(self.local_path()), options=["-av"]
+                )
+                self._run_cmd(cmd)

203-205: Consider documenting symlink limitations

The use of symlinks for on-demand retrieval is a good optimization, but has limitations that users should be aware of (e.g., symlinks don't work across different filesystems, break if the source is moved/deleted).

Consider adding a more detailed log message explaining these limitations:

-            self.provider.logger.info(
-                f"Creating symlink for on-demand retrieval of {self.query_path}."
-            )
+            self.provider.logger.info(
+                f"Creating symlink for on-demand retrieval of {self.query_path}. "
+                f"Note: Symlinks require source files to remain available and may not work across filesystems."
+            )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fc6f499 and 5a7cbae.

⛔ Files ignored due to path filters (1)
  • pyproject.toml is excluded by !pyproject.toml
📒 Files selected for processing (1)
  • snakemake_storage_plugin_fs/__init__.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.py`: Do not try to improve formatting. Do not suggest type annotations for functions that are defined inside of functions or methods. Do not suggest type annotation of the `s...

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

  • snakemake_storage_plugin_fs/__init__.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: formatting
🔇 Additional comments (1)
snakemake_storage_plugin_fs/__init__.py (1)

202-215: Good optimization for on-demand retrieval

The conditional logic to use symlinks for on-demand eligible objects is a good optimization that can improve performance, especially for large files that might not be accessed.

@johanneskoester johanneskoester merged commit e69267c into main Mar 20, 2025
6 checks passed
@johanneskoester johanneskoester deleted the feat/on-demand-support branch March 20, 2025 08:33
johanneskoester pushed a commit that referenced this pull request Mar 20, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.1.0](v1.0.6...v1.1.0)
(2025-03-20)


### Features

* on demand retrieval (via symlinking) in case input is annotated as
on-demand eligible by Snakemake (e.g. because of sequential access being
annotated by the developer
([#32](#32))
([e69267c](e69267c))


### Bug Fixes

* adapt to interface version 4.0
([fc6f499](fc6f499))
* proper use of relpath to define symlink
([2295f7f](2295f7f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant