-
Notifications
You must be signed in to change notification settings - Fork 2
fix: scheduler test set() #4
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 a new DummyJob to the test DAG, makes it a dependency of an existing job, includes it in the scheduler candidate set for the second selection, and adjusts test assertions (one remains a single-item check; another changed from list to set equality). Minor assertion formatting tweaks only. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
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 (1)
src/snakemake_interface_scheduler_plugins/tests.py (1)
131-153: Consider converting results to sets in tests instead of changing the return type.If modifying the scheduler interface's return type is not feasible (e.g., due to backward compatibility concerns), consider converting the results to sets only in the assertions:
- assert scheduled == set([]), ( + assert set(scheduled) == set(), ( "Scheduler should not select jobs exceeding available resources" )This approach:
- Maintains backward compatibility if existing code expects lists
- Achieves order-independent comparisons
- Requires changes only in tests, not in the interface
However, if changing the interface to return sets is the intended design, ensure that:
- The base class or interface definition is updated with the correct return type annotation
- All implementations are updated to return sets
- All callers are updated to handle sets instead of lists
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/snakemake_interface_scheduler_plugins/tests.py(3 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 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.
Files:
src/snakemake_interface_scheduler_plugins/tests.py
🪛 GitHub Actions: CI
src/snakemake_interface_scheduler_plugins/tests.py
[error] 131-131: AssertionError: Scheduler should not select jobs exceeding available resources
🔇 Additional comments (1)
src/snakemake_interface_scheduler_plugins/tests.py (1)
141-141: Ensure the scheduler implementation returns sets.These assertions will also fail if
select_jobsreturns a list instead of a set. While changing to sets is appropriate for order-independent comparisons (as mentioned in the PR description), the actualselect_jobsmethod implementation must also be updated to return asetinstead of alist.If the implementation already returns a set, then the type annotations and return statements throughout the codebase should be verified for consistency.
Verify that all scheduler implementations return sets:
Also applies to: 151-151
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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/snakemake_interface_scheduler_plugins/base.py (1)
48-71: Update docstring to reflect the return type change.Line 70 of the docstring states "Otherwise, return the sequence of selected jobs," but the method now returns a set, not a sequence.
Apply this diff to fix the documentation:
Return None to indicate an error in the selection process that shall lead to a fallback to the Snakemake's internal greedy scheduler. - Otherwise, return the sequence of selected jobs. + Otherwise, return the set of selected jobs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/snakemake_interface_scheduler_plugins/base.py(2 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 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.
Files:
src/snakemake_interface_scheduler_plugins/base.py
🧬 Code graph analysis (1)
src/snakemake_interface_scheduler_plugins/base.py (1)
src/snakemake_interface_scheduler_plugins/interfaces/jobs.py (1)
JobSchedulerInterface(7-18)
🔇 Additional comments (1)
src/snakemake_interface_scheduler_plugins/base.py (1)
7-7: LGTM!The addition of
Setto the imports is necessary to support the return type change in theselect_jobsmethod.
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: 0
🧹 Nitpick comments (3)
src/snakemake_interface_scheduler_plugins/tests.py (3)
131-133: Fix addresses the pipeline failure correctly.Converting
scheduledto a set before comparison resolves the type mismatch and enables order-independent assertions. This approach is flexible—it works whetherselect_jobsreturns a list, tuple, or set.Minor: prefer
set()overset([])for empty sets—it's more idiomatic and avoids creating an intermediate list:- assert set(scheduled) == set([]), ( + assert set(scheduled) == set(), ( "Scheduler should not select jobs exceeding available resources" )
141-143: Order-independent comparison implemented correctly.The set conversion ensures the assertion passes regardless of job ordering in the returned collection.
Consider simplifying the right-hand side for clarity:
- assert set(scheduled) == set([dag._jobs[0]]), ( + assert set(scheduled) == {dag._jobs[0]}, ( "Scheduler did not select the expected job" )
153-155: Multiple job selection validated correctly with order independence.The set conversion properly handles the case where both jobs should be selected, regardless of their order in the result.
For consistency with the other assertions, consider using set literal syntax:
- assert set(scheduled) == set([dag._jobs[1], dag._jobs[2]]), ( + assert set(scheduled) == {dag._jobs[1], dag._jobs[2]}, ( "Scheduler did not select the expected jobs" )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/snakemake_interface_scheduler_plugins/tests.py(3 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 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.
Files:
src/snakemake_interface_scheduler_plugins/tests.py
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)
src/snakemake_interface_scheduler_plugins/tests.py (2)
136-138: Apply set comparison consistently per PR objective.The PR objective is to use
set()for test comparisons to handle different job ordering. While this assertion compares against an empty result (where ordering doesn't matter), for consistency with the PR objective and line 158's approach, consider using set comparison here as well.Apply this diff:
- assert scheduled == [], ( + assert set(scheduled) == set(), ( "Scheduler should not select jobs exceeding available resources" )Note: This also addresses the type mismatch mentioned in the previous review if
select_jobsreturns aSequencetype, since[] != set([])in Python.
146-148: Apply set comparison consistently per PR objective.The PR objective is to use
set()for test comparisons to handle different job ordering. While there's only one job here, applying set comparison consistently aligns with the PR's purpose and matches the approach used at line 158.Apply this diff:
- assert scheduled == [dag._jobs[0]], ( + assert set(scheduled) == {dag._jobs[0]}, ( "Scheduler did not select the expected job" )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/snakemake_interface_scheduler_plugins/tests.py(2 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 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.
Files:
src/snakemake_interface_scheduler_plugins/tests.py
🧬 Code graph analysis (1)
src/snakemake_interface_scheduler_plugins/tests.py (2)
src/snakemake_interface_scheduler_plugins/interfaces/jobs.py (3)
input(24-26)output(30-32)SingleJobSchedulerInterface(21-49)src/snakemake_interface_scheduler_plugins/base.py (1)
select_jobs(41-72)
🪛 Ruff (0.14.0)
src/snakemake_interface_scheduler_plugins/tests.py
74-78: Positional argument cannot follow keyword argument
(invalid-syntax)
🔇 Additional comments (1)
src/snakemake_interface_scheduler_plugins/tests.py (1)
152-160: LGTM: Set comparison correctly applied and test logic is sound.The set comparison at line 158 correctly implements the PR objective. The test appropriately validates that the scheduler excludes
dag._jobs[3](which requires 10024 MB but only 10000 MB is available) while selecting jobs 1 and 2 that fit within the resource constraints.
set()on tests, otherwiseassertwill fail if order of jobs is different. Or the scheduler could also return aset(), but not sure if it breaks backwards compatibility.release-pleasetokenSummary by CodeRabbit
Tests
Chores