-
Notifications
You must be signed in to change notification settings - Fork 1
Add SLURM job submission script generation #15
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
- Implement SlurmJob class with fluent API for SLURM configuration - Support for job name, time, cores, memory, partition, account, queue, and module loading - Integrate with OrcaBuilder and QchemBuilder via get_slurm_directives() and get_launch_command() - Add 52 comprehensive tests covering unit, contract, integration, and regression testing - Tests validate sbatch directives, program-specific parallelism (OpenMP/MPI), module loading - Semantic regression tests ensure functional correctness without brittle string matching - Update README with SLURM usage examples for ORCA and Q-Chem - Update LLM documentation with SLURM workflow examples - Maintain zero external dependencies and full type annotations
Pytest Coverage Report 🧪 |
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.
8 files reviewed, 2 comments
src/calcflow/slurm.py
Outdated
|
|
||
| # add program-specific directives for parallelism | ||
| lines.extend(program_directives) | ||
| lines.append("\n") |
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.
style: appending "\n" to the list will create an empty line in the output, but joining with "\n".join() treats this as a literal string "\n" which becomes \n in the output (double newline). consider appending "" instead for clarity
| lines.append("\n") | |
| lines.append("") |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/calcflow/slurm.py
Line: 93:93
Comment:
**style:** appending `"\n"` to the list will create an empty line in the output, but joining with `"\n".join()` treats this as a literal string `"\n"` which becomes `\n` in the output (double newline). consider appending `""` instead for clarity
```suggestion
lines.append("")
```
How can I resolve this? If you propose a fix, please make it concise.
src/calcflow/slurm.py
Outdated
| if self.modules: | ||
| for module in self.modules: | ||
| lines.append(f"module load {module}") | ||
| lines.append("\n") |
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.
style: same as line 93 - appending "\n" creates double newline when joined. use "" for clarity
| lines.append("\n") | |
| lines.append("") |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/calcflow/slurm.py
Line: 98:98
Comment:
**style:** same as line 93 - appending `"\n"` creates double newline when joined. use `""` for clarity
```suggestion
lines.append("")
```
How can I resolve this? If you propose a fix, please make it concise.
Pytest Coverage Report 🧪 |
TL;DR
Added SLURM job submission script generation capabilities to CalcFlow.
What changed?
SlurmJobclass incalcflow.slurmmodule for generating SLURM submission scripts.gitignoreentry forh2o_calc_spec.jsonHow to test?
Why make this change?
This change enhances CalcFlow's usability in high-performance computing environments by providing automated generation of SLURM job submission scripts. Users can now seamlessly move from calculation definition to cluster submission without manually writing SLURM scripts, ensuring proper resource allocation and program-specific parallelism directives are correctly configured.
Greptile Overview
Updated On: 2025-11-06 15:33:18 UTC
Greptile Summary
Adds SLURM job submission script generation capability to CalcFlow, enabling users to generate cluster submission scripts for ORCA and Q-Chem calculations.
Key changes:
calcflow.slurm.SlurmJobclass with fluent API for building SLURM scriptsOrcaBuilderandQchemBuilderwithget_slurm_directives()andget_launch_command()methodsImplementation approach:
The design follows CalcFlow's philosophy of separation of concerns -
SlurmJobhandles HPC scheduler configuration, while program builders provide quantum chemistry program-specific directives. This allows the SLURM module to remain program-agnostic while still generating correct parallelism flags.Confidence Score: 5/5
src/calcflow/slurm.pylines 93 and 98Important Files Changed
File Analysis
get_slurm_directives()andget_launch_command()methods for ORCA integrationSequence Diagram
sequenceDiagram participant User participant SlurmJob participant CalculationInput participant BUILDERS participant OrcaBuilder participant QchemBuilder User->>SlurmJob: create(job_name, time, n_cores, ...) User->>SlurmJob: add_modules(["orca/5.0"]) User->>SlurmJob: export(calc, program="orca", input_filename, output_filename) SlurmJob->>BUILDERS: get builder for program BUILDERS-->>SlurmJob: OrcaBuilder instance SlurmJob->>OrcaBuilder: get_slurm_directives(calculation) OrcaBuilder-->>SlurmJob: ["#SBATCH --ntasks=N", "#SBATCH --nodes=1"] SlurmJob->>OrcaBuilder: get_launch_command(calculation, input_fname, output_fname) OrcaBuilder-->>SlurmJob: "$(which orca) input.inp > output.out" SlurmJob->>SlurmJob: build(directives, launch_command) Note over SlurmJob: Constructs SLURM script with:<br/>- shebang<br/>- SBATCH directives<br/>- module loads<br/>- launch command SlurmJob-->>User: complete SLURM script string