Skip to content

Conversation

@cademirch
Copy link
Contributor

@cademirch cademirch commented Jul 28, 2025

Adds scaffolding for logger plugin.

tests.py is incomplete. It was rather difficult for me to come up with a way to build an abstract test class for logging.

I considered using https://github.com/snakemake/snakemake/blob/main/src/snakemake/common/tests/__init__.py like the reporter does, but it would take a fair amount of changes in that code to accomodate specifiying the logger plugin.

Testing logging is also a bit difficult in general since for the most part it requires visual inspection.

I can try to find some time to tinker with the tests more, but would appreciate any feedback.

Summary by CodeRabbit

  • New Features
    • Added scaffolding for Snakemake logger plugins with ready-to-use templates, example handler, and configurable settings to bootstrap custom logging.
  • Tests
    • Expanded test coverage to include the logger plugin type and added a concrete test harness to validate logger implementations.
  • Chores
    • CLI scaffold command now accepts "logger" as a plugin type option.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

📝 Walkthrough

Walkthrough

Adds scaffolding support for a Snakemake logger plugin: new scaffold plugin class, logger plugin template (module + tests), package registration, and inclusion of logger in the client scaffolding test loop.

Changes

Cohort / File(s) Change Summary
Scaffold plugin implementation
snakedeploy/scaffold_plugins/logger_plugins.py
Added ScaffoldSnakemakeLoggerPlugin implementing get_templates, get_plugin_type, and include_snakemake_dev_dependency to scaffold logger plugins.
Templates — logger plugin code
snakedeploy/templates/plugins/logger-plugins/__init__.py
Added LogHandlerSettings dataclass and LogHandler class with customization points, metadata, and placeholder properties/methods for logger behavior.
Templates — logger plugin tests
snakedeploy/templates/plugins/logger-plugins/tests.py
Added TestConcreteRichPlugin concrete test class extending TestLogHandlerBase with placeholder methods get_log_handler_cls and get_log_handler_settings.
Package registration
snakedeploy/scaffold_plugins/__init__.py
Imported ScaffoldSnakemakeLoggerPlugin and added "logger" scaffold type handling to instantiate it.
Client test script
tests/test_client.sh
Updated assertions to expect config.yaml and extended the scaffolded plugin test loop to include logger; adjusted destination path construction for plugin tests.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as snakedeploy CLI
    participant Scaffold as ScaffoldSnakemakeLoggerPlugin
    participant Templates as logger-plugins templates
    participant FS as Filesystem

    CLI->>Scaffold: request scaffold type="logger"
    activate Scaffold
    Scaffold->>Templates: get_templates(module_path, tests_path)
    Templates-->>Scaffold: list of (template_name, target_path)
    Scaffold->>FS: write module and test files to target paths
    FS-->>Scaffold: write results
    Scaffold-->>CLI: return generated paths / status
    deactivate Scaffold
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: add logger plugin scaffold" is fully related to the main change in the changeset. The changes introduce comprehensive scaffolding infrastructure for logger plugins in Snakemake, including a new ScaffoldSnakemakeLoggerPlugin class, logger plugin templates (init.py and tests.py), addition of "logger" to the plugin type choices in the CLI, and corresponding test updates. The title clearly and concisely summarizes the primary purpose of these changes: adding scaffolding capability for logger plugins. While it doesn't capture every detail (such as the specific template files or test modifications), this is expected and appropriate for a PR title.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-add-logger-plugin-scaffold

📜 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 c142fc8 and c79534d.

⛔ Files ignored due to path filters (1)
  • pyproject.toml is excluded by !pyproject.toml
📒 Files selected for processing (2)
  • snakedeploy/client.py (1 hunks)
  • tests/test_client.sh (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_client.sh
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

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

Files:

  • snakedeploy/client.py
🔇 Additional comments (1)
snakedeploy/client.py (1)

245-245: LGTM!

The addition of "logger" to the plugin type choices is correct and aligns with the PR objective to add logger plugin scaffolding support.


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

Tip

🧪 Early access (models): enabled

We are currently testing Sonnet 4.5 code review models, which should lead to better review quality. However, this model may result in higher noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
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: 0

🧹 Nitpick comments (1)
snakedeploy/templates/plugins/logger-plugins/init.py (1)

8-32: Fix placeholder values in metadata.

The dataclass structure and documentation are excellent for a template. However, the ellipsis placeholders in the metadata should be handled properly.

             # Optionally specify a function that parses the value given by the user.
             # This is useful to create complex types from the user input.
-            "parse_func": ...,
+            # "parse_func": your_parse_function,
             # If a parse_func is specified, you also have to specify an unparse_func
             # that converts the parsed value back to a string.
-            "unparse_func": ...,
+            # "unparse_func": your_unparse_function,

This prevents potential syntax errors when developers use the template and provides clearer guidance on how to specify these optional functions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0e78b and 36ddc91.

📒 Files selected for processing (3)
  • snakedeploy/scaffold_plugins/logger_plugins.py (1 hunks)
  • snakedeploy/templates/plugins/logger-plugins/init.py (1 hunks)
  • tests/test_client.sh (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit Configuration File

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

Files:

  • snakedeploy/scaffold_plugins/logger_plugins.py
  • snakedeploy/templates/plugins/logger-plugins/init.py
🧬 Code Graph Analysis (1)
snakedeploy/scaffold_plugins/logger_plugins.py (2)
snakedeploy/scaffold_plugins/common.py (1)
  • ScaffoldPlugin (11-170)
snakedeploy/providers.py (1)
  • name (87-88)
🔇 Additional comments (9)
snakedeploy/scaffold_plugins/logger_plugins.py (4)

7-12: LGTM!

The class definition follows the proper inheritance pattern and includes appropriate name and description attributes that clearly identify the plugin's purpose.


14-20: LGTM!

The method correctly implements the abstract interface, providing appropriate template mappings for the logger plugin scaffolding.


22-23: LGTM!

The method correctly returns "logger" as the plugin type, which aligns with the scaffolding purpose.


25-26: Logger plugins correctly opt-out of Snakemake dev dependency

The include_snakemake_dev_dependency() override in logger_plugins.py returns False, matching the behavior of storage, software-deployment, and scheduler plugins. Only executor and report plugins return True (to pull in Snakemake for their specific test scenarios). No change needed here.

tests/test_client.sh (1)

88-88: LGTM!

Properly adds logger plugin type to the automated scaffolding tests, ensuring the new functionality is covered by the test suite.

snakedeploy/templates/plugins/logger-plugins/init.py (4)

1-6: LGTM!

The imports are well-organized and include the necessary dependencies for creating a logger plugin template.


35-46: LGTM!

Excellent template structure with comprehensive documentation. The use of __post_init__ instead of overriding __init__ is well-explained and follows the plugin interface best practices.


48-56: LGTM!

Excellent educational comments that provide valuable context about Snakemake's logging system and point developers to relevant documentation and examples.


58-93: LGTM!

The property methods are well-documented with comprehensive guidance for developers. The placeholder implementations with ellipsis are appropriate for a template, and the extensive comments clearly explain the purpose and expected behavior of each property.

@johanneskoester
Copy link
Contributor

I agree, not straightforward what the test class should test for loggers. Maybe it is more like testing instantiation of the logger, giving it some dummy messages and just expecting them to be processed without error. That should be enough as a start.

Copy link
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
snakedeploy/scaffold_plugins/__init__.py (1)

1-31: Address Ruff TRY003 violation
In snakedeploy/scaffold_plugins/__init__.py:31, avoid specifying long messages outside exception classes—move the “Unknown plugin type: {plugin_type}” message into UserError or simplify the raise.
Run ruff check --exit-zero to confirm no remaining violations.

🧹 Nitpick comments (1)
snakedeploy/templates/plugins/logger-plugins/tests.py (1)

1-1: Make the template test actionable and generic (remove “rich”, implement hooks).

Replace ellipses with a minimal, working implementation that imports the scaffolded plugin, with an env override for flexibility. Also generalize the wording.

-from snakemake_interface_logger_plugins.tests import TestLogHandlerBase
+from snakemake_interface_logger_plugins.tests import TestLogHandlerBase
+import importlib
+import os
@@
-class TestConcreteRichPlugin(TestLogHandlerBase):
-    """Concrete test using the actual rich plugin to verify the abstract test class works."""
+class TestTemplateLoggerPlugin(TestLogHandlerBase):
+    """Concrete test using the scaffolded logger plugin to verify the abstract test base."""
@@
-    def get_log_handler_cls(self):
-        """Return the rich log handler class."""
-        ...
+    def get_log_handler_cls(self):
+        """Return the scaffolded LogHandler class."""
+        module_name = os.environ.get("SNAKEPLUGIN_MODULE", "your_plugin_package")
+        module = importlib.import_module(module_name)
+        return module.LogHandler
@@
-    def get_log_handler_settings(self):
-        """Return the rich settings with default values for testing."""
-        ...
+    def get_log_handler_settings(self):
+        """Return default scaffolded LogHandlerSettings for testing."""
+        module_name = os.environ.get("SNAKEPLUGIN_MODULE", "your_plugin_package")
+        module = importlib.import_module(module_name)
+        return module.LogHandlerSettings()

Note: replace "your_plugin_package" with the actual package name in the scaffold, or set SNAKEPLUGIN_MODULE in CI.

Also applies to: 4-16

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 36ddc91 and 1c5fea4.

📒 Files selected for processing (2)
  • snakedeploy/scaffold_plugins/__init__.py (2 hunks)
  • snakedeploy/templates/plugins/logger-plugins/tests.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

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

Files:

  • snakedeploy/scaffold_plugins/__init__.py
  • snakedeploy/templates/plugins/logger-plugins/tests.py
🧬 Code graph analysis (1)
snakedeploy/scaffold_plugins/__init__.py (1)
snakedeploy/scaffold_plugins/logger_plugins.py (1)
  • ScaffoldSnakemakeLoggerPlugin (7-26)
🪛 GitHub Actions: CI
snakedeploy/scaffold_plugins/__init__.py

[error] 1-1: Ruff formatting check detected that the file would be reformatted by 'ruff format --check'. Run 'ruff format' to fix code style issues.

🔇 Additional comments (1)
snakedeploy/scaffold_plugins/__init__.py (1)

13-13: Logger plugin dispatch: LGTM; scaffolding already sets project.requires-python to >=3.11,<4.0 (common.py:66), which satisfies the match/case requirement.

@cademirch
Copy link
Contributor Author

Unsure about why test is failing seems related to the workflow template?

@johanneskoester johanneskoester merged commit da2d149 into main Sep 29, 2025
6 checks passed
@johanneskoester johanneskoester deleted the feat-add-logger-plugin-scaffold branch September 29, 2025 18:31
johanneskoester pushed a commit that referenced this pull request Sep 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.13.0](v0.12.3...v0.13.0)
(2025-09-29)


### Features

* add logger plugin scaffold
([#94](#94))
([da2d149](da2d149))

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

3 participants