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

fix: Correctly handle non str index list for bwa-mem2/mem #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

korbit-ai[bot]
Copy link

@korbit-ai korbit-ai bot commented Aug 21, 2024

As reported in #522, currently the bwa2-mem wrapper has issues if idx is a sequence is it incorrectly checked input.index to be as string instead of input.idx.

This bug was silent, as usually snakemake.input.index would always be a available as functools.partial(<function Namedlist._used_attribute at 0x73ac4dbc0c20>, _name='index') or similar. Thus the predicate that it was not a str was always true.
Now with snakemake=8.16.0 this changed and the bug becomes an error running the already existing tests.

While the discussion in #522 indicates, that there is an underlying issue with the concept of input.idx being as sequence of indices, this may need rework later. Until all the details are decided, having a correct working version should be still valuable. With the current state any workflow using this wrapper using snakemake=8.16.0 is broken.

QC

While the contributions guidelines are more extensive, please particularly ensure that:

  • test.py was updated to call any added or updated example rules in a Snakefile
  • input: and output: file paths in the rules can be chosen arbitrarily
  • wherever possible, command line arguments are inferred and set automatically (e.g. based on file extensions in input: or output:)
  • temporary files are either written to a unique hidden folder in the working directory, or (better) stored where the Python function tempfile.gettempdir() points to
  • the meta.yaml contains a link to the documentation of the respective tool or command under url:
  • conda environments use a minimal amount of channels and packages, in recommended ordering

Summary by CodeRabbit

  • New Features

    • Enhanced documentation clarifying input requirements for index files, ensuring users know all necessary file extensions.
    • Added a new function to extract the longest common prefix from index file names, improving error handling.
  • Bug Fixes

    • Updated index file specifications to require a complete list of index files, preventing execution errors due to missing files.
  • Documentation

    • Improved comments and descriptions in the Snakefile and meta.yaml for better user guidance on index file usage.

Description by Korbit AI

What change is being made?

Correctly handle non-string index list for bwa-mem2/mem by updating the variable name and its conditional checks.

Why are these changes being made?

The previous implementation incorrectly assumed the index input was always a string, leading to potential errors when a list was provided. This change ensures proper handling of both string and list inputs for the index.

Vito Zanotelli and others added 2 commits August 6, 2024 09:23
As reported in #522, currently this wrapper
has issues if `idx` is a sequence is it incorrectly
checked `input.index` to be as tring instead of `input.idx`.
This is fixed now.

While the discussin in #522 indicates, that there
is an underlying issue with the concept of `input.idx` being
as sequence of indices, this may need rework later.
Until all the details are decided, having a correct version
should be still valuable.
Copy link
Author

korbit-ai bot commented Aug 21, 2024

Clone of the PR snakemake/snakemake-wrappers#3101

Copy link

My review is in progress 📖 - I will have feedback for you in a few minutes!

1 similar comment
Copy link
Author

korbit-ai bot commented Aug 21, 2024

My review is in progress 📖 - I will have feedback for you in a few minutes!

Copy link

coderabbitai bot commented Aug 21, 2024

Warning

Rate limit exceeded

@furwellness has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 53 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

Files that changed from the base of the PR and between 92dbf03 and 3ef9dca.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Author

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

I have reviewed your code and found 1 potential issue.

Comment on lines +30 to +34
idx = snakemake.input.get("idx", "")
if isinstance(idx, str):
index = path.splitext(idx)[0]
else:
index = path.splitext(snakemake.input.idx[0])[0]
index = path.splitext(idx[0])[0]
Copy link
Author

Choose a reason for hiding this comment

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

category Functionality

The changes you've made to use 'idx' instead of 'index' are good and address the reported issue. However, I suggest adding an explicit check for when 'idx' is not provided. Currently, if 'idx' is an empty string, it might lead to unexpected behavior. Consider adding a check like this:

idx = snakemake.input.get("idx", "")
if not idx:
    raise ValueError("No index file provided. Please specify 'idx' in the input.")

This will ensure that the wrapper fails early with a clear error message if the required index is not provided.

Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.

Copy link

@development-korbit-ai-mentor development-korbit-ai-mentor bot left a comment

Choose a reason for hiding this comment

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

I have reviewed your code and did not find any issues!


Please note that I can make mistakes, and you should still encourage your team to review your code as well.

Copy link

Mapping from the Github issue to the LangSmith prompt that generated the issue:

Copy link

System configuration at time of review:

- category__name: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__database_operations: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__documentation: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__logging: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__error_handling: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__systems_and_environment: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__objects_and_data_structures: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__tests: {'enabled': False, 'user_values': {'minimum_severity': 'nit'}}
- category__readability_and_maintainability: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__asynchronous_processing: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__design_patterns: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__third_party_libraries: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__performance: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- category__security: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}
- pull_request_review_schedule: {'enabled': True, 'user_values': {'review_schedule': 'non-draft'}}
- maximum_shown_issues: {'enabled': True, 'user_values': {'max_issues': 10}}
- auto_pr_description: {'enabled': True, 'user_values': {}}
- category__functionality: {'enabled': True, 'user_values': {'minimum_severity': 'nit'}}

Copy link

@coderabbitai full review

Copy link

coderabbitai bot commented Aug 22, 2024

Actions performed

Full review triggered.

@furwellness furwellness changed the base branch from cloned_master_8b420 to master August 24, 2024 13:27
@furwellness
Copy link
Owner

/review

Copy link

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Key issues to review

Logic Change
The PR changes the logic for handling the index input. It now uses input.get("idx", "") instead of input.get("index", ""), and handles both string and list inputs for idx. This change should be carefully reviewed to ensure it correctly addresses the reported issue and doesn't introduce new problems.

@furwellness
Copy link
Owner

@coderabbitai full review

Copy link

coderabbitai bot commented Aug 24, 2024

Actions performed

Full review triggered.

Copy link

/review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant