fix: Restore python rules changes triggering reruns. (GH: #3213)#3485
fix: Restore python rules changes triggering reruns. (GH: #3213)#3485johanneskoester merged 3 commits intosnakemake:mainfrom
Conversation
📝 WalkthroughWalkthroughThis pull request updates how rule source code is captured and utilized. The Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/snakemake/workflow.py (1)
1953-1954: Good caching implementation for rule source code.These lines add the source code caching mechanism by storing the rule's source code in
rule.run_func_srcwhen a rule function is defined. This will help prevent unnecessary reruns when rule source hasn't changed meaningfully.Since you mentioned needing help with testing, I'd suggest a test case that:
- Creates a workflow with a Python rule
- Runs it once and verifies completion
- Runs again without changes to verify it doesn't rerun (up-to-date)
- Makes a comment-only change to the rule source
- Verifies it still doesn't rerun
- Makes a functional change to the source
- Verifies it does rerun (rule marked as outdated)
Would you like me to help develop this test case for you?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/snakemake/persistence.py(1 hunks)src/snakemake/rules.py(1 hunks)src/snakemake/workflow.py(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...
**/*.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 theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
src/snakemake/persistence.pysrc/snakemake/rules.pysrc/snakemake/workflow.py
🧬 Code Definitions (2)
src/snakemake/persistence.py (1)
src/snakemake/workflow.py (2)
rule(1735-2018)shellcmd(2230-2235)
src/snakemake/workflow.py (3)
src/snakemake/rules.py (1)
lineno(138-139)src/snakemake/parser.py (1)
lineno(74-75)src/snakemake/persistence.py (1)
rule(426-427)
⏰ Context from checks skipped due to timeout of 90000ms (34)
- GitHub Check: tests (10, windows-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py311)
- GitHub Check: tests (9, windows-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py311)
- GitHub Check: tests (8, windows-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py311)
- GitHub Check: tests (7, windows-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py311)
- GitHub Check: tests (6, macos-latest, py312)
- GitHub Check: tests (6, windows-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py311)
- GitHub Check: tests (5, macos-latest, py312)
- GitHub Check: tests (5, windows-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py311)
- GitHub Check: tests (4, macos-latest, py312)
- GitHub Check: tests (4, windows-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py311)
- GitHub Check: tests (3, windows-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py311)
- GitHub Check: tests (2, windows-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py311)
- GitHub Check: tests (1, macos-latest, py312)
- GitHub Check: tests (1, windows-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py311)
🔇 Additional comments (4)
src/snakemake/rules.py (1)
110-110: Good addition of the run_func_src attribute.This new attribute will store the source code of Python rule functions, enabling caching for run functions like it's done for shell commands. This change aligns with the PR objective of implementing a source code caching mechanism to prevent unnecessary reruns.
src/snakemake/persistence.py (1)
557-562: Good implementation of source caching for Python run functions.This change properly extends the
_codemethod to handle both shell commands and Python function source code. The updated comment also correctly reflects this dual capability. The implementation preserves existing behavior for shell commands while adding support for caching Python function source code when available.This change, combined with the new
run_func_srcattribute and theget_rule_sourcemethod inworkflow.py, should effectively address issue #3213 by preventing unnecessary reruns when Python rules are used.src/snakemake/workflow.py (2)
13-14: Added necessary imports for rule source retrieval.The new imports of
disandlinecachemodules are needed for the source code extraction functionality being implemented.
1717-1734: Well-implemented source code extraction method.This new
get_rule_sourcemethod extracts the source code of a rule function by:
- Using
dis.findlinestarts()to locate line numbers in the compiled function's bytecode- Mapping these to original source lines via
self.linemaps- Retrieving the actual source lines with
linecache.getline()The comments explain clearly why
inspectmodule couldn't be used and how the implementation works. The function is thoughtfully designed to skip the first instruction (rule declaration line) and only include the actual rule body code.
55ef9d0 to
ea0782f
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/snakemake/workflow.py (2)
1717-1735: Implementation for extracting rule function source code looks solidThis new method retrieves the source code of a rule function by using the
dismodule to analyze bytecode and map line numbers to the original source file. The approach is well documented and handles the edge case of skipping the first line (offset 0) that corresponds to the rule definition line.I have a minor concern about error handling - the code assumes that
sourcefileis always present inself.linemapsand there's no try/except block to handle cases where line numbers might not be present in the map or issues with reading source files.Consider adding error handling to gracefully handle cases where:
sourcefileisn't inself.linemaps- Line numbers from
dis.findlinestarts()aren't inlinemaplinecache.getline()fails to read the filedef get_rule_source(self, func): # This can't use `inspect` because the functions are compiled into intermediate python code # in parser.py and that intermediate source is not available anymore (or desirable). # Instead, we're using dis to retrieve the line numbers of the function in the intermediate # code and then map it to the original file using `self.linemaps`. sourcefile = func.__code__.co_filename line_numbers = [] - linemap = self.linemaps[sourcefile] + try: + linemap = self.linemaps.get(sourcefile, {}) + if not linemap: + return "" + + for func_offset, line in dis.findlinestarts(func.__code__): + # The first instruction in the compiled function is RESUME, which + # with snakemake is mapped to the 'rule: ' line and is not considered + # part of the rule source. + if func_offset == 0: + continue + if line in linemap: + line_numbers.append(linemap[line]) + + return "".join( + [linecache.getline(sourcefile, lineno) for lineno in sorted(line_numbers)] + ) + except Exception as e: + logger.debug(f"Could not extract source for rule function: {e}") + return "" - for func_offset, line in dis.findlinestarts(func.__code__): - # The first instruction in the compiled function is RESUME, which - # with snakemake is mapped to the 'rule: ' line and is not considered - # part of the rule source. - if func_offset == 0: - continue - if line in linemap: - line_numbers.append(linemap[line]) - return "".join( - [linecache.getline(sourcefile, lineno) for lineno in sorted(line_numbers)] - )
1-2411: Consider adding unit tests for the source code extraction functionalityThe PR objectives mention a need for assistance with developing a test for these changes. Implementing a test would be beneficial to verify that the source code extraction works correctly and that it prevents unnecessary reruns of Python rules.
I can help develop a test case that would:
- Create a rule with a Python function
- Extract and verify the source code
- Test that changes to comments or formatting don't trigger reruns
- Test that actual code changes do trigger reruns
Would you like me to draft a test implementation for this feature?
🧰 Tools
🪛 Ruff (0.8.2)
68-68:
snakemake.exceptions.update_linenoimported but unusedRemove unused import:
snakemake.exceptions.update_lineno(F401)
75-75:
snakemake.io.protectedimported but unusedRemove unused import
(F401)
76-76:
snakemake.io.tempimported but unusedRemove unused import
(F401)
77-77:
snakemake.io.temporaryimported but unusedRemove unused import
(F401)
78-78:
snakemake.io.ancientimported but unusedRemove unused import
(F401)
79-79:
snakemake.io.directoryimported but unusedRemove unused import
(F401)
81-81:
snakemake.io.glob_wildcardsimported but unusedRemove unused import
(F401)
82-82:
snakemake.io.flagimported but unusedRemove unused import
(F401)
83-83:
snakemake.io.touchimported but unusedRemove unused import
(F401)
84-84:
snakemake.io.unpackimported but unusedRemove unused import
(F401)
85-85:
snakemake.io.localimported but unusedRemove unused import
(F401)
86-86:
snakemake.io.pipeimported but unusedRemove unused import
(F401)
87-87:
snakemake.io.serviceimported but unusedRemove unused import
(F401)
88-88:
snakemake.io.repeatimported but unusedRemove unused import
(F401)
89-89:
snakemake.io.reportimported but unusedRemove unused import
(F401)
90-90:
snakemake.io.multiextimported but unusedRemove unused import
(F401)
91-91:
snakemake.io.ensureimported but unusedRemove unused import
(F401)
99-99:
snakemake.script.scriptimported but unusedRemove unused import:
snakemake.script.script(F401)
100-100:
snakemake.notebook.notebookimported but unusedRemove unused import:
snakemake.notebook.notebook(F401)
101-101:
snakemake.wrapper.wrapperimported but unusedRemove unused import:
snakemake.wrapper.wrapper(F401)
102-102:
snakemake.cwl.cwlimported but unusedRemove unused import:
snakemake.cwl.cwl(F401)
103-103:
snakemake.template_rendering.render_templateimported but unusedRemove unused import:
snakemake.template_rendering.render_template(F401)
104-104:
snakemake_interface_common.utils.not_iterableimported but unusedRemove unused import:
snakemake_interface_common.utils.not_iterable(F401)
112-112:
snakemake.common.Rulesimported but unusedRemove unused import:
snakemake.common.Rules(F401)
132-132:
snakemake.apiimported but unusedRemove unused import:
snakemake.api(F401)
355-356: Use a single
ifstatement instead of nestedifstatements(SIM102)
397-397: Redefinition of unused
touchfrom line 83(F811)
750-754: Do not assign a
lambdaexpression, use adefRewrite
relpathas adef(E731)
908-912: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
1038-1038: Redefinition of unused
cwlfrom line 102(F811)
1682-1682: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
1691-1691: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
1702-1702: Redefinition of unused
reportfrom line 89(F811)
1857-1859: Multiple
isinstancecalls forr, merge into a single callMerge
isinstancecalls forr(SIM101)
1885-1886: Use a single
ifstatement instead of nestedifstatements(SIM102)
1945-1945: Avoid inequality comparisons to
False; useif ruleinfo.container_img:for truth checksReplace with
ruleinfo.container_img(E712)
2114-2116: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
2135-2138: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
2239-2239: Redefinition of unused
scriptfrom line 99(F811)
2239-2239: Redefinition of unused
scriptfrom line 99(F811)
2246-2246: Redefinition of unused
notebookfrom line 100(F811)
2246-2246: Redefinition of unused
notebookfrom line 100(F811)
2253-2253: Redefinition of unused
wrapperfrom line 101(F811)
2253-2253: Redefinition of unused
wrapperfrom line 101(F811)
2267-2267: Redefinition of unused
cwlfrom line 102(F811)
2267-2267: Redefinition of unused
cwlfrom line 102(F811)
2335-2339: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
2354-2358: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
2361-2365: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/snakemake/persistence.py(1 hunks)src/snakemake/rules.py(1 hunks)src/snakemake/workflow.py(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/snakemake/rules.py
- src/snakemake/persistence.py
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...
**/*.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 theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
src/snakemake/workflow.py
🧬 Code Definitions (1)
src/snakemake/workflow.py (3)
src/snakemake/rules.py (1)
lineno(138-139)src/snakemake/parser.py (1)
lineno(74-75)src/snakemake/persistence.py (1)
rule(426-427)
⏰ Context from checks skipped due to timeout of 90000ms (36)
- GitHub Check: tests (10, macos-latest, py312)
- GitHub Check: tests (10, windows-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py311)
- GitHub Check: tests (9, windows-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py311)
- GitHub Check: tests (8, windows-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py311)
- GitHub Check: tests (7, windows-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py311)
- GitHub Check: tests (6, windows-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py311)
- GitHub Check: tests (5, windows-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py311)
- GitHub Check: tests (4, macos-latest, py312)
- GitHub Check: tests (4, windows-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py311)
- GitHub Check: tests (3, macos-latest, py312)
- GitHub Check: tests (3, windows-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py311)
- GitHub Check: tests (2, macos-latest, py312)
- GitHub Check: tests (2, windows-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py311)
- GitHub Check: tests (1, macos-latest, py312)
- GitHub Check: tests (1, windows-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py311)
- GitHub Check: apidocs
🔇 Additional comments (2)
src/snakemake/workflow.py (2)
13-14: New imports support source code extraction for rulesNew imports for the Python standard library modules
disandlinecacheare added to support the source code extraction functionality for rule functions.
1955-1956: Storing source code for rule run functionsThis change assigns the extracted source code to the rule object when a run function exists, completing the key part of this PR's functionality.
|
I guess having a testcase with a rule that has a run directive, which first runs the workflow with Also, should be assured that the new approach really captures the function code and not lines above or below the actual function. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/tests.py (1)
1907-1935: Excellent test implementation for the caching issue.This test follows the recommended approach perfectly:
- It runs the workflow initially and captures the outputs
- It clears the linecache to ensure new source code is picked up
- It replaces the Snakefile with a modified version
- It runs the workflow again without forcing to test if the change is detected naturally
- It runs a third time with forceall=True to get fresh outputs
- The assertions verify the expected behavior
The test is well-structured, but consider using context managers for file operations:
- ts_a1, ts_b1 = [open(os.path.join(tmpdir, f)).read() for f in ['file_a.txt', 'file_b.txt']] + ts_a1, ts_b1 = [open(os.path.join(tmpdir, f)).read() and f.close() for f in ['file_a.txt', 'file_b.txt']]Or better:
with open(os.path.join(tmpdir, 'file_a.txt')) as f_a, open(os.path.join(tmpdir, 'file_b.txt')) as f_b: ts_a1, ts_b1 = f_a.read(), f_b.read()And similarly for the other file reading operations.
🧰 Tools
🪛 Ruff (0.8.2)
1912-1912: Use a context manager for opening files
(SIM115)
1920-1920: Use a context manager for opening files
(SIM115)
1923-1923: Use a context manager for opening files
(SIM115)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/snakemake/workflow.py(3 hunks)tests/test_github_issue3213/Snakefile(1 hunks)tests/test_github_issue3213/Snakefile.newver(1 hunks)tests/tests.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/snakemake/workflow.py
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...
**/*.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 theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
tests/tests.py
🧬 Code Definitions (1)
tests/tests.py (1)
tests/common.py (2)
run(151-494)dpath(32-35)
🪛 Ruff (0.8.2)
tests/tests.py
1912-1912: Use a context manager for opening files
(SIM115)
1920-1920: Use a context manager for opening files
(SIM115)
1923-1923: Use a context manager for opening files
(SIM115)
⏰ Context from checks skipped due to timeout of 90000ms (34)
- GitHub Check: tests (10, windows-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py311)
- GitHub Check: tests (9, windows-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py311)
- GitHub Check: tests (8, windows-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py311)
- GitHub Check: tests (7, windows-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py311)
- GitHub Check: tests (6, windows-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py311)
- GitHub Check: tests (5, windows-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py311)
- GitHub Check: tests (4, macos-latest, py312)
- GitHub Check: tests (4, windows-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py311)
- GitHub Check: tests (3, macos-latest, py312)
- GitHub Check: tests (3, windows-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py311)
- GitHub Check: tests (2, macos-latest, py312)
- GitHub Check: tests (2, windows-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py311)
- GitHub Check: tests (1, macos-latest, py312)
- GitHub Check: tests (1, windows-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py311)
🔇 Additional comments (2)
tests/test_github_issue3213/Snakefile (1)
1-24: Test implementation looks good for checking rule source code caching.This file creates a simple workflow with three rules, each properly defined with input/output relationships. The
file_aandfile_brules each use arundirective to write their respective output files with timestamps usingtime.time_ns(). This setup will effectively test if changes to rule source code are properly detected or cached.The difference between this file and
Snakefile.newveris thatfile_bwrites "B" in this version, while it writes "D" in the newer version - perfect for testing source code change detection.tests/test_github_issue3213/Snakefile.newver (1)
1-24: Good implementation of the modified Snakefile for testing.This is a well-designed variation of the original Snakefile, with the only difference being that
file_bnow writes "D" instead of "B" to the output file. This small change is perfect for testing whether Snakemake properly detects changes to the source code in Pythonrunblocks.
f85e011 to
2a290d5
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/tests.py (1)
1907-1951: LGTM! Good test implementation for the Python rules caching mechanism.This test effectively validates that the caching solution works correctly by:
- Running a workflow and capturing output
- Clearing the linecache (crucial for the fix being tested)
- Changing the Snakefile and verifying only rules with changed code are rerun
- Verifying that forceall works as expected
Minor improvement opportunity: consider using context managers for file handling operations.
- ts_a1, ts_b1 = [open(os.path.join(tmpdir, f)).read() for f in output_files] + ts_a1, ts_b1 = [open(os.path.join(tmpdir, f)).read() for f in output_files] - ts_a2, ts_b2 = [open(os.path.join(tmpdir, f)).read() for f in output_files] + with open(os.path.join(tmpdir, f)) as file_a, open(os.path.join(tmpdir, f)) as file_b: + ts_a2 = file_a.read() + ts_b2 = file_b.read() - ts_a3, ts_b3 = [open(os.path.join(tmpdir, f)).read() for f in output_files] + ts_a3, ts_b3 = [open(os.path.join(tmpdir, f)).read() for f in output_files]Actually, a cleaner solution would be to create a helper function:
def read_output_files(directory, files): results = [] for f in files: with open(os.path.join(directory, f)) as file: results.append(file.read()) return results # Then use it like: ts_a1, ts_b1 = read_output_files(tmpdir, output_files)🧰 Tools
🪛 Ruff (0.8.2)
1914-1914: Use a context manager for opening files
(SIM115)
1930-1930: Use a context manager for opening files
(SIM115)
1939-1939: Use a context manager for opening files
(SIM115)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tests/test_github_issue3213/Snakefile(1 hunks)tests/test_github_issue3213/Snakefile.newver(1 hunks)tests/tests.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/test_github_issue3213/Snakefile.newver
- tests/test_github_issue3213/Snakefile
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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 `s...
**/*.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 theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
tests/tests.py
🧬 Code Definitions (1)
tests/tests.py (1)
tests/common.py (2)
run(151-494)dpath(32-35)
🪛 Ruff (0.8.2)
tests/tests.py
1914-1914: Use a context manager for opening files
(SIM115)
1930-1930: Use a context manager for opening files
(SIM115)
1939-1939: Use a context manager for opening files
(SIM115)
⏰ Context from checks skipped due to timeout of 90000ms (36)
- GitHub Check: tests (10, macos-latest, py312)
- GitHub Check: tests (10, windows-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py312)
- GitHub Check: tests (10, ubuntu-latest, py311)
- GitHub Check: tests (9, windows-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py312)
- GitHub Check: tests (9, ubuntu-latest, py311)
- GitHub Check: tests (8, windows-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py312)
- GitHub Check: tests (8, ubuntu-latest, py311)
- GitHub Check: tests (7, windows-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py312)
- GitHub Check: tests (7, ubuntu-latest, py311)
- GitHub Check: tests (6, windows-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py312)
- GitHub Check: tests (6, ubuntu-latest, py311)
- GitHub Check: tests (5, windows-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py312)
- GitHub Check: tests (5, ubuntu-latest, py311)
- GitHub Check: tests (4, macos-latest, py312)
- GitHub Check: tests (4, windows-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py312)
- GitHub Check: tests (4, ubuntu-latest, py311)
- GitHub Check: tests (3, macos-latest, py312)
- GitHub Check: tests (3, windows-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py312)
- GitHub Check: tests (3, ubuntu-latest, py311)
- GitHub Check: tests (2, macos-latest, py312)
- GitHub Check: tests (2, windows-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py312)
- GitHub Check: tests (2, ubuntu-latest, py311)
- GitHub Check: tests (1, macos-latest, py312)
- GitHub Check: tests (1, windows-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py312)
- GitHub Check: tests (1, ubuntu-latest, py311)
- GitHub Check: apidocs
|
I didn't hook into the DAG directly but I validate that the change in rules was detected using timestamps + different results. About how to validate that it's actually the intended source lines - I'm not sure. (in the future I believe a more robust approach would be to improve the source tracking in |
|
@johanneskoester friendly ping :) |
|
Hi @johanneskoester, is there anything I could help with to move this PR forward? |
johanneskoester
left a comment
There was a problem hiding this comment.
Fantastic, thanks a lot!
|
Sorry for the delay, there is a huge backlog to catch up with! |
|
Best is always to ping me via discord. |
🤖 I have created a release *beep* *boop* --- ## [9.11.0](v9.10.1...v9.11.0) (2025-09-05) ### Features * add landing page to the report containing custom metadata defined with a YTE yaml template ([#3452](#3452)) ([c754d80](c754d80)) * Issue a warning when unsupported characters are used in wildcard names ([#1587](#1587)) ([fa57355](fa57355)) ### Bug Fixes * avoid checking output files in immediate-submit mode ([#3569](#3569)) ([58c42cf](58c42cf)) * clarify --keep-going flag help text to distinguish runtime vs DAG construction errors ([#3705](#3705)) ([a3a8ef4](a3a8ef4)) * enable docstring assignment in `use rule ... with:` block ([#3710](#3710)) ([2191962](2191962)) * fix missing attribute error in greedy scheduler settings when using touch, dryrun or immediate submit. ([6471004](6471004)) * only trigger script with CODE label ([#3707](#3707)) ([2d01f8c](2d01f8c)) * parser.py incorrectly parsing multiline f-strings ([#3701](#3701)) ([06ece76](06ece76)) * parsing ordinary yaml strings ([#3506](#3506)) ([ddf334e](ddf334e)) * remove temp files when using checkpoints ([#3716](#3716)) ([5ff3e20](5ff3e20)) * Restore python rules changes triggering reruns. (GH: [#3213](#3213)) ([#3485](#3485)) ([2f663be](2f663be)) * unit testing ([#3680](#3680)) ([06ba7e6](06ba7e6)) * use queue_input_wait_time when updating queue input jobs ([#3712](#3712)) ([a945a19](a945a19)) ### Documentation * output files within output directories is an error ([#2848](#2848)) ([#2913](#2913)) ([37272e5](37272e5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
) (snakemake#3485) Trying to fix snakemake#3213 by caching the source code of python rules (using `dis` + `linecache` magic). I would appreciate any help in how to approach writing a test for this. cc @corneliusroemer ### QC <!-- Make sure that you can tick the boxes below. --> * [x] The PR contains a test case for the changes or the changes are already covered by an existing test case. * [x] The documentation (`docs/`) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced rule processing to capture both shell command and Python function definitions when available. - Expanded the internal rule configuration to include additional source code information, supporting improved debugging and documentation. - Introduced a method to retrieve and store source details for rules automatically. - New workflow defined with rules for generating files based on time-stamped content. - **Bug Fixes** - Added tests to validate the behavior of the new rule processing and ensure expected outputs. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
🤖 I have created a release *beep* *boop* --- ## [9.11.0](snakemake/snakemake@v9.10.1...v9.11.0) (2025-09-05) ### Features * add landing page to the report containing custom metadata defined with a YTE yaml template ([snakemake#3452](snakemake#3452)) ([c754d80](snakemake@c754d80)) * Issue a warning when unsupported characters are used in wildcard names ([snakemake#1587](snakemake#1587)) ([fa57355](snakemake@fa57355)) ### Bug Fixes * avoid checking output files in immediate-submit mode ([snakemake#3569](snakemake#3569)) ([58c42cf](snakemake@58c42cf)) * clarify --keep-going flag help text to distinguish runtime vs DAG construction errors ([snakemake#3705](snakemake#3705)) ([a3a8ef4](snakemake@a3a8ef4)) * enable docstring assignment in `use rule ... with:` block ([snakemake#3710](snakemake#3710)) ([2191962](snakemake@2191962)) * fix missing attribute error in greedy scheduler settings when using touch, dryrun or immediate submit. ([6471004](snakemake@6471004)) * only trigger script with CODE label ([snakemake#3707](snakemake#3707)) ([2d01f8c](snakemake@2d01f8c)) * parser.py incorrectly parsing multiline f-strings ([snakemake#3701](snakemake#3701)) ([06ece76](snakemake@06ece76)) * parsing ordinary yaml strings ([snakemake#3506](snakemake#3506)) ([ddf334e](snakemake@ddf334e)) * remove temp files when using checkpoints ([snakemake#3716](snakemake#3716)) ([5ff3e20](snakemake@5ff3e20)) * Restore python rules changes triggering reruns. (GH: [snakemake#3213](snakemake#3213)) ([snakemake#3485](snakemake#3485)) ([2f663be](snakemake@2f663be)) * unit testing ([snakemake#3680](snakemake#3680)) ([06ba7e6](snakemake@06ba7e6)) * use queue_input_wait_time when updating queue input jobs ([snakemake#3712](snakemake#3712)) ([a945a19](snakemake@a945a19)) ### Documentation * output files within output directories is an error ([snakemake#2848](snakemake#2848)) ([snakemake#2913](snakemake#2913)) ([37272e5](snakemake@37272e5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Trying to fix #3213 by caching the source code of python rules (using
dis+linecachemagic).I would appreciate any help in how to approach writing a test for this.
cc @corneliusroemer
QC
docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).Summary by CodeRabbit