-
Notifications
You must be signed in to change notification settings - Fork 15
feat: submit method upgrade snakemake #1604
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 all commits
Commits
Show all changes
320 commits
Select commit
Hold shift + click to select a range
d49293b
Revert "change to equal"
mathiasbio c421297
remove attempt
mathiasbio 7a1d198
remove threads
mathiasbio 5e26b08
test
mathiasbio 49f89d5
change yaml format
mathiasbio 98358b4
Merge branch 'change_submit_method' of github.com:Clinical-Genomics/B…
mathiasbio 6054eca
clean up
mathiasbio 5fe92e3
Merge branch 'change_submit_method' of github.com:Clinical-Genomics/B…
mathiasbio 03e2286
reformat
mathiasbio 4058fc7
reformat
mathiasbio 4b664b3
revert to yaml structure
mathiasbio 463751b
test
mathiasbio 308b8cd
add slurm options
mathiasbio 962e974
tsst
mathiasbio e92d689
testing
mathiasbio b5105ca
account
mathiasbio 5083bf1
test
mathiasbio 84f739c
test write new config yaml
mathiasbio 14e8e88
fix
mathiasbio cbb8573
fix
mathiasbio 3eb2813
fix quotes
mathiasbio 8114baf
fix
mathiasbio 2fe65d3
revert
mathiasbio 024042f
Revert "Merge branch 'change_submit_method' of github.com:Clinical-Ge…
mathiasbio 08146b7
Merge branch 'change_submit_method' of github.com:Clinical-Genomics/B…
mathiasbio 4d1ac80
revert snakemake
mathiasbio 90e7890
REVERT DAG
mathiasbio 4ee48fd
fix
mathiasbio 6e94598
restore config
mathiasbio 234cc80
add slurm yaml
mathiasbio 975ff62
worth a try
mathiasbio 198dbb0
move mem to dynamic resource
mathiasbio 05c48ef
fix
mathiasbio e17a41f
increase mem
mathiasbio 19f9b1b
refactor
mathiasbio a66485b
mem
mathiasbio 2f87f71
increase mem
mathiasbio d3782b0
mem wgs align
mathiasbio d9a2d68
add init
mathiasbio 8196874
clean up
mathiasbio 8f6ad56
remove cluster env
mathiasbio 153b688
refactor code
mathiasbio 8fd0823
Merge branch 'develop' of github.com:Clinical-Genomics/BALSAMIC into …
mathiasbio 74a75e4
Merge branch 'develop' into change_submit_method
mathiasbio a756d2f
mem fix
mathiasbio 799d057
change mem according to benchmark files
mathiasbio dbd6e37
add r
mathiasbio 53bafbd
update threads
mathiasbio 42b7d74
test adding mail func
mathiasbio baaa087
test
mathiasbio 7807e94
remove email functionality
mathiasbio 4dc3a66
clean up
mathiasbio 81fca1b
clean
mathiasbio 8a33122
fix
mathiasbio 4fb4795
clean up
mathiasbio 17c75a1
fix pytests
mathiasbio 82c3e26
fix pytests
mathiasbio e9a42ac
black
mathiasbio 0a12ec2
Merge branch 'develop' of github.com:Clinical-Genomics/BALSAMIC into …
mathiasbio 8931641
Merge branch 'develop' into change_submit_method
mathiasbio 89bd073
Merge develop and changelog
mathiasbio 16f63ae
add logger test
mathiasbio 9bf65e0
add sbatch pytest
mathiasbio ea0bf39
test
mathiasbio b3812b9
cap mem
mathiasbio a2529bf
fix
mathiasbio e9626a1
restore resources
mathiasbio 978599d
adjust mem and time
mathiasbio 108add1
add partition core
mathiasbio ec8ae7f
remove test
mathiasbio 2c6d18c
black
mathiasbio ed36c56
test
mathiasbio a8fb39f
test
mathiasbio d882d02
nothing
mathiasbio 1615e9f
black
mathiasbio 7dc87e1
fix
mathiasbio 0738dd7
add logs
mathiasbio c1b76c0
black
mathiasbio 846cf7d
remove test
mathiasbio 0eef24d
black
mathiasbio c003549
add analysis status check to snakemake master job
mathiasbio b0199d5
fix variable
mathiasbio cea15bc
add success status check
mathiasbio 80be77b
add resources
mathiasbio 37267d3
change resources
mathiasbio 0c9aeea
fix
mathiasbio aa722c0
add job status check
mathiasbio cf4bd51
black
mathiasbio 1097cba
add to init
mathiasbio 7dbb730
add cancel check state
mathiasbio 997ad63
fix test
mathiasbio 6b5b9ea
refactor code
mathiasbio aa63863
black
mathiasbio 2d3e34b
remove retries
mathiasbio 011a6a0
remove shell true
mathiasbio c03d9a7
black
mathiasbio ad6aa04
add description
mathiasbio 8b64154
fix pytest
mathiasbio 2b0a65d
fix pytests
mathiasbio 4a77c5b
add qc error to status
mathiasbio edb3a83
fix
mathiasbio 3ffca6d
append write statusfile
mathiasbio 19f84d6
restore
mathiasbio ec403e8
test new options
mathiasbio 0e4e6bd
mem
mathiasbio ba66a56
testing logs
mathiasbio bd0ed50
fix
mathiasbio 16b4378
add cluster status script
mathiasbio b9ec70c
remove
mathiasbio 9f77377
fix
mathiasbio 947ffbd
fix
mathiasbio a8d1b59
fix
mathiasbio 8fc8743
update state check
mathiasbio 91ddb69
mem
mathiasbio d15050c
fix permission after install
mathiasbio 658335a
fix
mathiasbio 95df709
fix bug
mathiasbio 00fb129
fix pytest
mathiasbio 94f8a86
increase mem
mathiasbio b897400
increase mem
mathiasbio 70ec4ab
fix codefactor issues
mathiasbio 63e0ff4
increase mem
mathiasbio b51a6b8
increase mem
mathiasbio 36c6969
add 1 retry
mathiasbio 6403b4d
fix delly
mathiasbio 2dc57b2
clean up
mathiasbio bff6a7f
Merge branch 'develop' of github.com:Clinical-Genomics/BALSAMIC into …
mathiasbio f7b4ec2
clean up merge conflict and add to changelog
mathiasbio 9620b21
add logging pytest
mathiasbio ac63e42
increase mem
mathiasbio a912b96
increase mem
mathiasbio e2f3c23
increase time and mem
mathiasbio 0e00b77
add dynamic mem to dedup
mathiasbio 215c821
increase mem
mathiasbio 8a28ca8
Merge branch 'develop' of github.com:Clinical-Genomics/BALSAMIC into …
mathiasbio 4a9fd1c
fix merge conflict
mathiasbio a8abdee
update script
mathiasbio be5d3ab
increase mem
mathiasbio f91e1ab
increase mem
mathiasbio b951a37
increase mem
mathiasbio f55e7a0
mem
mathiasbio e4f1244
increase mem
mathiasbio 4027da2
increase mem
mathiasbio 4f24c56
decrease mem
mathiasbio b241795
mem
mathiasbio 51427d5
lower slurm stress
mathiasbio 4ee9975
upgrade to latest snakemake
mathiasbio 4e5b870
bump packaging
mathiasbio eb2956a
bump yte
mathiasbio 7e9e7cd
decrease snakemake v
mathiasbio 4f67ed6
test executor
mathiasbio cc8c206
increase snakemake v to 9
mathiasbio 68ef42d
increase numpy
mathiasbio 5ac1f24
bump pandas
mathiasbio 6b751bd
move out threads from config
mathiasbio 827424c
use only cluster profile
mathiasbio 6f8ed14
refactor threads
mathiasbio c2688f5
Merge branch 'submit_method_upgrade_snakemake' of github.com:Clinical…
mathiasbio abc357e
move args
mathiasbio 0cd8e86
test
mathiasbio 5f8373b
test fix
mathiasbio 1ee7f72
update dag function
mathiasbio 8598c8c
fix
mathiasbio 9c2ebdd
keep logs
mathiasbio a9abaa7
refactor mem
mathiasbio 2d71fdd
refactor mem
mathiasbio 8b6ad13
Merge branch 'submit_method_upgrade_snakemake' of github.com:Clinical…
mathiasbio 17bfb83
rulename
mathiasbio 4826ee8
fix
mathiasbio 98f60f3
try fix
mathiasbio 20dd678
revert mem
mathiasbio 10da0ef
attempt fix
mathiasbio 7fe208d
Merge branch 'submit_method_upgrade_snakemake' of github.com:Clinical…
mathiasbio 5566a07
log testing
mathiasbio 53e9abb
fix
mathiasbio ecc4564
add partition argument
mathiasbio 1abd86c
fix
mathiasbio 60d9ad2
fix
mathiasbio 894bf95
fix write script
mathiasbio cd5037f
fix
mathiasbio 5257b46
fix
mathiasbio 64971c0
update jobstatus csript
mathiasbio 0e63c13
append
mathiasbio 644fe4d
update status check
mathiasbio ba60ef8
remove restart times
mathiasbio c063eb1
fix
mathiasbio a64ca11
refactor
mathiasbio 2e9fc89
black
mathiasbio d901872
remove backup
mathiasbio c7e0a97
black
mathiasbio 1040d7d
cleaning up
mathiasbio e394801
fix pytests
mathiasbio 40135f4
fix pytests
mathiasbio 6744fcc
fix pytests
mathiasbio d3124b5
git add executor installation
mathiasbio 583b77b
add analysis status content to stderr
mathiasbio 92d6fe9
clean up profile
mathiasbio 48fec3d
fix pytest
mathiasbio 60ab56b
add restart times
mathiasbio 4d5a3ec
refactor
mathiasbio 04f772b
merge conflict
mathiasbio a094ff3
fix
mathiasbio 68064b2
fix
mathiasbio 1d4bed3
refactor
mathiasbio fe04e2b
add docstring
mathiasbio 5d14c27
fix init
mathiasbio db6510e
update env and pytest
mathiasbio 840739a
test
mathiasbio d66b724
revert
mathiasbio b570b40
test
mathiasbio 18e9cf2
test
mathiasbio 31f5d52
add pydantic
mathiasbio f6ea34f
test
mathiasbio b8f4664
test
mathiasbio 39321bf
fix pytests
mathiasbio 802f766
fixing code after snakemake update
mathiasbio caa6315
black
mathiasbio 6a6aaaf
Not working
mathiasbio 54aa720
update
mathiasbio 14e6a6f
test
mathiasbio 790cd4d
fix
mathiasbio 88ba7d4
black
mathiasbio 561413b
fix
mathiasbio c751a3e
refactor
mathiasbio 00e5d65
change
mathiasbio 8126c61
test
mathiasbio 9162584
refactor
mathiasbio 2bca239
fix
mathiasbio a7b2bfd
fix
mathiasbio 2abf7e3
remove raw
mathiasbio 13c632b
fix typehints
mathiasbio ee9c855
fix
mathiasbio aaaa98e
test
mathiasbio db322b6
fix
mathiasbio cda98f5
fix pytest
mathiasbio 6ed7aa5
remove unused function
mathiasbio 19b99b5
return shell true
mathiasbio 3104561
black
mathiasbio c0e8be7
changelog
mathiasbio 4aebdce
remove import
mathiasbio 520cbab
update install inst
mathiasbio 4b0d3fe
add pytests
mathiasbio 4b91b19
clean up
mathiasbio 5f3e094
test report
mathiasbio ff44bfb
add unknown status
mathiasbio 51c33cf
refactor
mathiasbio 6f934b0
fix
mathiasbio 2636666
add max mem
mathiasbio 7650575
250gb max
mathiasbio fb55922
fix
mathiasbio 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
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| #!/usr/bin/env python3 | ||
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| import re | ||
| import subprocess | ||
| from pathlib import Path | ||
| from typing import Dict, List, Tuple, Optional | ||
| from datetime import datetime | ||
| import click | ||
|
|
||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def find_job_logs(log_root: Path) -> Dict[str, Path]: | ||
| """ | ||
| Recursively find *.log files whose basename is a numeric jobid. | ||
| Returns {jobid -> log_path}. | ||
| """ | ||
| job_logs: Dict[str, Path] = {} | ||
| for p in log_root.rglob("*.log"): | ||
| if p.stem.isdigit(): # e.g. "9727982.log" -> "9727982" | ||
| job_logs[p.stem] = p | ||
| else: | ||
| LOG.debug(f"Skipping non-job log file: {p}") | ||
| LOG.info(f"Discovered {len(job_logs)} job logs under {log_root}") | ||
| return job_logs | ||
|
|
||
|
|
||
| def get_job_state(jobid: str) -> Optional[str]: | ||
| """ | ||
| Return raw output of `scontrol show job JOBID`, or None if the query fails. | ||
| """ | ||
| try: | ||
| LOG.debug(f"Running show job scontrol {jobid}") | ||
| result = subprocess.run( | ||
| ["scontrol", "show", "job", jobid], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| ) | ||
| return result.stdout | ||
| except FileNotFoundError: | ||
| LOG.error("scontrol executable not found: scontrol") | ||
| return None | ||
| except subprocess.CalledProcessError as e: | ||
| LOG.warning(f"Could not check job {jobid} (may not exist). rc={e.returncode}") | ||
| LOG.debug(f"scontrol stderr for {jobid} {e.stderr}") | ||
| return None | ||
|
|
||
|
|
||
| def parse_state(scontrol_output: str) -> Optional[str]: | ||
| """ | ||
| Extract JobState from scontrol text, e.g. 'JobState=FAILED'. | ||
| Returns the state string (e.g. 'FAILED') or None if not found. | ||
| """ | ||
| m = re.search(r"JobState=(\S+)", scontrol_output) | ||
| state = m.group(1) if m else None | ||
| if state is None: | ||
| LOG.debug("JobState not found in scontrol output") | ||
| return state | ||
|
|
||
|
|
||
| def write_results( | ||
| output_file: Path, | ||
| failed: List[Tuple[str, Path]], | ||
| cancelled: List[Tuple[str, Path]], | ||
| unknown: List[str], | ||
| ) -> None: | ||
| """ | ||
| Append job results to output_file. | ||
| Each run is prefixed with a timestamp header. | ||
| """ | ||
| output_file.parent.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||
|
|
||
| with output_file.open("a") as out_f: | ||
| out_f.write(f"=== Job status check at {timestamp} ===\n") | ||
|
|
||
| if failed: | ||
| out_f.write("Failed jobs:\n") | ||
| for jobid, log_path in failed: | ||
| out_f.write(f"{jobid}\t{log_path}\n") | ||
| out_f.write("\n") | ||
|
|
||
| if cancelled: | ||
| out_f.write("Cancelled jobs:\n") | ||
| for jobid, log_path in cancelled: | ||
| out_f.write(f"{jobid}\t{log_path}\n") | ||
| out_f.write("\n") | ||
|
|
||
| if unknown: | ||
| out_f.write("Unknown status jobs:\n") | ||
| for jobid in unknown: | ||
| out_f.write(f"{jobid}\tNA\n") | ||
| out_f.write("\n") | ||
|
|
||
| if not failed and not cancelled: | ||
| out_f.write("SUCCESSFUL\n\n") | ||
|
|
||
| LOG.info( | ||
| f"Appended results to {output_file} (failed={len(failed)}, cancelled={len(cancelled)} unknown={len(unknown)})" | ||
| ) | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.argument( | ||
| "log_dir", type=click.Path(exists=True, file_okay=False, path_type=Path) | ||
| ) | ||
| @click.option( | ||
| "--output", | ||
| "-o", | ||
| required=True, | ||
| type=click.Path(writable=True, path_type=Path), | ||
| help="Path to output file for results (FAILED/CANCELLED or SUCCESS).", | ||
| ) | ||
| @click.option( | ||
| "--log-level", | ||
| default="INFO", | ||
| show_default=True, | ||
| type=click.Choice( | ||
| ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"], case_sensitive=False | ||
| ), | ||
| help="Logging verbosity.", | ||
| ) | ||
| def check_failed_jobs(log_dir: Path, output: Path, log_level: str) -> None: | ||
| """ | ||
| Recursively scan LOG_DIR for SLURM *.log files (stdout+stderr combined), | ||
| extract job IDs from filenames, and check their states via `scontrol show job JOBID`. | ||
| """ | ||
| logging.basicConfig( | ||
| level=getattr(logging, log_level.upper(), logging.INFO), | ||
| format="%(asctime)s %(levelname)s %(name)s: %(message)s", | ||
| ) | ||
|
|
||
| LOG.info("Scanning logs under: %s", log_dir) | ||
| job_logs = find_job_logs(log_dir) | ||
|
|
||
| failed: List[Tuple[str, Path]] = [] | ||
| cancelled: List[Tuple[str, Path]] = [] | ||
| unknown: List[str] = [] | ||
|
|
||
| if not job_logs: | ||
| LOG.warning("No job logs found (no files matching '*.log')") | ||
| return | ||
|
|
||
| for jobid in sorted(job_logs.keys(), key=int): | ||
| out_text = get_job_state(jobid) | ||
| if not out_text: | ||
| # Can't classify without job info; skip but note it. | ||
| LOG.warning( | ||
| f"Missing scontrol output for job {jobid} -- setting status UNKNOWN" | ||
| ) | ||
| unknown.append(jobid) | ||
| continue | ||
|
|
||
| state = parse_state(out_text) | ||
| if state == "FAILED": | ||
| failed.append((jobid, job_logs[jobid])) | ||
| elif state == "CANCELLED": | ||
| cancelled.append((jobid, job_logs[jobid])) | ||
| else: | ||
| LOG.debug(f"Job {jobid} state is {state}") | ||
|
|
||
| write_results(output, failed, cancelled, unknown) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| check_failed_jobs() | ||
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
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.