runhpc 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.
runhpc-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,305 @@
1
+ Metadata-Version: 2.4
2
+ Name: runhpc
3
+ Version: 0.1.0
4
+ Summary: Python utilities for configuring, diagnosing, and monitoring HPC runs, with HyperQueue job execution on Slurm.
5
+ Author: zy_peng
6
+ Project-URL: Repository, https://github.com/ccbry/runhpc
7
+ Project-URL: Issues, https://github.com/ccbry/runhpc/issues
8
+ Keywords: hpc,slurm,hyperqueue,job scheduling,diagnostics
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Topic :: Scientific/Engineering
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: python-dotenv>=1.2.4
18
+ Requires-Dist: tomli-w>=1.2.0
19
+ Provides-Extra: hq
20
+ Requires-Dist: hyperqueue==0.27.0; (sys_platform == "linux" and platform_machine == "x86_64") and extra == "hq"
21
+ Requires-Dist: runhpc-hq==0.27.0; (sys_platform == "linux" and platform_machine == "x86_64") and extra == "hq"
22
+
23
+ # runhpc
24
+
25
+ Read TOML configuration sections into registered dataclasses:
26
+
27
+ ```python
28
+ from dataclasses import dataclass
29
+
30
+ from runhpc.config import ConfigReader, read_config
31
+
32
+
33
+ @dataclass
34
+ class TrainingConfig:
35
+ epochs: int
36
+ learning_rate: float = 0.001
37
+
38
+
39
+ configs = read_config(
40
+ {"training": TrainingConfig},
41
+ "config.toml",
42
+ write_config=True,
43
+ run_result_directory="runs/example",
44
+ )
45
+ training = configs["training"]
46
+
47
+ # Optional registration wrapper; reading uses the same public function.
48
+ reader = ConfigReader()
49
+ reader.register_class(TrainingConfig, section_name="training")
50
+ # Decorator form: @reader.register_name("training"), above @dataclass.
51
+ configs = reader.read("config.toml")
52
+ ```
53
+
54
+ Example `config.toml`:
55
+
56
+ ```toml
57
+ [training]
58
+ epochs = 100
59
+ ```
60
+
61
+ Missing fields use dataclass defaults or default factories and emit a warning:
62
+ `learning_rate is not presented in training, using default value: 0.001`.
63
+ An absent registered section uses the same field rules. Missing required fields,
64
+ unknown sections or fields, and duplicate registration names raise errors.
65
+ Fields with `init=False` are left to the dataclass and cannot appear in the input.
66
+
67
+ Supported annotations are `str`, `bool`, `int`, `float`, `datetime.date`,
68
+ `datetime.time`, `datetime.datetime`, nested dataclasses, typed lists,
69
+ string-keyed typed dictionaries, unions (including `Optional`), and scalar
70
+ `Literal` values. Types are enforced without conversions: an integer cannot
71
+ stand in for a float, and a boolean cannot stand in for an integer. Unsupported
72
+ annotations raise errors. Unions use the first matching declared branch, without
73
+ executing constructors for rejected branches.
74
+ Resolved constructor fields are checked after default factories and `__post_init__`
75
+ run. A nested dataclass default must be an instance of that class, including
76
+ inside lists, dictionaries, and unions; dictionaries are accepted as dataclass
77
+ input only while parsing TOML.
78
+
79
+ Reading returns fresh objects without changing the section-to-class mapping.
80
+ Supply `logger=` to choose a logger; otherwise the package logger is used.
81
+ `write_config=False` is the default and creates no output files. When enabled,
82
+ records go into `<run_result_directory>/configs`, or directly into an explicit
83
+ `output_directory`. Writing requires one of these locations. The files are:
84
+
85
+ - `config.original.toml`: an exact copy of the input, including comments.
86
+ - `config.completed.toml`: resolved constructor-field values, including defaults.
87
+
88
+ Completed TOML excludes `init=False` fields and omits `None` entries in tables.
89
+ Because TOML has no null value, `None` inside lists causes a writing error.
90
+ Run-directory protection belongs to the caller; this module does not refuse
91
+ existing directories or files. Keep experiment descriptions in a separate file,
92
+ such as `experiments.md`.
93
+
94
+ Planned: configuration overrides from environment variables, with each override logged explicitly.
95
+
96
+ ## Doctor
97
+
98
+ `runhpc doctor` logs diagnostics to stderr. Add `--json` to get a single JSON
99
+ document on stdout while keeping the diagnostic logs on stderr.
100
+
101
+ ```bash
102
+ uv run runhpc doctor
103
+ uv run runhpc doctor --json > doctor.json
104
+ ```
105
+
106
+ Doctor reports Linux or macOS hardware and OS details, the current Python
107
+ environment and its installed distributions, and checks for terminal color
108
+ support, Submitit, SMTP connectivity, and read-only SeaTable metadata access.
109
+ Service checks read `.env` in the current working directory when present.
110
+ Process environment values take precedence.
111
+
112
+ - SMTP uses `SMTP_HOST`, `SMTP_PORT`, and `SMTP_SECURITY` (`starttls` or `tls`).
113
+ - SeaTable uses `SEATABLE_BASE_URL`, `SEATABLE_API_KEY`, and
114
+ `SEATABLE_HPC_TABLE`.
115
+
116
+ Use the Python API to write three separate files, `hardware_os.json`,
117
+ `self.json`, and `python_env.json`:
118
+
119
+ ```python
120
+ from runhpc.doctor import run_doctor
121
+
122
+ report = run_doctor(write_report=True, run_result_directory="runs/example")
123
+ ```
124
+
125
+ The files go under `runs/example/environment/`. Pass `output_directory` to
126
+ choose their location directly. The CLI writes its output to standard streams.
127
+
128
+ ## Email
129
+
130
+ Set `SMTP_HOST`, `SMTP_PORT`, and `SMTP_SECURITY` (`starttls` or `tls`).
131
+ For authenticated SMTP, also set `SMTP_USERNAME` and `SMTP_PASSWORD`.
132
+ Process environment values take precedence over `.env` in the current
133
+ directory. An explicit `environment` mapping supplies all SMTP settings.
134
+
135
+ ```python
136
+ from runhpc.mail import send_email
137
+
138
+ send_email(
139
+ "Run complete",
140
+ "All stages passed.",
141
+ smtp_from="sender@example.com",
142
+ smtp_to="recipient@example.com",
143
+ )
144
+ ```
145
+
146
+ ## SeaTable job logs
147
+
148
+ Install the optional SDK with `uv sync --group full`. Set
149
+ `SEATABLE_BASE_URL`, `SEATABLE_API_KEY`, and `SEATABLE_HPC_TABLE`. Process
150
+ values take precedence, and missing variables are read from `.env` in the
151
+ current directory. The table must already have the standard Job Status columns.
152
+
153
+ ```python
154
+ from runhpc.table import create_table_logs, end_table_logs, update_table_logs
155
+
156
+ logs = create_table_logs(job_id="114511", total_stages=4, observation="Production run")
157
+ update_table_logs(logs, completed_stages=4)
158
+ end_table_logs(logs, status="Completed") # Use "Failed" if the job failed.
159
+ ```
160
+
161
+ Keep the returned handle for later writes to the same row.
162
+
163
+ ## HyperQueue jobs on Slurm
164
+
165
+ On Linux x86-64, the `hq` extra installs the matching HyperQueue Python
166
+ binding and the RunHPC companion package with the `hq` executable. In a Git
167
+ checkout, initialize the pinned source before enabling the extra:
168
+
169
+ ```bash
170
+ git submodule update --init
171
+ uv sync --extra hq
172
+ ```
173
+
174
+ RunHPC release wheels ship an `hq` executable built from the pinned HyperQueue
175
+ source. Building from a Git checkout or source archive uses Cargo and requires
176
+ Rust 1.95 or newer, a C/C++ toolchain, CMake, and libclang.
177
+ On a cluster with its own HyperQueue installation, pass the absolute
178
+ `hq_executable` path or make `hq` available on `PATH`.
179
+
180
+ Install on a filesystem shared by the Slurm submission host and workers, and
181
+ pass a new `hq_metadata_directory` on that filesystem. The runner creates that
182
+ exact directory for the dedicated server's state, journal, and log.
183
+
184
+ ```python
185
+ from hyperqueue import Job
186
+ from runhpc.job_queue.controller import JobRunner, WorkerConfig
187
+
188
+ job = Job()
189
+ for case_index in range(100):
190
+ job.program(
191
+ ["python", "simulate.py", "--config", "config.toml"],
192
+ cwd="/shared/project",
193
+ env={"CASE_INDEX": str(case_index)},
194
+ )
195
+
196
+ workers = WorkerConfig(
197
+ max_worker_count=8,
198
+ partition="compute",
199
+ allocation_time_limit_seconds=3600,
200
+ cpus_per_worker=4,
201
+ )
202
+ result = JobRunner(
203
+ job, workers, hq_metadata_directory="/shared/runs/sweep-01/hyperqueue"
204
+ ).start()
205
+ print(result["succeeded"], result["journal_path"])
206
+ ```
207
+
208
+ HyperQueue starts tasks as workers become available and handles task
209
+ dependencies and worker loss. The worker count caps queued and running
210
+ workers. `start()` waits for the job to finish and stops its dedicated server.
211
+
212
+ Use the returned journal to create a timeline after the server shuts down.
213
+ The viewer reads HyperQueue 0.27 journal exports and draws each task attempt
214
+ on its worker lane.
215
+
216
+ ```python
217
+ from runhpc.job_queue.run_viewer import generate_job_timeline_svg
218
+
219
+ generate_job_timeline_svg(
220
+ result["journal_path"],
221
+ "timeline.svg",
222
+ hyperqueue_job_id=result["hyperqueue_job_id"],
223
+ )
224
+ ```
225
+
226
+ ## Development
227
+
228
+ Development checks:
229
+
230
+ ```bash
231
+ uv sync --dev
232
+ uv run pytest
233
+ uv run black --check src/runhpc/config.py tests/test_config.py src/runhpc/logger.py
234
+ uv run mypy
235
+ ```
236
+
237
+ Mypy currently checks the configuration module and its local imports.
238
+
239
+ ## Publishing
240
+
241
+ Build from the repository root with `uv` and Docker available. The companion
242
+ wheel is built from its source archive inside the glibc 2.28 environment.
243
+ `auditwheel` checks the executable's library requirements before applying the
244
+ manylinux tag. The final check submits a local task using the installed wheel
245
+ and the matching HyperQueue Python binding.
246
+
247
+ ```bash
248
+ set -e
249
+ git submodule update --init
250
+ release_dir=$(mktemp -d)
251
+ uv build --no-sources --out-dir "$release_dir/main"
252
+
253
+ docker run --rm -i --platform linux/amd64 \
254
+ -v "$PWD:/io:ro" -v "$release_dir:/release" \
255
+ quay.io/pypa/manylinux_2_28_x86_64 bash -se -o pipefail <<'BUILD_HQ'
256
+ yum install -y clang
257
+ curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | \
258
+ sh -s -- -y --profile minimal --default-toolchain 1.95.0
259
+ export PATH="$HOME/.cargo/bin:/opt/python/cp312-cp312/bin:$PATH"
260
+ python -m pip install 'uv==0.9.15' 'auditwheel==6.8.2'
261
+
262
+ uv build /io/packages/runhpc-hq --no-sources --sdist --out-dir /release/companion
263
+ CARGO_BUILD_JOBS=2 uv build /release/companion/runhpc_hq-*.tar.gz \
264
+ --no-sources --wheel --out-dir /tmp/hq-wheel
265
+ auditwheel repair --plat manylinux_2_28_x86_64 --only-plat \
266
+ --wheel-dir /release/companion /tmp/hq-wheel/runhpc_hq-*.whl
267
+
268
+ smoke_dir=$(mktemp -d)
269
+ cd "$smoke_dir"
270
+ uv venv --python /opt/python/cp312-cp312/bin/python .venv
271
+ main_wheel=(/release/main/runhpc-*.whl)
272
+ uv pip install --only-binary :all: "${main_wheel[0]}[hq]" /release/companion/runhpc_hq-*.whl
273
+ hq=$(.venv/bin/python -c 'from runhpc.job_queue.hq_executable import resolve_hq_executable; print(resolve_hq_executable())')
274
+ "$hq" --version
275
+ "$hq" --server-dir "$smoke_dir/server" server start &
276
+ server_pid=$!
277
+ trap 'kill "$server_pid" 2>/dev/null || true' EXIT
278
+ for attempt in {1..30}; do
279
+ if "$hq" --server-dir "$smoke_dir/server" server info >/dev/null 2>&1; then
280
+ break
281
+ fi
282
+ sleep 1
283
+ done
284
+ "$hq" --server-dir "$smoke_dir/server" server info
285
+ "$hq" --server-dir "$smoke_dir/server" worker start --cpus 1 --detect-resources none &
286
+ worker_pid=$!
287
+ trap 'kill "$worker_pid" "$server_pid" 2>/dev/null || true' EXIT
288
+ timeout 60 .venv/bin/python - <<'SMOKE_TEST'
289
+ from hyperqueue import Client, Job
290
+
291
+ client = Client(server_dir="server")
292
+ job = Job()
293
+ job.program(["/bin/true"])
294
+ assert client.wait_for_jobs([client.submit(job)])
295
+ SMOKE_TEST
296
+ BUILD_HQ
297
+ ```
298
+
299
+ With `UV_PUBLISH_TOKEN` set for each project, publish the companion first. Use
300
+ the same `release_dir` from the build commands.
301
+
302
+ ```bash
303
+ uv publish "$release_dir"/companion/*.whl "$release_dir"/companion/*.tar.gz
304
+ uv publish "$release_dir"/main/*.whl "$release_dir"/main/*.tar.gz
305
+ ```
runhpc-0.1.0/README.md ADDED
@@ -0,0 +1,283 @@
1
+ # runhpc
2
+
3
+ Read TOML configuration sections into registered dataclasses:
4
+
5
+ ```python
6
+ from dataclasses import dataclass
7
+
8
+ from runhpc.config import ConfigReader, read_config
9
+
10
+
11
+ @dataclass
12
+ class TrainingConfig:
13
+ epochs: int
14
+ learning_rate: float = 0.001
15
+
16
+
17
+ configs = read_config(
18
+ {"training": TrainingConfig},
19
+ "config.toml",
20
+ write_config=True,
21
+ run_result_directory="runs/example",
22
+ )
23
+ training = configs["training"]
24
+
25
+ # Optional registration wrapper; reading uses the same public function.
26
+ reader = ConfigReader()
27
+ reader.register_class(TrainingConfig, section_name="training")
28
+ # Decorator form: @reader.register_name("training"), above @dataclass.
29
+ configs = reader.read("config.toml")
30
+ ```
31
+
32
+ Example `config.toml`:
33
+
34
+ ```toml
35
+ [training]
36
+ epochs = 100
37
+ ```
38
+
39
+ Missing fields use dataclass defaults or default factories and emit a warning:
40
+ `learning_rate is not presented in training, using default value: 0.001`.
41
+ An absent registered section uses the same field rules. Missing required fields,
42
+ unknown sections or fields, and duplicate registration names raise errors.
43
+ Fields with `init=False` are left to the dataclass and cannot appear in the input.
44
+
45
+ Supported annotations are `str`, `bool`, `int`, `float`, `datetime.date`,
46
+ `datetime.time`, `datetime.datetime`, nested dataclasses, typed lists,
47
+ string-keyed typed dictionaries, unions (including `Optional`), and scalar
48
+ `Literal` values. Types are enforced without conversions: an integer cannot
49
+ stand in for a float, and a boolean cannot stand in for an integer. Unsupported
50
+ annotations raise errors. Unions use the first matching declared branch, without
51
+ executing constructors for rejected branches.
52
+ Resolved constructor fields are checked after default factories and `__post_init__`
53
+ run. A nested dataclass default must be an instance of that class, including
54
+ inside lists, dictionaries, and unions; dictionaries are accepted as dataclass
55
+ input only while parsing TOML.
56
+
57
+ Reading returns fresh objects without changing the section-to-class mapping.
58
+ Supply `logger=` to choose a logger; otherwise the package logger is used.
59
+ `write_config=False` is the default and creates no output files. When enabled,
60
+ records go into `<run_result_directory>/configs`, or directly into an explicit
61
+ `output_directory`. Writing requires one of these locations. The files are:
62
+
63
+ - `config.original.toml`: an exact copy of the input, including comments.
64
+ - `config.completed.toml`: resolved constructor-field values, including defaults.
65
+
66
+ Completed TOML excludes `init=False` fields and omits `None` entries in tables.
67
+ Because TOML has no null value, `None` inside lists causes a writing error.
68
+ Run-directory protection belongs to the caller; this module does not refuse
69
+ existing directories or files. Keep experiment descriptions in a separate file,
70
+ such as `experiments.md`.
71
+
72
+ Planned: configuration overrides from environment variables, with each override logged explicitly.
73
+
74
+ ## Doctor
75
+
76
+ `runhpc doctor` logs diagnostics to stderr. Add `--json` to get a single JSON
77
+ document on stdout while keeping the diagnostic logs on stderr.
78
+
79
+ ```bash
80
+ uv run runhpc doctor
81
+ uv run runhpc doctor --json > doctor.json
82
+ ```
83
+
84
+ Doctor reports Linux or macOS hardware and OS details, the current Python
85
+ environment and its installed distributions, and checks for terminal color
86
+ support, Submitit, SMTP connectivity, and read-only SeaTable metadata access.
87
+ Service checks read `.env` in the current working directory when present.
88
+ Process environment values take precedence.
89
+
90
+ - SMTP uses `SMTP_HOST`, `SMTP_PORT`, and `SMTP_SECURITY` (`starttls` or `tls`).
91
+ - SeaTable uses `SEATABLE_BASE_URL`, `SEATABLE_API_KEY`, and
92
+ `SEATABLE_HPC_TABLE`.
93
+
94
+ Use the Python API to write three separate files, `hardware_os.json`,
95
+ `self.json`, and `python_env.json`:
96
+
97
+ ```python
98
+ from runhpc.doctor import run_doctor
99
+
100
+ report = run_doctor(write_report=True, run_result_directory="runs/example")
101
+ ```
102
+
103
+ The files go under `runs/example/environment/`. Pass `output_directory` to
104
+ choose their location directly. The CLI writes its output to standard streams.
105
+
106
+ ## Email
107
+
108
+ Set `SMTP_HOST`, `SMTP_PORT`, and `SMTP_SECURITY` (`starttls` or `tls`).
109
+ For authenticated SMTP, also set `SMTP_USERNAME` and `SMTP_PASSWORD`.
110
+ Process environment values take precedence over `.env` in the current
111
+ directory. An explicit `environment` mapping supplies all SMTP settings.
112
+
113
+ ```python
114
+ from runhpc.mail import send_email
115
+
116
+ send_email(
117
+ "Run complete",
118
+ "All stages passed.",
119
+ smtp_from="sender@example.com",
120
+ smtp_to="recipient@example.com",
121
+ )
122
+ ```
123
+
124
+ ## SeaTable job logs
125
+
126
+ Install the optional SDK with `uv sync --group full`. Set
127
+ `SEATABLE_BASE_URL`, `SEATABLE_API_KEY`, and `SEATABLE_HPC_TABLE`. Process
128
+ values take precedence, and missing variables are read from `.env` in the
129
+ current directory. The table must already have the standard Job Status columns.
130
+
131
+ ```python
132
+ from runhpc.table import create_table_logs, end_table_logs, update_table_logs
133
+
134
+ logs = create_table_logs(job_id="114511", total_stages=4, observation="Production run")
135
+ update_table_logs(logs, completed_stages=4)
136
+ end_table_logs(logs, status="Completed") # Use "Failed" if the job failed.
137
+ ```
138
+
139
+ Keep the returned handle for later writes to the same row.
140
+
141
+ ## HyperQueue jobs on Slurm
142
+
143
+ On Linux x86-64, the `hq` extra installs the matching HyperQueue Python
144
+ binding and the RunHPC companion package with the `hq` executable. In a Git
145
+ checkout, initialize the pinned source before enabling the extra:
146
+
147
+ ```bash
148
+ git submodule update --init
149
+ uv sync --extra hq
150
+ ```
151
+
152
+ RunHPC release wheels ship an `hq` executable built from the pinned HyperQueue
153
+ source. Building from a Git checkout or source archive uses Cargo and requires
154
+ Rust 1.95 or newer, a C/C++ toolchain, CMake, and libclang.
155
+ On a cluster with its own HyperQueue installation, pass the absolute
156
+ `hq_executable` path or make `hq` available on `PATH`.
157
+
158
+ Install on a filesystem shared by the Slurm submission host and workers, and
159
+ pass a new `hq_metadata_directory` on that filesystem. The runner creates that
160
+ exact directory for the dedicated server's state, journal, and log.
161
+
162
+ ```python
163
+ from hyperqueue import Job
164
+ from runhpc.job_queue.controller import JobRunner, WorkerConfig
165
+
166
+ job = Job()
167
+ for case_index in range(100):
168
+ job.program(
169
+ ["python", "simulate.py", "--config", "config.toml"],
170
+ cwd="/shared/project",
171
+ env={"CASE_INDEX": str(case_index)},
172
+ )
173
+
174
+ workers = WorkerConfig(
175
+ max_worker_count=8,
176
+ partition="compute",
177
+ allocation_time_limit_seconds=3600,
178
+ cpus_per_worker=4,
179
+ )
180
+ result = JobRunner(
181
+ job, workers, hq_metadata_directory="/shared/runs/sweep-01/hyperqueue"
182
+ ).start()
183
+ print(result["succeeded"], result["journal_path"])
184
+ ```
185
+
186
+ HyperQueue starts tasks as workers become available and handles task
187
+ dependencies and worker loss. The worker count caps queued and running
188
+ workers. `start()` waits for the job to finish and stops its dedicated server.
189
+
190
+ Use the returned journal to create a timeline after the server shuts down.
191
+ The viewer reads HyperQueue 0.27 journal exports and draws each task attempt
192
+ on its worker lane.
193
+
194
+ ```python
195
+ from runhpc.job_queue.run_viewer import generate_job_timeline_svg
196
+
197
+ generate_job_timeline_svg(
198
+ result["journal_path"],
199
+ "timeline.svg",
200
+ hyperqueue_job_id=result["hyperqueue_job_id"],
201
+ )
202
+ ```
203
+
204
+ ## Development
205
+
206
+ Development checks:
207
+
208
+ ```bash
209
+ uv sync --dev
210
+ uv run pytest
211
+ uv run black --check src/runhpc/config.py tests/test_config.py src/runhpc/logger.py
212
+ uv run mypy
213
+ ```
214
+
215
+ Mypy currently checks the configuration module and its local imports.
216
+
217
+ ## Publishing
218
+
219
+ Build from the repository root with `uv` and Docker available. The companion
220
+ wheel is built from its source archive inside the glibc 2.28 environment.
221
+ `auditwheel` checks the executable's library requirements before applying the
222
+ manylinux tag. The final check submits a local task using the installed wheel
223
+ and the matching HyperQueue Python binding.
224
+
225
+ ```bash
226
+ set -e
227
+ git submodule update --init
228
+ release_dir=$(mktemp -d)
229
+ uv build --no-sources --out-dir "$release_dir/main"
230
+
231
+ docker run --rm -i --platform linux/amd64 \
232
+ -v "$PWD:/io:ro" -v "$release_dir:/release" \
233
+ quay.io/pypa/manylinux_2_28_x86_64 bash -se -o pipefail <<'BUILD_HQ'
234
+ yum install -y clang
235
+ curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | \
236
+ sh -s -- -y --profile minimal --default-toolchain 1.95.0
237
+ export PATH="$HOME/.cargo/bin:/opt/python/cp312-cp312/bin:$PATH"
238
+ python -m pip install 'uv==0.9.15' 'auditwheel==6.8.2'
239
+
240
+ uv build /io/packages/runhpc-hq --no-sources --sdist --out-dir /release/companion
241
+ CARGO_BUILD_JOBS=2 uv build /release/companion/runhpc_hq-*.tar.gz \
242
+ --no-sources --wheel --out-dir /tmp/hq-wheel
243
+ auditwheel repair --plat manylinux_2_28_x86_64 --only-plat \
244
+ --wheel-dir /release/companion /tmp/hq-wheel/runhpc_hq-*.whl
245
+
246
+ smoke_dir=$(mktemp -d)
247
+ cd "$smoke_dir"
248
+ uv venv --python /opt/python/cp312-cp312/bin/python .venv
249
+ main_wheel=(/release/main/runhpc-*.whl)
250
+ uv pip install --only-binary :all: "${main_wheel[0]}[hq]" /release/companion/runhpc_hq-*.whl
251
+ hq=$(.venv/bin/python -c 'from runhpc.job_queue.hq_executable import resolve_hq_executable; print(resolve_hq_executable())')
252
+ "$hq" --version
253
+ "$hq" --server-dir "$smoke_dir/server" server start &
254
+ server_pid=$!
255
+ trap 'kill "$server_pid" 2>/dev/null || true' EXIT
256
+ for attempt in {1..30}; do
257
+ if "$hq" --server-dir "$smoke_dir/server" server info >/dev/null 2>&1; then
258
+ break
259
+ fi
260
+ sleep 1
261
+ done
262
+ "$hq" --server-dir "$smoke_dir/server" server info
263
+ "$hq" --server-dir "$smoke_dir/server" worker start --cpus 1 --detect-resources none &
264
+ worker_pid=$!
265
+ trap 'kill "$worker_pid" "$server_pid" 2>/dev/null || true' EXIT
266
+ timeout 60 .venv/bin/python - <<'SMOKE_TEST'
267
+ from hyperqueue import Client, Job
268
+
269
+ client = Client(server_dir="server")
270
+ job = Job()
271
+ job.program(["/bin/true"])
272
+ assert client.wait_for_jobs([client.submit(job)])
273
+ SMOKE_TEST
274
+ BUILD_HQ
275
+ ```
276
+
277
+ With `UV_PUBLISH_TOKEN` set for each project, publish the companion first. Use
278
+ the same `release_dir` from the build commands.
279
+
280
+ ```bash
281
+ uv publish "$release_dir"/companion/*.whl "$release_dir"/companion/*.tar.gz
282
+ uv publish "$release_dir"/main/*.whl "$release_dir"/main/*.tar.gz
283
+ ```
@@ -0,0 +1,61 @@
1
+ [project]
2
+ name = "runhpc"
3
+ version = "0.1.0"
4
+ description = "Python utilities for configuring, diagnosing, and monitoring HPC runs, with HyperQueue job execution on Slurm."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ authors = [{ name = "zy_peng" }]
8
+ keywords = ["hpc", "slurm", "hyperqueue", "job scheduling", "diagnostics"]
9
+ classifiers = [
10
+ "Environment :: Console",
11
+ "Intended Audience :: Science/Research",
12
+ "Programming Language :: Python :: 3",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ "Topic :: Scientific/Engineering",
16
+ ]
17
+ dependencies = [
18
+ "python-dotenv>=1.2.4",
19
+ "tomli-w>=1.2.0",
20
+ ]
21
+
22
+ [project.urls]
23
+ Repository = "https://github.com/ccbry/runhpc"
24
+ Issues = "https://github.com/ccbry/runhpc/issues"
25
+
26
+ [project.optional-dependencies]
27
+ hq = [
28
+ "hyperqueue==0.27.0; sys_platform == 'linux' and platform_machine == 'x86_64'",
29
+ "runhpc-hq==0.27.0; sys_platform == 'linux' and platform_machine == 'x86_64'",
30
+ ]
31
+
32
+ [project.scripts]
33
+ runhpc = "runhpc.cli:main"
34
+
35
+ [build-system]
36
+ requires = ["setuptools>=64"]
37
+ build-backend = "setuptools.build_meta"
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "black>=26.10.1",
42
+ "hatchling>=1.27",
43
+ "mypy>=2.4.1",
44
+ "pytest>=9.2.0",
45
+ ]
46
+ full = [
47
+ "seatable-api>=4.0.0",
48
+ "submitit>=1.5.4",
49
+ ]
50
+
51
+ [tool.uv.sources]
52
+ runhpc-hq = { path = "packages/runhpc-hq" }
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ pythonpath = ["src"]
57
+
58
+ [tool.mypy]
59
+ files = ["src/runhpc/config.py"]
60
+ mypy_path = "src"
61
+ check_untyped_defs = true
runhpc-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,37 @@
1
+ """Command-line entry point for runhpc."""
2
+
3
+ import argparse
4
+ import json
5
+ import logging
6
+ import sys
7
+ from collections.abc import Sequence
8
+ from contextlib import redirect_stdout
9
+
10
+ from runhpc.doctor import run_doctor
11
+ from runhpc.logger import Logger
12
+
13
+
14
+ def main(argv: Sequence[str] | None = None) -> int:
15
+ """Run doctor and optionally write its JSON document to stdout."""
16
+ parser = argparse.ArgumentParser(prog="runhpc")
17
+ commands = parser.add_subparsers(required=True)
18
+ doctor_parser = commands.add_parser("doctor", help="Check the runtime environment.")
19
+ doctor_parser.add_argument(
20
+ "--json",
21
+ action="store_true",
22
+ help="Print the complete report as JSON to stdout.",
23
+ )
24
+ arguments = parser.parse_args(argv)
25
+
26
+ logger = Logger(
27
+ level=logging.DEBUG if arguments.json else logging.INFO, stream=sys.stderr
28
+ )
29
+ try:
30
+ with redirect_stdout(sys.stderr):
31
+ report = run_doctor(logger=logger, terminal_stream=sys.stderr)
32
+ except (OSError, ValueError) as error:
33
+ logger.error("%s", error)
34
+ return 1
35
+ if arguments.json:
36
+ print(json.dumps(report, indent=2))
37
+ return 0