Skip to content

test: extend validation test to modules#3343

Merged
johanneskoester merged 1 commit intosnakemake:mainfrom
fgvieira:module_schema_validation
Mar 9, 2025
Merged

test: extend validation test to modules#3343
johanneskoester merged 1 commit intosnakemake:mainfrom
fgvieira:module_schema_validation

Conversation

@fgvieira
Copy link
Copy Markdown
Contributor

@fgvieira fgvieira commented Mar 7, 2025

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
    • Introduced a modular test workflow that streamlines execution, with new rules for generating test outputs.
    • Added a dedicated configuration validation schema enforcing stricter checks on required inputs.
  • Refactor
    • Reordered configuration validation to ensure consistency immediately after loading.
  • Chores
    • Updated schema URLs in configuration files to align with current standards.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 7, 2025

📝 Walkthrough

Walkthrough

The pull request restructures the workflow configuration and modularizes the rules. In the main Snakefile, configuration validation has been repositioned to occur immediately after loading the config file, and the samples DataFrame is validated against an existing schema. A new module named "test" is introduced—with its own Snakefile and JSON schema—that defines a new rule. The main Snakefile now delegates rule execution to the module by using a prefix directive. Additionally, the JSON schema files have been updated to remove the trailing hash in the $schema URL.

Changes

File(s) Change Summary
tests/test_validate/Snakefile Reordered config validation (loaded then validated), modified rule all input (added trailing comma), removed the original rule a, added a new module declaration (module test), and delegated rules via use rule * from test as test_*.
tests/test_validate/(config.schema.yaml, samples.schema.yaml) Updated the $schema declaration by removing the trailing # from the JSON Schema URL.
tests/test_validate/module-test/Snakefile New file: sets shell to "bash", imports required libraries, validates the provided config against its JSON schema, and defines a rule a that creates an output file using a shell command.
tests/test_validate/module-test/config.schema.yaml New JSON schema file: defines an object with properties samples (required, type: string) and adapter (type: string with regex constraint for A, C, T, G).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Main as Main Snakefile
    participant Module as Module-Test Snakefile

    User->>Main: Execute workflow
    Main->>Main: Load configfile and validate config
    Main->>Main: Validate samples DataFrame using samples.schema.yaml
    Main->>Module: Import rules (via "use rule * from test as test_*")
    Module->>Module: Validate config using module-test/config.schema.yaml
    Module->>Module: Execute rule a (create test file)
    Module-->>Main: Return execution status
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 75afa38 and f06408a.

📒 Files selected for processing (5)
  • tests/test_validate/Snakefile (1 hunks)
  • tests/test_validate/config.schema.yaml (1 hunks)
  • tests/test_validate/module-test/Snakefile (1 hunks)
  • tests/test_validate/module-test/config.schema.yaml (1 hunks)
  • tests/test_validate/samples.schema.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (40)
  • GitHub Check: testing (10, 3.12, dash)
  • GitHub Check: testing (10, 3.12, bash)
  • GitHub Check: testing (10, 3.11, bash)
  • GitHub Check: testing (9, 3.12, dash)
  • GitHub Check: testing (9, 3.12, bash)
  • GitHub Check: testing (9, 3.11, bash)
  • GitHub Check: testing (8, 3.12, dash)
  • GitHub Check: testing (8, 3.12, bash)
  • GitHub Check: testing (8, 3.11, bash)
  • GitHub Check: testing (7, 3.12, dash)
  • GitHub Check: testing (7, 3.12, bash)
  • GitHub Check: testing (7, 3.11, bash)
  • GitHub Check: testing (6, 3.12, dash)
  • GitHub Check: testing (6, 3.12, bash)
  • GitHub Check: testing (6, 3.11, bash)
  • GitHub Check: testing (5, 3.12, dash)
  • GitHub Check: testing (5, 3.12, bash)
  • GitHub Check: testing (5, 3.11, bash)
  • GitHub Check: testing (4, 3.12, dash)
  • GitHub Check: testing (4, 3.12, bash)
  • GitHub Check: testing (4, 3.11, bash)
  • GitHub Check: testing (3, 3.12, dash)
  • GitHub Check: testing-windows (10)
  • GitHub Check: testing (3, 3.12, bash)
  • GitHub Check: testing-windows (9)
  • GitHub Check: testing (3, 3.11, bash)
  • GitHub Check: testing-windows (8)
  • GitHub Check: testing (2, 3.12, dash)
  • GitHub Check: testing-windows (7)
  • GitHub Check: testing (2, 3.12, bash)
  • GitHub Check: testing-windows (6)
  • GitHub Check: testing (2, 3.11, bash)
  • GitHub Check: testing-windows (5)
  • GitHub Check: testing (1, 3.12, dash)
  • GitHub Check: testing-windows (4)
  • GitHub Check: testing (1, 3.12, bash)
  • GitHub Check: testing-windows (3)
  • GitHub Check: testing (1, 3.11, bash)
  • GitHub Check: testing-windows (2)
  • GitHub Check: testing-windows (1)
🔇 Additional comments (8)
tests/test_validate/samples.schema.yaml (1)

1-1: Schema URL updated for better compliance.

The removal of the trailing hash (#) from the schema URL aligns with JSON Schema best practices. This change maintains the same schema functionality while following more precise URL formatting.

tests/test_validate/config.schema.yaml (1)

1-1: Schema URL updated for better compliance.

The removal of the trailing hash (#) from the schema URL aligns with JSON Schema best practices. This change maintains the same schema functionality while following more precise URL formatting.

tests/test_validate/module-test/Snakefile (1)

1-15: Good modularization approach for rule validation.

The module structure is well implemented with proper imports and configuration validation. The rule definition is clear and concise.

The validation of the config against the schema within the module ensures configuration integrity when the module is used independently, which is a good practice.

tests/test_validate/module-test/config.schema.yaml (1)

1-16: Note the nucleotide pattern order difference.

The module schema looks good overall, but I noticed a small inconsistency in the nucleotide pattern.

In this file you've used "^[ACTG]+$" while in the main config.schema.yaml file the pattern is "^[ACGT]+$". While both patterns match the same set of characters, maintaining consistency in the order would be better for code maintainability.

-    pattern: "^[ACTG]+$"
+    pattern: "^[ACGT]+$"
tests/test_validate/Snakefile (4)

10-11: Validation strategically positioned after config loading

The validation of the configuration now occurs immediately after loading the config file, which is a good practice for early error detection and better workflow reliability.


18-19: Minor syntax improvement with trailing comma

The addition of a trailing comma in the expand statement allows for easier future additions to the input list and maintains consistent formatting.


21-26: Good modularization with module declaration

The introduction of a dedicated module for testing helps with code organization and separation of concerns. This approach makes the workflow more maintainable and follows best practices for complex Snakemake pipelines.


28-28: Effective rule inclusion with prefix

Using the use rule * from test as test_* directive is an elegant way to include all rules from the module with a consistent naming convention. This makes it clear which rules come from the test module and prevents potential naming conflicts.


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.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 7, 2025

@johanneskoester johanneskoester merged commit 045c612 into snakemake:main Mar 9, 2025
50 checks passed
@fgvieira fgvieira deleted the module_schema_validation branch March 9, 2025 13:53
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
<!--Add a description of your PR here-->

### QC
<!-- Make sure that you can tick the boxes below. -->

* [x] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [x] 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).


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a modular test workflow that streamlines execution, with
new rules for generating test outputs.
- Added a dedicated configuration validation schema enforcing stricter
checks on required inputs.
- **Refactor**
- Reordered configuration validation to ensure consistency immediately
after loading.
- **Chores**
- Updated schema URLs in configuration files to align with current
standards.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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