fix: load concrete Env/EnvSpec classes instead of abstract bases#58
Merged
johanneskoester merged 1 commit intoJun 26, 2026
Merged
Conversation
load_plugin() read module.EnvBase / module.EnvSpecBase, which resolve to the abstract base classes (each plugin imports them as base classes), so plugin.env_spec_cls was always EnvSpecBase. As a result, e.g. source_path_attributes() returned None and snakemake's software-deployment directive factory crashed when wrapping source path attributes. Read module.Env / module.EnvSpec -- the concrete classes that expected_attributes() already requires -- instead.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe plugin registry now constructs ChangesPlugin registry environment classes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
johanneskoester
approved these changes
Jun 26, 2026
johanneskoester
pushed a commit
that referenced
this pull request
Jun 26, 2026
🤖 I have created a release *beep* *boop* --- ## [0.18.3](v0.18.2...v0.18.3) (2026-06-26) ### Bug Fixes * load concrete Env/EnvSpec classes instead of abstract bases ([#58](#58)) ([78c2d62](78c2d62)) --- 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>
johanneskoester
added a commit
to snakemake/snakemake-software-deployment-plugin-envmodules
that referenced
this pull request
Jun 28, 2026
## Problem `EnvSpec.identity_attributes` and `EnvSpec.source_path_attributes` are defined as instance methods (`self`), but the interface base (`snakemake_interface_software_deployment_plugins.EnvSpecBase`) and the sibling plugins (conda, container) declare them as `@classmethod` (`cls`). ## Impact `EnvSpecBase.__hash__` -> `managed_identity_attributes()` (a classmethod) calls `cls.identity_attributes()`. Because this plugin's `identity_attributes` is an instance method, that call raises: ``` TypeError: EnvSpec.identity_attributes() missing 1 required positional argument: 'self' ``` So every envmodules spec is **unhashable**. Anywhere a spec is used as a dict key or set member it crashes — in particular `SoftwareDeploymentManager.get_env()` does `if env_spec in self.specs_to_envs:`, which hashes the spec. This breaks standalone `envmodules(...)` usage and the fallback chain `envmodules(...) or conda(...)` (the headline composition form). ## Fix Make both methods `@classmethod`, matching the interface and the other plugins: ```python @classmethod def identity_attributes(cls) -> Iterable[str]: yield "names" @classmethod def source_path_attributes(cls) -> Iterable[str]: return () ``` Neither body uses `self`, so this is a drop-in fix. ## Verification After the change, envmodules specs are hashable (`hash(spec)` succeeds) and `get_env()` no longer crashes on the fallback path. Context: snakemake/snakemake#4209; related interface fix: snakemake/snakemake-interface-software-deployment-plugins#58. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved how environment module details are handled, making environment identification and hashing more reliable. * Fixed shell command handling so module names with unsafe characters are quoted correctly. * Ensured environment records are created consistently and can be used as dictionary keys without issues. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SoftwareDeploymentPluginRegistry.load_plugin()populated thePluginwith:Each plugin module imports
EnvBase/EnvSpecBaseas the abstract base classes for its ownEnv/EnvSpecsubclasses, somodule.EnvBase/module.EnvSpecBaseresolve to those abstract bases — not the concrete classes the plugin defines. As a resultplugin.env_spec_clswas alwaysEnvSpecBase(and_env_clsalwaysEnvBase) for every plugin.This is inconsistent with
expected_attributes(), which already correctly requires the concreteEnvandEnvSpecattributes.Impact
Because
plugin.env_spec_clswas the abstractEnvSpecBase, methods likesource_path_attributes()(abstract body...) returnedNone. Snakemake's software-deployment directive factory iteratesplugin.env_spec_cls.source_path_attributes()and crashed:This broke every
software: <kind>(...)directive at parse time (conda/container/envmodules), so the whole generic software-deployment feature was unusable with the published plugin versions.Fix
Read the concrete classes that plugins actually expose:
Verification
With this change plus the corresponding snakemake-side fixes, the
software: conda(envfile=...)path works end-to-end (the conda env is created and the rule runs); before this, anysoftware:directive crashed in the factory.plugin.env_spec_clsnow resolves to the concrete class for all plugins, e.g.:Context: snakemake/snakemake#4209.
Summary by CodeRabbit