hpc-runner 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. hpc_runner-0.1.0/.github/workflows/ci.yml +30 -0
  2. hpc_runner-0.1.0/.github/workflows/publish.yml +47 -0
  3. hpc_runner-0.1.0/.gitignore +66 -0
  4. hpc_runner-0.1.0/CLAUDE.md +65 -0
  5. hpc_runner-0.1.0/PKG-INFO +46 -0
  6. hpc_runner-0.1.0/README.md +3 -0
  7. hpc_runner-0.1.0/SPEC.md +2002 -0
  8. hpc_runner-0.1.0/defaults/config.toml +46 -0
  9. hpc_runner-0.1.0/pyproject.toml +78 -0
  10. hpc_runner-0.1.0/sourceme +31 -0
  11. hpc_runner-0.1.0/src/hpc_runner/__init__.py +57 -0
  12. hpc_runner-0.1.0/src/hpc_runner/_version.py +34 -0
  13. hpc_runner-0.1.0/src/hpc_runner/cli/__init__.py +1 -0
  14. hpc_runner-0.1.0/src/hpc_runner/cli/cancel.py +38 -0
  15. hpc_runner-0.1.0/src/hpc_runner/cli/config.py +109 -0
  16. hpc_runner-0.1.0/src/hpc_runner/cli/main.py +72 -0
  17. hpc_runner-0.1.0/src/hpc_runner/cli/run.py +136 -0
  18. hpc_runner-0.1.0/src/hpc_runner/cli/status.py +65 -0
  19. hpc_runner-0.1.0/src/hpc_runner/core/__init__.py +1 -0
  20. hpc_runner-0.1.0/src/hpc_runner/core/config.py +177 -0
  21. hpc_runner-0.1.0/src/hpc_runner/core/descriptors.py +56 -0
  22. hpc_runner-0.1.0/src/hpc_runner/core/exceptions.py +29 -0
  23. hpc_runner-0.1.0/src/hpc_runner/core/job.py +149 -0
  24. hpc_runner-0.1.0/src/hpc_runner/core/job_array.py +58 -0
  25. hpc_runner-0.1.0/src/hpc_runner/core/resources.py +49 -0
  26. hpc_runner-0.1.0/src/hpc_runner/core/result.py +157 -0
  27. hpc_runner-0.1.0/src/hpc_runner/core/types.py +13 -0
  28. hpc_runner-0.1.0/src/hpc_runner/py.typed +0 -0
  29. hpc_runner-0.1.0/src/hpc_runner/schedulers/__init__.py +60 -0
  30. hpc_runner-0.1.0/src/hpc_runner/schedulers/base.py +76 -0
  31. hpc_runner-0.1.0/src/hpc_runner/schedulers/detection.py +34 -0
  32. hpc_runner-0.1.0/src/hpc_runner/schedulers/local/__init__.py +5 -0
  33. hpc_runner-0.1.0/src/hpc_runner/schedulers/local/scheduler.py +237 -0
  34. hpc_runner-0.1.0/src/hpc_runner/schedulers/local/templates/job.sh.j2 +28 -0
  35. hpc_runner-0.1.0/src/hpc_runner/schedulers/sge/__init__.py +5 -0
  36. hpc_runner-0.1.0/src/hpc_runner/schedulers/sge/args.py +165 -0
  37. hpc_runner-0.1.0/src/hpc_runner/schedulers/sge/parser.py +194 -0
  38. hpc_runner-0.1.0/src/hpc_runner/schedulers/sge/scheduler.py +325 -0
  39. hpc_runner-0.1.0/src/hpc_runner/schedulers/sge/templates/job.sh.j2 +39 -0
  40. hpc_runner-0.1.0/src/hpc_runner/templates/__init__.py +5 -0
  41. hpc_runner-0.1.0/src/hpc_runner/templates/engine.py +55 -0
  42. hpc_runner-0.1.0/src/hpc_runner/workflow/__init__.py +6 -0
  43. hpc_runner-0.1.0/src/hpc_runner/workflow/dependency.py +20 -0
  44. hpc_runner-0.1.0/src/hpc_runner/workflow/pipeline.py +180 -0
  45. hpc_runner-0.1.0/tests/__init__.py +1 -0
  46. hpc_runner-0.1.0/tests/conftest.py +98 -0
  47. hpc_runner-0.1.0/tests/test_cli/__init__.py +1 -0
  48. hpc_runner-0.1.0/tests/test_cli/test_run.py +98 -0
  49. hpc_runner-0.1.0/tests/test_core/__init__.py +1 -0
  50. hpc_runner-0.1.0/tests/test_core/test_config.py +130 -0
  51. hpc_runner-0.1.0/tests/test_core/test_job.py +113 -0
  52. hpc_runner-0.1.0/tests/test_core/test_resources.py +71 -0
  53. hpc_runner-0.1.0/tests/test_schedulers/__init__.py +1 -0
  54. hpc_runner-0.1.0/tests/test_schedulers/test_detection.py +55 -0
  55. hpc_runner-0.1.0/tests/test_schedulers/test_local.py +124 -0
  56. hpc_runner-0.1.0/tests/test_schedulers/test_sge.py +167 -0
  57. hpc_runner-0.1.0/tests/test_workflow/__init__.py +1 -0
  58. hpc_runner-0.1.0/tests/test_workflow/test_pipeline.py +167 -0
@@ -0,0 +1,30 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ['3.10', '3.11', '3.12']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0 # Full history for hatch-vcs
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install dependencies
27
+ run: pip install -e ".[dev]"
28
+
29
+ - name: Run tests
30
+ run: pytest -v
@@ -0,0 +1,47 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ with:
14
+ fetch-depth: 0 # Full history for hatch-vcs
15
+
16
+ - name: Set up Python
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: '3.11'
20
+
21
+ - name: Install build dependencies
22
+ run: pip install build
23
+
24
+ - name: Build package
25
+ run: python -m build
26
+
27
+ - name: Upload dist artifacts
28
+ uses: actions/upload-artifact@v4
29
+ with:
30
+ name: dist
31
+ path: dist/
32
+
33
+ publish:
34
+ needs: build
35
+ runs-on: ubuntu-latest
36
+ environment: pypi
37
+ permissions:
38
+ id-token: write # Required for trusted publishing
39
+ steps:
40
+ - name: Download dist artifacts
41
+ uses: actions/download-artifact@v4
42
+ with:
43
+ name: dist
44
+ path: dist/
45
+
46
+ - name: Publish to PyPI
47
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,66 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ .installed.cfg
25
+ *.egg
26
+
27
+ # Virtual environments
28
+ .venv/
29
+ venv/
30
+ ENV/
31
+ env/
32
+
33
+ # IDE
34
+ .idea/
35
+ .vscode/
36
+ *.swp
37
+ *.swo
38
+ *~
39
+
40
+ # Testing
41
+ .pytest_cache/
42
+ .coverage
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+
47
+ # mypy
48
+ .mypy_cache/
49
+ .dmypy.json
50
+ dmypy.json
51
+
52
+ # Ruff
53
+ .ruff_cache/
54
+
55
+ # Local development
56
+ *.log
57
+ .DS_Store
58
+
59
+ # HPC job outputs (don't commit job logs)
60
+ *.out
61
+ *.err
62
+ *.o[0-9]*
63
+ *.e[0-9]*
64
+
65
+ # Generated version file
66
+ src/hpc_runner/_version.py
@@ -0,0 +1,65 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Build & Development Commands
6
+
7
+ ```bash
8
+ # Setup virtual environment
9
+ source sourceme # Creates .venv with Python 3.11, installs deps
10
+ source sourceme --clean # Clean rebuild of .venv
11
+
12
+ # Run tests
13
+ pytest # All tests
14
+ pytest -v # Verbose
15
+ pytest tests/test_core/ # Specific directory
16
+ pytest -k "test_job" # By name pattern
17
+
18
+ # Type checking and linting
19
+ mypy src/hpc_runner
20
+ ruff check src/hpc_runner
21
+ ruff format src/hpc_runner
22
+
23
+ # CLI usage
24
+ hpc --help
25
+ hpc run --dry-run "echo hello"
26
+ hpc --scheduler sge run --cpu 4 --mem 8G "python script.py"
27
+ ```
28
+
29
+ ## Architecture
30
+
31
+ **Package**: `hpc-runner` (PyPI) / `hpc_runner` (import) / `hpc` (CLI)
32
+
33
+ ### Core Abstractions (`src/hpc_runner/core/`)
34
+
35
+ - **Job** - Central job model with command, resources (cpu/mem/time), modules, dependencies
36
+ - **JobResult/ArrayJobResult** - Returned from submission, provides status polling and output access
37
+ - **JobStatus** - Unified enum: PENDING, RUNNING, COMPLETED, FAILED, CANCELLED, TIMEOUT, UNKNOWN
38
+ - **ResourceSet** - Collection of named resources (gpu, licenses, etc.)
39
+ - **HPCConfig** - TOML-based config with hierarchy: ./hpc-tools.toml > pyproject.toml > git root > ~/.config > package defaults
40
+
41
+ ### Scheduler System (`src/hpc_runner/schedulers/`)
42
+
43
+ - **BaseScheduler** - ABC defining submit(), cancel(), get_status(), generate_script()
44
+ - **SGEScheduler** - Sun Grid Engine (qsub/qstat/qdel). All SGE-specific settings (PE name, resource names) are configurable via `[schedulers.sge]` config section
45
+ - **LocalScheduler** - Runs jobs as local subprocesses (for testing without cluster)
46
+ - **detection.py** - Auto-detects scheduler: HPC_SCHEDULER env > SGE_ROOT > sbatch > PBS > local fallback
47
+ - **Registry** - `get_scheduler(name)` with lazy imports, `register_scheduler()` for custom schedulers
48
+
49
+ ### CLI (`src/hpc_runner/cli/`)
50
+
51
+ Uses `rich-click` for styled output. Commands: `run`, `status`, `cancel`, `config`.
52
+
53
+ ### Workflow (`src/hpc_runner/workflow/`)
54
+
55
+ **Pipeline** - Job dependency graphs with topological sorting. Jobs reference other jobs by name; dependencies are resolved at submit time.
56
+
57
+ ### Templates (`src/hpc_runner/templates/`)
58
+
59
+ Jinja2 templates for job scripts. Each scheduler has its own template in `schedulers/{name}/templates/job.sh.j2`.
60
+
61
+ ## Key Design Decisions
62
+
63
+ - **Merged output by default**: stderr goes to stdout unless `--stderr` specified
64
+ - **Configurable SGE settings**: PE name, memory resource name, time resource name all come from config, not hardcoded
65
+ - **Descriptor pattern**: Scheduler arguments use Python descriptors for type-safe flag/directive generation
@@ -0,0 +1,46 @@
1
+ Metadata-Version: 2.4
2
+ Name: hpc-runner
3
+ Version: 0.1.0
4
+ Summary: Unified HPC job submission across multiple schedulers
5
+ Project-URL: Homepage, https://github.com/shareefj/hpc-tools
6
+ Project-URL: Repository, https://github.com/shareefj/hpc-tools
7
+ Author: Shareef Jalloq
8
+ License-Expression: MIT
9
+ Keywords: cluster,hpc,job-submission,pbs,sge,slurm
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: System :: Clustering
21
+ Classifier: Topic :: System :: Distributed Computing
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: jinja2>=3.0
24
+ Requires-Dist: rich-click>=1.7
25
+ Requires-Dist: tomli>=2.0; python_version < '3.11'
26
+ Provides-Extra: all
27
+ Requires-Dist: build; extra == 'all'
28
+ Requires-Dist: hatch-vcs; extra == 'all'
29
+ Requires-Dist: mypy; extra == 'all'
30
+ Requires-Dist: pytest-cov; extra == 'all'
31
+ Requires-Dist: pytest>=7.0; extra == 'all'
32
+ Requires-Dist: ruff; extra == 'all'
33
+ Requires-Dist: twine; extra == 'all'
34
+ Provides-Extra: dev
35
+ Requires-Dist: build; extra == 'dev'
36
+ Requires-Dist: hatch-vcs; extra == 'dev'
37
+ Requires-Dist: mypy; extra == 'dev'
38
+ Requires-Dist: pytest-cov; extra == 'dev'
39
+ Requires-Dist: pytest>=7.0; extra == 'dev'
40
+ Requires-Dist: ruff; extra == 'dev'
41
+ Requires-Dist: twine; extra == 'dev'
42
+ Description-Content-Type: text/markdown
43
+
44
+ # hpc-tools
45
+
46
+ A collection of tools aimed at abstracting the intricacies of HPC job schedulers from the user. Having writen tools like this in every job I've had, I thought it about time to write one to rule them all. With some help from my mate Claude.
@@ -0,0 +1,3 @@
1
+ # hpc-tools
2
+
3
+ A collection of tools aimed at abstracting the intricacies of HPC job schedulers from the user. Having writen tools like this in every job I've had, I thought it about time to write one to rule them all. With some help from my mate Claude.