Skip to content

fix: Allow hyphens in config keys given on the command line.#2998

Merged
johanneskoester merged 2 commits intosnakemake:mainfrom
cmkobel:main
Aug 13, 2024
Merged

fix: Allow hyphens in config keys given on the command line.#2998
johanneskoester merged 2 commits intosnakemake:mainfrom
cmkobel:main

Conversation

@cmkobel
Copy link
Copy Markdown

@cmkobel cmkobel commented Aug 4, 2024

It is possible to use hyphens when specifying config keys given in the configfile, but when given on the command line as --config key-with-hyphens=value, it fails. With this PR, hyphens are allowed in the middle of config keys, when given on the command line.

As far as I understand, hyphens are valid for keys in the yaml specification: https://yaml.org/spec/1.2.2/ https://www.yaml.info/learn/bestpractices.html

I have been using this code in my projects for a while and I don't think it introduces any problems, especially since hyphens have been allowed in the config file for a very long time.

The motivation for me to use hyphens in the command line config is discussed here: #2986

Best, Carl

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).

Summary by CodeRabbit

  • New Features
    • Enhanced configuration key validation to allow hyphens in key names, increasing flexibility for user configurations.

@cmkobel cmkobel changed the title Allow hyphens in config keys given on the command line. Fix: Allow hyphens in config keys given on the command line. Aug 4, 2024
@cmkobel cmkobel changed the title Fix: Allow hyphens in config keys given on the command line. fix: Allow hyphens in config keys given on the command line. Aug 4, 2024
@cmkobel cmkobel marked this pull request as ready for review August 4, 2024 14:16
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 13, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The recent changes enhance the parse_config function in the snakemake/cli.py file by updating the regular expression used to validate configuration keys. The new regex allows for hyphens in key names, expanding the range of valid formats and improving flexibility in configuration entry. This adjustment aims to accommodate diverse naming requirements in configuration files.

Changes

File Change Summary
snakemake/cli.py Modified the regex in parse_config to allow hyphens in configuration keys, enhancing flexibility.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant ConfigParser

    User->>CLI: Submit configuration
    CLI->>ConfigParser: Parse configuration
    ConfigParser-->>CLI: Validate keys with regex
    CLI-->>User: Return success/failure
Loading

Poem

In the meadow, the rabbit hops,
With keys that dance and never stop.
Hyphens now join the joyful spree,
Configs are free, as they ought to be!
So let's all cheer, with a little twitch,
For flexible keys, without a hitch! 🐇✨


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.

@johanneskoester johanneskoester enabled auto-merge (squash) August 13, 2024 09:54
@sonarqubecloud
Copy link
Copy Markdown

@johanneskoester johanneskoester merged commit b70c0db into snakemake:main Aug 13, 2024
johanneskoester pushed a commit that referenced this pull request Aug 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[8.17.0](v8.16.0...v8.17.0)
(2024-08-13)


### Features

* fix job rate limiting with --max-jobs-per-second and introduce the
more flexible --max-jobs-per-timespan
([#3010](#3010))
([9c31257](9c31257))


### Bug Fixes

* Allow hyphens in config keys given on the command line.
([#2998](#2998))
([b70c0db](b70c0db))
* allowing trailing '+' in name patterns
([#3002](#3002))
([59150d3](59150d3))
* print message if not yet enough resources for executing further jobs
([b8df036](b8df036))
* unawaited coroutine sanitize_local_storage_copies
([#2972](#2972))
([715c572](715c572))


### Documentation

* Change sha256 checksum in docs to more realistic example
([#2987](#2987))
([16a5cf2](16a5cf2))
* Make it more clear that the cluster commands now require a plugin
([#2976](#2976))
([74134cf](74134cf))
* Update installation.rst to recommend Miniforge instead of Mambaforge
([#2975](#2975))
([0fc7619](0fc7619))
* use plain monospace font instead of theme default that changes &gt;=
into ≥
([cc17fc1](cc17fc1))

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