-
Notifications
You must be signed in to change notification settings - Fork 38
feat!: proposal for dynamic partition selection #321
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
3bb795f
feat: initial commit of automated partition selection
cademirch 6f475c3
fix: flatten expected yaml structure; remove partition description
cademirch f8d342e
fix: update cli arg name and help
cademirch f5511ff
docs: update docs and help
cademirch 01a94c6
chore: linting; change automatic to dynamic partition selection
cademirch bb8c471
chore: format tests
cademirch daa202c
fix: merge conflicts
cmeesters 0d95537
fix: merge conflicts
cmeesters 25c043b
fix: syntax error after merge conflict
cmeesters 7a6e582
fix: left over line from merge conflict
cmeesters 4726ce6
fix: missing import
cmeesters 3febf2c
fix: removed doubled import statement
cmeesters 65396ac
fix: made an error when solving merge conflict - mock job for partiti…
cmeesters e652e69
fix: formatting
cmeesters 982dfee
feat: allowing env variable to define the partition profile
cmeesters da1b009
feat: enabling environment variable for partition configuration file
cmeesters 65f1007
feat: added 'threads' hardening selection score
cmeesters 9d01b96
feat: support cluster selection in multi-cluster env
cmeesters 38d7daf
fix: sound thread checking
cmeesters 53ed396
fix: removed print statement (debugg leftover)
cmeesters 2ee9f09
docs: added docs for this PR
cmeesters 744b8b3
tests: added tests for this PR
cmeesters be655d1
fix: formatting
cmeesters dd40f24
fix: formatting
cmeesters fd2336e
fix: relative import
cmeesters adb276c
feat: first step to refactoring, trying Snakemake's dpath
cmeesters f96cdc5
fix: added missing whitespace
cmeesters 64e99b9
fix: reordered
cmeesters 5b53def
fix: no negative value for cpus_per_task
cmeesters 0781a2b
fix: mock logger level
cmeesters f8538ed
fix: threads check abbreviated
cmeesters 8aeb8c5
fix: import order
cmeesters db00ab1
fix: formatting, gnarf!
cmeesters eb9933d
fix: attempt to run modularized tests in one go without additional im…
cmeesters 7c662bb
fix: mock warnings
cmeesters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| __email__ = "[email protected]" | ||
| __license__ = "MIT" | ||
|
|
||
| import atexit | ||
| import csv | ||
| from io import StringIO | ||
| import os | ||
|
|
@@ -35,6 +36,7 @@ | |
| ) | ||
| from .efficiency_report import create_efficiency_report | ||
| from .submit_string import get_submit_command | ||
| from .partitions import read_partition_file, get_best_partition | ||
| from .validation import validate_slurm_extra | ||
|
|
||
|
|
||
|
|
@@ -113,6 +115,15 @@ class ExecutorSettings(ExecutorSettingsBase): | |
| "required": False, | ||
| }, | ||
| ) | ||
| partition_config: Optional[Path] = field( | ||
| default=None, | ||
| metadata={ | ||
| "help": "Path to YAML file defining partition limits for dynamic " | ||
| "partition selection. When provided, jobs will be dynamically " | ||
| "assigned to the best-fitting partition based on " | ||
| "See documentation for complete list of available limits.", | ||
| }, | ||
| ) | ||
| efficiency_report: bool = field( | ||
| default=False, | ||
| metadata={ | ||
|
|
@@ -201,6 +212,12 @@ def __post_init__(self, test_mode: bool = False): | |
| if self.workflow.executor_settings.logdir | ||
| else Path(".snakemake/slurm_logs").resolve() | ||
| ) | ||
| self._partitions = ( | ||
| read_partition_file(self.workflow.executor_settings.partition_config) | ||
| if self.workflow.executor_settings.partition_config | ||
| else None | ||
| ) | ||
| atexit.register(self.clean_old_logs) | ||
|
|
||
| def shutdown(self) -> None: | ||
| """ | ||
|
|
@@ -305,6 +322,8 @@ def run_job(self, job: JobExecutorInterface): | |
| if job.resources.get("slurm_extra"): | ||
| self.check_slurm_extra(job) | ||
|
|
||
| # NOTE removed partition from below, such that partition | ||
| # selection can benefit from resource checking as the call is built up. | ||
| job_params = { | ||
| "run_uuid": self.run_uuid, | ||
| "slurm_logfile": slurm_logfile, | ||
|
|
@@ -698,9 +717,13 @@ def get_partition_arg(self, job: JobExecutorInterface): | |
| returns a default partition, if applicable | ||
| else raises an error - implicetly. | ||
| """ | ||
| partition = None | ||
| if job.resources.get("slurm_partition"): | ||
| partition = job.resources.slurm_partition | ||
| else: | ||
| elif self._partitions: | ||
| partition = get_best_partition(self._partitions, job, self.logger) | ||
| # we didnt get a partition yet so try fallback. | ||
| if not partition: | ||
| if self._fallback_partition is None: | ||
| self._fallback_partition = self.get_default_partition(job) | ||
| partition = self._fallback_partition | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.