-
Notifications
You must be signed in to change notification settings - Fork 2
fix: Require emit() method implementation #35
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
Conversation
📝 WalkthroughWalkthroughAdds an abstract emit(record: LogRecord) method to LogHandlerBase and updates README examples to demonstrate overriding and using emit (including simple filtering and formatted output). Also contains minor whitespace and formatting tweaks in README examples. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client as Snakemake Runtime
participant Logger as Logger
participant Handler as LogHandlerBase (subclass)
Note over Client,Handler: Logging flow with new emit(record) contract
Client->>Logger: log(LogRecord)
Logger->>Handler: handle(record)
alt passes Handler.filter(record)
Handler->>Handler: emit(record)
Note right of Handler: Subclass implements output (console/file/etc.)
else filtered out
Handler-->>Logger: no-op
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal). Please share your feedback with us on this Discord post. 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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
README.md (2)
58-59
: Avoid no-op attribute references in example
self.settings
andself.common_settings
as standalone expressions are no-ops and may confuse readers. Replace with a comment or remove.- # access settings attributes - self.settings - self.common_settings + # access settings via self.settings and self.common_settings as needed
157-164
: Clarify rule-name filtering: prefer record.rule_name over record.nameIn stdlib logging,
record.name
is the logger name, not the Snakemake rule name. If the rule name is exposed asrecord.rule_name
, prefer that and fall back torecord.name
only if needed.- if hasattr(record, 'name') and record.name in ['rule1', 'rule2']: + rule_name = getattr(record, 'rule_name', getattr(record, 'name', None)) + if rule_name in ['rule1', 'rule2']:Can you confirm whether Snakemake consistently provides
rule_name
on JOB_ERROR records in the current version? If not, the fallback torecord.name
(logger name) should be explicitly documented as such to avoid confusion.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
README.md
(2 hunks)src/snakemake_interface_logger_plugins/base.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 theself
argument of methods.
Do not suggest type annotation of thecls
argument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturn
statement.
Files:
src/snakemake_interface_logger_plugins/base.py
🧠 Learnings (1)
📚 Learning: 2025-02-12T10:48:34.812Z
Learnt from: johanneskoester
PR: snakemake/snakemake-interface-logger-plugins#9
File: src/snakemake_interface_logger_plugins/registry/plugin.py:20-21
Timestamp: 2025-02-12T10:48:34.812Z
Learning: In the `Plugin` class of snakemake-interface-logger-plugins, the `log_handler` field should be annotated with `Type[LogHandlerBase]` as it stores the class type, not an instance.
Applied to files:
src/snakemake_interface_logger_plugins/base.py
🔇 Additional comments (3)
src/snakemake_interface_logger_plugins/base.py (1)
30-36
: Abstract emit() is a deliberate breaking change—confirm versioning/commsMarking
emit()
as abstract will prevent instantiation of existing plugins that didn’t override it (now failing at import/instantiation rather than at first use). That’s preferable, but please ensure release notes and versioning reflect this requirement and that downstream templates/examples are updated (README has been updated—thanks).README.md (2)
62-64
: Good clarification that emit() is the only required Handler overrideThis sets the right expectation and points to the official docs. LGTM.
71-76
: Emit() example is clear and actionableThe guidance to call
self.format(record)
and write to a stream/file is appropriate for plugin authors.
thanks! |
Could you add the missing import? Happy to merge after tests pass. |
Thanks for fixing, sorry wasn't able to get to it last night. |
🤖 I have created a release *beep* *boop* --- ## [1.2.5](v1.2.4...v1.2.5) (2025-09-28) ### Bug Fixes * call logging.Handler init in base class ([#34](#34)) ([a3bd247](a3bd247)) * Require emit() method implementation ([#35](#35)) ([71e6372](71e6372)) ### Documentation * add basefilename requirement ([#38](#38)) ([38d2993](38d2993)), closes [#37](#37) --- 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>
This change was introduced in PR #35 but was not properly documented as breaking. Plugin authors need to ensure their LogHandlerBase implementations include an emit() method that handles log record processing.
BREAKING CHANGE: All LogHandlerBase subclasses must now implement the emit() method. This change was introduced in PR #35 but was not properly documented as breaking. Plugin authors need to ensure their LogHandlerBase implementations include an emit() method that handles log record processing.
BREAKING CHANGE: All LogHandlerBase subclasses must now implement the emit() method. This change was introduced in PR #35 but was not properly documented as breaking. Plugin authors need to ensure their LogHandlerBase implementations include a concrete emit() method.
Plugin handler classes will not work without an implementation of
emit()
(thelogging.Handler
version just raisesNotImplementedError
). The README mentions overriding the method but it is not obvious that it is a requirement.This updates the example code in the README to include an
emit()
method. It also marks the method as abstract inLogHandlerBase
. The latter is not strictly required but would probably result in a clearer error message, and the class already inherits from ABC.Summary by CodeRabbit
New Features
Documentation