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: enable event reports #364

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FelixMoelder
Copy link
Contributor

@FelixMoelder FelixMoelder commented Feb 24, 2025

Currently the workflow does not create any reports when reports are enabled in the config.
This happens as we have a global option for creating reports by checking config["report"]["activate"].
Still, when enabling this option no report will be created as for every single event the workflow checks if it contains a report property and defaults to False if non exists.
This is misleading as the global option indicates that reports will be created while it is currently opt-in instead of opt-out for every single event.

Summary by CodeRabbit

  • Bug Fixes
    • Updated the handling of missing configuration settings so that, when expected data isn’t provided, the system now produces a more complete and consistent output.

Copy link

coderabbitai bot commented Feb 24, 2025

Walkthrough

The pull request updates the get_final_output function within workflow/rules/common.smk by changing the default value passed to the lookup function from False to True. This modifies the control flow so that when the specified configuration path is missing, it is now interpreted as a positive condition, potentially affecting the subsequent logic that extends the final_output list.

Changes

File Path Change Summary
workflow/rules/common.smk Updated the default value in the call to lookup within get_final_output from False to True to alter control flow

Sequence Diagram(s)

sequenceDiagram
    participant G as get_final_output
    participant L as lookup

    G->>L: Call lookup(path, default=True)
    alt Path Found
        L-->>G: Return actual value
    else Path Not Found
        L-->>G: Return True
    end
    G->>G: Process result into final_output
Loading

Possibly related PRs

Suggested reviewers

  • johanneskoester

Poem

I'm hopping through the code, so bright and true,
A tiny tweak shifts path from False to True.
With every line a bounce, a joyful little leap,
Debugs and outputs in a rhythm deep.
From a rabbit's heart, cheers for changes anew!
🐇✨


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (1)
workflow/rules/common.smk (1)

166-207: Consider refactoring the nested conditional logic.

The report generation logic contains deeply nested conditionals that make it harder to understand the control flow. Consider extracting the report generation logic into a separate function for better readability and maintainability.

-    for calling_type in calling_types:
-        if config["report"]["activate"]:
-            for event in get_calling_events(calling_type):
-                if lookup(
-                    dpath=f"calling/fdr-control/events/{event}/report",
-                    within=config,
-                    default=True,
-                ):
-                    final_output.extend(
-                        expand(
-                            "results/datavzrd-report/{batch}.{event}.{calling_type}.fdr-controlled",
-                            batch=get_report_batches(calling_type),
-                            event=event,
-                            calling_type=calling_type,
-                        )
-                    )
-                else:
-                    final_output.extend(
-                        expand(
-                            "results/final-calls/{group}.{event}.{calling_type}.fdr-controlled.bcf",
-                            group=(
-                                variants_groups
-                                if calling_type == "variants"
-                                else fusions_groups
-                            ),
-                            event=event,
-                            calling_type=calling_type,
-                        )
-                    )
+def get_report_outputs(calling_type, event):
+    """Generate report outputs for a given calling type and event."""
+    if not config["report"]["activate"]:
+        return []
+    
+    if lookup(
+        dpath=f"calling/fdr-control/events/{event}/report",
+        within=config,
+        default=True,
+    ):
+        return expand(
+            "results/datavzrd-report/{batch}.{event}.{calling_type}.fdr-controlled",
+            batch=get_report_batches(calling_type),
+            event=event,
+            calling_type=calling_type,
+        )
+    else:
+        return expand(
+            "results/final-calls/{group}.{event}.{calling_type}.fdr-controlled.bcf",
+            group=(
+                variants_groups
+                if calling_type == "variants"
+                else fusions_groups
+            ),
+            event=event,
+            calling_type=calling_type,
+        )

+def get_final_output(wildcards):
+    final_output = expand(
+        "results/qc/multiqc/{group}.html",
+        group=groups,
+    )
+
+    final_output.extend(
+        expand(
+            "results/datavzrd-report/{group}.coverage",
+            group=groups,
+        )
+    )
+
+    for calling_type in calling_types:
+        for event in get_calling_events(calling_type):
+            final_output.extend(get_report_outputs(calling_type, event))
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 75a332c and 563d7ee.

📒 Files selected for processing (1)
  • workflow/rules/common.smk (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Formatting
🔇 Additional comments (2)
workflow/rules/common.smk (2)

172-172: Approve the change to enable reports by default.

This change aligns with the PR objectives by making report generation opt-out instead of opt-in when reports are globally enabled. This fixes the issue where reports were not being generated even when activated in the configuration.


167-181:

❓ Verification inconclusive

Verify the impact of enabling reports by default.

The change affects the report generation logic when config["report"]["activate"] is True. Now, if an event's report configuration is not explicitly set to False, a report will be generated. This could lead to unexpected report generation for events that previously didn't have reports.

Let's verify the potential impact:


🏁 Script executed:

#!/bin/bash
# Description: Check for events that might be affected by the default value change

# Search for event configurations that don't explicitly set the report property
ast-grep --pattern $'calling:
  fdr-control:
    events:
      $_:
        $$$'

# Search for any existing report configurations
rg -A 5 'report:' 

Length of output: 276


Subject: Verify Default Report Generation Behavior in common.smk

The code now uses a lookup with a default value of True, which means that if an event’s configuration does not explicitly set report to False, a report will be generated. Our repository search (via the provided shell scripts) did not reveal any explicit disabling of reports for events. This indicates that enabling reports by default may lead to a broader set of reports than previously expected.

  • Impact: Events lacking an explicit report configuration will now generate reports, which could be unintentional.
  • Action: Double-check the event configuration files and related settings (e.g., in workflow/Snakefile) to ensure this default behavior aligns with your intended workflow.

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