Skip to content

fix: Support versioned URLs in Asset class and fix missing versions in Snakemake report#3203

Merged
johanneskoester merged 6 commits intomainfrom
asset-versioning
Nov 21, 2024
Merged

fix: Support versioned URLs in Asset class and fix missing versions in Snakemake report#3203
johanneskoester merged 6 commits intomainfrom
asset-versioning

Conversation

@fxwiegand
Copy link
Copy Markdown
Contributor

@fxwiegand fxwiegand commented Nov 12, 2024

Support versioned URLs in Asset class and fix missing versions in Snakemake report

Summary by CodeRabbit

  • New Features

    • Introduced versioning for assets, allowing dynamic URL generation based on specified versions.
    • Added a method to retrieve the version of specified assets.
  • Bug Fixes

    • Enhanced logic for determining package versions with fallback options for version retrieval.
  • Documentation

    • Updated documentation to reflect new attributes and methods related to asset versioning.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 12, 2024

Warning

Rate limit exceeded

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

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces enhancements to the Asset and Assets classes in the snakemake/assets/__init__.py file by adding a version attribute to the Asset class and modifying asset URLs to include this versioning. Additionally, a new method get_version is added to the Assets class to retrieve the version of specified assets. Changes to the Package class constructor in snakemake/report/html_reporter/data/packages.py improve how the version attribute is initialized, allowing for fallback retrieval from the Assets class.

Changes

File Path Change Summary
snakemake/assets/init.py - Added version: Optional[str] attribute to Asset class.
- Updated get_content method to format URLs with version.
- Added get_version(cls, asset_path: str) -> Optional[str] method to Assets class.
snakemake/report/html_reporter/data/packages.py - Updated __init__ method of Package class to enhance version initialization logic, allowing fallback from Assets.get_version.

Possibly related PRs

Suggested reviewers

  • johanneskoester

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

@github-actions
Copy link
Copy Markdown
Contributor

Please format your code with black: black snakemake tests/*.py.

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: 2

🧹 Outside diff range and nitpick comments (1)
snakemake/assets/__init__.py (1)

166-172: Add docstring to document the get_version method.

The implementation is clean and follows good practices. Consider adding a docstring to document the method's purpose, parameters, and return value.

 @classmethod
 def get_version(cls, asset_path: str) -> Optional[str]:
+    """Retrieve the version of a specified asset.
+
+    Args:
+        asset_path: The path identifier of the asset in the spec dictionary.
+
+    Returns:
+        The version string if the asset exists and has a version, None otherwise.
+    """
     if asset_path in cls.spec:
         return cls.spec[asset_path].version
     else:
         return None
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 76d5329 and f415d11.

📒 Files selected for processing (2)
  • snakemake/assets/__init__.py (3 hunks)
  • snakemake/report/html_reporter/data/packages.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
snakemake/assets/__init__.py (1)

Pattern **/*.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/report/html_reporter/data/packages.py (1)

Pattern **/*.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.

🔇 Additional comments (2)
snakemake/report/html_reporter/data/packages.py (1)

Line range hint 8-63: Verify version resolution for all package declarations.

The changes to Package.__init__ affect how versions are resolved. Please ensure all packages get proper version information, especially those without explicit versions.

Let's verify version resolution for each package:

#!/bin/bash
# Description: Check version resolution for each package declaration

# Extract all Package instantiations and their parameters
rg -A 5 'Package\(' | grep -v 'class Package' | grep -E '(version=|source_path=|license_path=)'

# Check if Assets class has version information for these paths
ast-grep --pattern 'class Assets:
  $$$
  _assets = {
    $$$
  }'
snakemake/assets/__init__.py (1)

21-21: LGTM! Verify version formatting in URLs.

The version support implementation is clean and handles the optional nature of versions correctly. The URL formatting is done safely with a conditional check.

Let's verify that all versioned URLs in the spec follow the same format pattern:

Also applies to: 27-28

✅ Verification successful

Version formatting in URLs is consistent.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check consistency of version formatting in URLs
# Look for inconsistencies in how {version} is used in URLs

rg -U 'url.*\{version\}.*",' | sort | uniq -c

Length of output: 1930

Comment on lines +77 to +81
self.version = (
version
or Assets.get_version(source_path)
or Assets.get_version(license_path)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add error handling to Assets.get_version to ensure reliable version retrieval.

🔗 Analysis chain

LGTM! The version fallback logic is well structured.

The implementation provides a clear fallback chain for version retrieval, prioritizing explicit versions over derived ones.

Let's verify the error handling of Assets.get_version and its impact on existing package declarations:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Assets.get_version error handling and usage

# Check if Assets.get_version has error handling
ast-grep --pattern 'class Assets:
  $$$
  def get_version($_):
    $$$
    try {
      $$$
    } catch $_:
      $$$'

# Check existing package declarations that might be affected
rg -A 5 'Package\(' | grep -v 'class Package'

Length of output: 1758

@sonarqubecloud
Copy link
Copy Markdown

@johanneskoester johanneskoester merged commit f086f6c into main Nov 21, 2024
@johanneskoester johanneskoester deleted the asset-versioning branch November 21, 2024 10:15
johanneskoester pushed a commit that referenced this pull request Nov 27, 2024
🤖 I have created a release *beep* *boop*
---


##
[8.25.4](v8.25.3...v8.25.4)
(2024-11-27)


### Bug Fixes

* clean env vars in apptainer
([#3199](#3199))
([76d5329](76d5329))
* ensure that intermediate files in job groups do not cause spurious
mtime errors when checking for consistency with output files
([#3220](#3220))
([4ba2bdf](4ba2bdf))
* Remove incomplete marker also when drop-metadata is active
([#3215](#3215))
([a4f2e5c](a4f2e5c))
* Remove incomplete marker for job finished only after metadata is
written ([#3197](#3197))
([6567e5f](6567e5f))
* Support versioned URLs in Asset class and fix missing versions in
Snakemake report
([#3203](#3203))
([f086f6c](f086f6c))
* update rust-script usage to recent version (v0.35.0)
[#3183](#3183)
([#3208](#3208))
([43885d7](43885d7))


### Documentation

* clarify continuously updated input section
([#3219](#3219))
([72a6994](72a6994))
* Fix typo in CHANGELOG.md
([#3198](#3198))
([0e445ed](0e445ed))
* refer to Merkle trees instead of "blockchain" in caching.rst
([#3216](#3216))
([282e5d9](282e5d9))
* remove twitter in favor of bluesky and mastodon
([#3217](#3217))
([231c6df](231c6df))
* use "dictionary" not "array" wording in config docs
([#3156](#3156))
([17aed41](17aed41))

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

2 participants