Draft: pythonic run_module(**kwargs) with auto-grouping#18
Draft
mathysgrapotte wants to merge 5 commits intomasterfrom
Draft
Draft: pythonic run_module(**kwargs) with auto-grouping#18mathysgrapotte wants to merge 5 commits intomasterfrom
mathysgrapotte wants to merge 5 commits intomasterfrom
Conversation
added 5 commits
January 31, 2026 11:52
Owner
Author
|
Pushed a readability-focused refactor of the kwargs auto-grouping ( Main simplifications:
This trades away “clever” mapping in favor of explicit + predictable behavior. |
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.
This PR is a draft / first pass at a more Pythonic nf-core module API.
Goal
result = pynf.run_module("<module_id>", param1=..., param2=...)param*are module inputs, and py-nf auto-maps them onto Nextflow input channels.Summary of code changes (by file)
src/pynf/__init__.pypynf.run_module(...)to mean: run an nf-core module via a keyword-arg API.run_module(module_id: str, *, executor="local", docker=False, cache_dir=..., github_token=None, params=None, verbose=False, force_download=False, **inputs) -> ModuleResultModuleResult(aNamedTuple) as the “tuple-like” return type:output_files: list[str]workflow_outputs: list[dict]report: dictraw: NextflowResultapi.get_module_inputs(...)to introspect expected input channelsauto_group_inputs(...)to convert**inputs→ExecutionRequest.inputs(list-of-dicts)run_nfcore_module(...)NextflowResultintoModuleResultfor easy unpacking + still exposingrawDesign choice:
ModuleResultkeeps the “pythonic tuple” feel without losing access to the fullNextflowResult.src/pynf/_core/pythonic_api.py(new)Design choice: this is “constrained magic” — ambiguity is an error, because guessing would be too surprising.
tests/test_pythonic_api_grouping.py(new)monkeypatchto stub:pynf.api.get_module_inputs(...)pynf.run_nfcore_module(...)template/pynf/__init__.pyiModuleResultrun_module(...)signaturetemplate/pynf/_core/pythonic_api.pyi(new)README.mdrun_module("path/to/script.nf")to userun_script(...).run_modulenow means “run nf-core module by id”.)Design / tradeoffs
**inputscan’t be mapped uniquely to the module input channels, we raise and tell users to pass explicit grouped inputs (viaExecutionRequest.inputs).ModuleResult, but you can also inspectraw(the underlyingNextflowResult).Follow-ups / open questions
run_module(path: Path)name somewhere (e.g.run_scriptalias), or is renaming acceptable?run_module_groups(module_id, groups=[...])helper as the non-magic escape hatch?quay.iowhendocker=True; we might want a more explicitdocker_config=option here.