dtu-hpc-cli 1.0.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.
@@ -0,0 +1,272 @@
1
+ Metadata-Version: 2.1
2
+ Name: dtu-hpc-cli
3
+ Version: 1.0.0
4
+ Summary:
5
+ Author: Christoffer Koo Øhrstrøm
6
+ Author-email: 2357447+ChrisFugl@users.noreply.github.com
7
+ Requires-Python: >=3.10,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Requires-Dist: paramiko (>=3.4.1,<4.0.0)
13
+ Requires-Dist: typer (>=0.12.5,<0.13.0)
14
+ Requires-Dist: uuid (>=1.30,<2.0)
15
+ Description-Content-Type: text/markdown
16
+
17
+ # DTU HPC CLI
18
+ CLI for working with the High Performance Cluster (HPC) at the Technical University of Denmark (DTU). This CLI is a wrapper around the tools provided by the HPC to make it easier to run and manage jobs. See the [HPC documentation](https://www.hpc.dtu.dk) for more information.
19
+
20
+ 1. [Requirements](#requirements)
21
+ 2. [Installation](#installation)
22
+ 3. [Usage](#usage)
23
+ 4. [Example](#example)
24
+ 5. [Configuration](#configuration)
25
+
26
+ a. [SSH](#ssh)
27
+
28
+ b. [Install](#install)
29
+
30
+ c. [History](#history)
31
+
32
+ d. [Remote Location](#remote-location)
33
+
34
+ e. [Submit](#submit)
35
+
36
+ f. [Complete Configuration](#complete-configuration)
37
+
38
+ ## Requirements
39
+
40
+ Python v3.10+ is a requirement.
41
+
42
+ You will also need to have `rsync` installed for the `dtu sync` command` to work.
43
+
44
+ ## Installation
45
+
46
+ The CLI can be installed using pip:
47
+
48
+ ``` sh
49
+ pip install dtu-hpc-cli
50
+ ```
51
+
52
+ You will also need to create a configuration in your project. See [Configuration](#configuration).
53
+
54
+ ## Usage
55
+
56
+ You can call it using the `dtu` command, which has the these subcommands:
57
+
58
+ * **history**: Shows a list of the jobs that you have submitted and the options/commands that you used.
59
+ * **install**: Calls the installation commands in your configuration. NB. this command will install your project on the HPC - not on your local machine.
60
+ * **list**: Shows a list of running and pending jobs. It calls `bstat` on the HPC.
61
+ * **remove**: Removes (kills) one or more running or pending jobs. It calls `bkill` on the HPC.
62
+ * **resubmit**: Submits a job with the same options/commands as a previous job. Each option/command can optionally be overriden.
63
+ * **submit**: Submits a job to the HPC. Calls `bsub` on the HPC. NB. This command will automatically split a job into multiple jobs that run after each other when the walltime exceeds 24 hours. This is done because HPC limits GPU jobs to this duration. You can use the `--split-every` option to change duration at which jobs should be split.
64
+ * **sync**: Synchronizes your local project with the project on the HPC. Requires that you have the `rsync` command. NB. It ignores everything in `.gitignore`.
65
+
66
+ All commands will work out of the box on the HPC (except for `sync`). However, a big advantage of this tool is that you can call it from your local machine as well. You will need to [configure SSH](#ssh) for this to work.
67
+
68
+ ## Example
69
+
70
+ A typical workflow will look like this:
71
+
72
+ 1. Synchronize your local project with the HPC.
73
+
74
+ ``` txt
75
+ > dtu sync
76
+
77
+ ⠹ Syncing
78
+ Finished synchronizing
79
+ ````
80
+
81
+ 2. Install the project on the HPC. (Install commands are `["poetry install --sync"]` in this example.)
82
+
83
+ ``` txt
84
+ > dtu install
85
+
86
+ ⠇ Installing
87
+ Finished installation. Here are the outputs:
88
+ > poetry install --sync
89
+ Installing dependencies from lock file
90
+
91
+ Package operations: 0 installs, 0 updates, 1 removal
92
+
93
+ - Removing setuptools (69.5.1)
94
+ ````
95
+
96
+ 3. Submit a job. Use `dtu submit --help` to see all available options.
97
+
98
+ ``` txt
99
+ > dtu submit --name test --cores 2 --memory 2gb --walltime 1h "echo foo" "echo bar"
100
+
101
+ Job script:
102
+
103
+ #!/bin/sh
104
+ ### General options
105
+ #BSUB -J test
106
+ #BSUB -q hpc
107
+ #BSUB -n 2
108
+ #BSUB -R rusage[mem=2GB]
109
+ #BSUB -R span[hosts=1]
110
+ #BSUB -W 01:00
111
+ # -- end of LSF options --
112
+
113
+ # Commands
114
+ git switch main && echo foo
115
+ git switch main && echo bar
116
+
117
+ Submit job (enter to submit)? [Y/n]: y
118
+ Submitting job...
119
+ Submitted job <22862148>
120
+ ```
121
+
122
+ 4. Check that job is queued.
123
+
124
+ ``` txt
125
+ > dtu list
126
+
127
+ JOBID USER QUEUE JOB_NAME NALLOC STAT START_TIME ELAPSED
128
+ 22862150 [user] hpc test 0 PEND - 0:00:00
129
+ ```
130
+
131
+ ## Configuration
132
+
133
+ You will need to configure the CLI for each project, such that it knows what to install and how to connect to the HPC. You do this by creating `.dtu_hpc.json` in the root of your project. (We suggest that you add this file to .gitignore since the SSH configuration is specific to each user.)
134
+
135
+ All options in the configuration are optional, which means it can be as simple as this:
136
+
137
+ ``` json
138
+ {}
139
+ ```
140
+
141
+ However, we highly recommend to at least configure SSH to be able to manage jobs from your local machine.
142
+
143
+ See all options in [the complete example at the end](#complete-configuration).
144
+
145
+ ### SSH
146
+
147
+ The SSH configuration requires that you at least add a *user* and *identityfile*. You may also optionally specify a hostname - it defaults to *login1.hpc.dtu.dk* when omitted.
148
+
149
+ ``` json
150
+ {
151
+ "ssh": {
152
+ "user": "your_dtu_username",
153
+ "identityfile": "/your/local/path/to/private/key"
154
+ }
155
+ }
156
+ ```
157
+
158
+ ### Install
159
+
160
+ The `install` command requires that you provide a set of commands to run. These are provided using the *install* option.
161
+
162
+ ``` json
163
+ {
164
+ "install": [
165
+ "pip install -r requirements.txt"
166
+ ]
167
+ }
168
+ ```
169
+
170
+ ### History
171
+
172
+ The history of job submissions defaults to be saved to *.dtu_hpc_history.json* in the root of your project. You can override this location using *history_path*:
173
+
174
+ ``` json
175
+ {
176
+ "history_path": "path/to/history.json"
177
+ }
178
+ ```
179
+
180
+ ### Remote Location
181
+
182
+ The tool needs to know the location of your project on the HPC. The location defaults to *~/[name]-[hash]* where *[name]* is the project directory name on your local machine and *[hash]* is generated based on the path to *[name]* on your local machine. You can override this using *remote_path*:
183
+
184
+ ``` json
185
+ {
186
+ "remote_path": "path/to/project/on/hpc"
187
+ }
188
+ ```
189
+
190
+ ### Submit
191
+ The submit command has many options and you may want to provide sensible defaults for your specific application. Call `dtu submit --help` to see the existing defaults.
192
+
193
+ Any of the options can be given a custom default. As such, both of these are valid configurations for *submit*.
194
+
195
+ Only override a single option to use the V100 GPU queue as the default queue:
196
+
197
+ ``` json
198
+ {
199
+ "submit": {
200
+ "queue": "gpuv100"
201
+ }
202
+ }
203
+ ```
204
+
205
+ Provide your own default settings for all *submit* options:
206
+
207
+ ``` json
208
+ {
209
+ "submit": {
210
+ "branch": "main",
211
+ "commands": [
212
+ "python my_script.py"
213
+ ],
214
+ "cores": 4,
215
+ "feature": [
216
+ "gpu32gb"
217
+ ],
218
+ "error": "path/to/error_dir",
219
+ "gpus": 1,
220
+ "hosts": 1,
221
+ "memory": "5GB",
222
+ "model": "XeonGold6230",
223
+ "name": "my_job",
224
+ "output": "path/to/output_dir_",
225
+ "queue": "hpc",
226
+ "split_every": "1d",
227
+ "start_after": "12345678",
228
+ "walltime": "1d"
229
+ }
230
+ }
231
+ ```
232
+
233
+ **NB.** *error* and *output* are directory locations on the HPC. The file path will be `[directory]/[name]_[jobId].out` for output and `[directory]/[name]_[jobId].err` for error.
234
+
235
+ ### Complete Configuration
236
+
237
+ Here is a complete example for a configuration that customizes everything:
238
+
239
+ ``` json
240
+ {
241
+ "history_path": "path/to/history.json",
242
+ "install": [
243
+ "pip install -r requirements.txt"
244
+ ],
245
+ "remote_path": "path/to/project/on/hpc",
246
+ "ssh": {
247
+ "user": "your_dtu_username",
248
+ "identityfile": "/your/local/path/to/private/key"
249
+ },
250
+ "submit": {
251
+ "branch": "main",
252
+ "commands": [
253
+ "python my_script.py"
254
+ ],
255
+ "cores": 4,
256
+ "feature": [
257
+ "gpu32gb"
258
+ ],
259
+ "error": "path/to/error_dir",
260
+ "gpus": 1,
261
+ "hosts": 1,
262
+ "memory": "5GB",
263
+ "model": "XeonGold6230",
264
+ "name": "my_job",
265
+ "output": "path/to/output_dir_",
266
+ "queue": "hpc",
267
+ "split_every": "1d",
268
+ "start_after": "12345678",
269
+ "walltime": "1d"
270
+ }
271
+ }
272
+ ```
@@ -0,0 +1,256 @@
1
+ # DTU HPC CLI
2
+ CLI for working with the High Performance Cluster (HPC) at the Technical University of Denmark (DTU). This CLI is a wrapper around the tools provided by the HPC to make it easier to run and manage jobs. See the [HPC documentation](https://www.hpc.dtu.dk) for more information.
3
+
4
+ 1. [Requirements](#requirements)
5
+ 2. [Installation](#installation)
6
+ 3. [Usage](#usage)
7
+ 4. [Example](#example)
8
+ 5. [Configuration](#configuration)
9
+
10
+ a. [SSH](#ssh)
11
+
12
+ b. [Install](#install)
13
+
14
+ c. [History](#history)
15
+
16
+ d. [Remote Location](#remote-location)
17
+
18
+ e. [Submit](#submit)
19
+
20
+ f. [Complete Configuration](#complete-configuration)
21
+
22
+ ## Requirements
23
+
24
+ Python v3.10+ is a requirement.
25
+
26
+ You will also need to have `rsync` installed for the `dtu sync` command` to work.
27
+
28
+ ## Installation
29
+
30
+ The CLI can be installed using pip:
31
+
32
+ ``` sh
33
+ pip install dtu-hpc-cli
34
+ ```
35
+
36
+ You will also need to create a configuration in your project. See [Configuration](#configuration).
37
+
38
+ ## Usage
39
+
40
+ You can call it using the `dtu` command, which has the these subcommands:
41
+
42
+ * **history**: Shows a list of the jobs that you have submitted and the options/commands that you used.
43
+ * **install**: Calls the installation commands in your configuration. NB. this command will install your project on the HPC - not on your local machine.
44
+ * **list**: Shows a list of running and pending jobs. It calls `bstat` on the HPC.
45
+ * **remove**: Removes (kills) one or more running or pending jobs. It calls `bkill` on the HPC.
46
+ * **resubmit**: Submits a job with the same options/commands as a previous job. Each option/command can optionally be overriden.
47
+ * **submit**: Submits a job to the HPC. Calls `bsub` on the HPC. NB. This command will automatically split a job into multiple jobs that run after each other when the walltime exceeds 24 hours. This is done because HPC limits GPU jobs to this duration. You can use the `--split-every` option to change duration at which jobs should be split.
48
+ * **sync**: Synchronizes your local project with the project on the HPC. Requires that you have the `rsync` command. NB. It ignores everything in `.gitignore`.
49
+
50
+ All commands will work out of the box on the HPC (except for `sync`). However, a big advantage of this tool is that you can call it from your local machine as well. You will need to [configure SSH](#ssh) for this to work.
51
+
52
+ ## Example
53
+
54
+ A typical workflow will look like this:
55
+
56
+ 1. Synchronize your local project with the HPC.
57
+
58
+ ``` txt
59
+ > dtu sync
60
+
61
+ ⠹ Syncing
62
+ Finished synchronizing
63
+ ````
64
+
65
+ 2. Install the project on the HPC. (Install commands are `["poetry install --sync"]` in this example.)
66
+
67
+ ``` txt
68
+ > dtu install
69
+
70
+ ⠇ Installing
71
+ Finished installation. Here are the outputs:
72
+ > poetry install --sync
73
+ Installing dependencies from lock file
74
+
75
+ Package operations: 0 installs, 0 updates, 1 removal
76
+
77
+ - Removing setuptools (69.5.1)
78
+ ````
79
+
80
+ 3. Submit a job. Use `dtu submit --help` to see all available options.
81
+
82
+ ``` txt
83
+ > dtu submit --name test --cores 2 --memory 2gb --walltime 1h "echo foo" "echo bar"
84
+
85
+ Job script:
86
+
87
+ #!/bin/sh
88
+ ### General options
89
+ #BSUB -J test
90
+ #BSUB -q hpc
91
+ #BSUB -n 2
92
+ #BSUB -R rusage[mem=2GB]
93
+ #BSUB -R span[hosts=1]
94
+ #BSUB -W 01:00
95
+ # -- end of LSF options --
96
+
97
+ # Commands
98
+ git switch main && echo foo
99
+ git switch main && echo bar
100
+
101
+ Submit job (enter to submit)? [Y/n]: y
102
+ Submitting job...
103
+ Submitted job <22862148>
104
+ ```
105
+
106
+ 4. Check that job is queued.
107
+
108
+ ``` txt
109
+ > dtu list
110
+
111
+ JOBID USER QUEUE JOB_NAME NALLOC STAT START_TIME ELAPSED
112
+ 22862150 [user] hpc test 0 PEND - 0:00:00
113
+ ```
114
+
115
+ ## Configuration
116
+
117
+ You will need to configure the CLI for each project, such that it knows what to install and how to connect to the HPC. You do this by creating `.dtu_hpc.json` in the root of your project. (We suggest that you add this file to .gitignore since the SSH configuration is specific to each user.)
118
+
119
+ All options in the configuration are optional, which means it can be as simple as this:
120
+
121
+ ``` json
122
+ {}
123
+ ```
124
+
125
+ However, we highly recommend to at least configure SSH to be able to manage jobs from your local machine.
126
+
127
+ See all options in [the complete example at the end](#complete-configuration).
128
+
129
+ ### SSH
130
+
131
+ The SSH configuration requires that you at least add a *user* and *identityfile*. You may also optionally specify a hostname - it defaults to *login1.hpc.dtu.dk* when omitted.
132
+
133
+ ``` json
134
+ {
135
+ "ssh": {
136
+ "user": "your_dtu_username",
137
+ "identityfile": "/your/local/path/to/private/key"
138
+ }
139
+ }
140
+ ```
141
+
142
+ ### Install
143
+
144
+ The `install` command requires that you provide a set of commands to run. These are provided using the *install* option.
145
+
146
+ ``` json
147
+ {
148
+ "install": [
149
+ "pip install -r requirements.txt"
150
+ ]
151
+ }
152
+ ```
153
+
154
+ ### History
155
+
156
+ The history of job submissions defaults to be saved to *.dtu_hpc_history.json* in the root of your project. You can override this location using *history_path*:
157
+
158
+ ``` json
159
+ {
160
+ "history_path": "path/to/history.json"
161
+ }
162
+ ```
163
+
164
+ ### Remote Location
165
+
166
+ The tool needs to know the location of your project on the HPC. The location defaults to *~/[name]-[hash]* where *[name]* is the project directory name on your local machine and *[hash]* is generated based on the path to *[name]* on your local machine. You can override this using *remote_path*:
167
+
168
+ ``` json
169
+ {
170
+ "remote_path": "path/to/project/on/hpc"
171
+ }
172
+ ```
173
+
174
+ ### Submit
175
+ The submit command has many options and you may want to provide sensible defaults for your specific application. Call `dtu submit --help` to see the existing defaults.
176
+
177
+ Any of the options can be given a custom default. As such, both of these are valid configurations for *submit*.
178
+
179
+ Only override a single option to use the V100 GPU queue as the default queue:
180
+
181
+ ``` json
182
+ {
183
+ "submit": {
184
+ "queue": "gpuv100"
185
+ }
186
+ }
187
+ ```
188
+
189
+ Provide your own default settings for all *submit* options:
190
+
191
+ ``` json
192
+ {
193
+ "submit": {
194
+ "branch": "main",
195
+ "commands": [
196
+ "python my_script.py"
197
+ ],
198
+ "cores": 4,
199
+ "feature": [
200
+ "gpu32gb"
201
+ ],
202
+ "error": "path/to/error_dir",
203
+ "gpus": 1,
204
+ "hosts": 1,
205
+ "memory": "5GB",
206
+ "model": "XeonGold6230",
207
+ "name": "my_job",
208
+ "output": "path/to/output_dir_",
209
+ "queue": "hpc",
210
+ "split_every": "1d",
211
+ "start_after": "12345678",
212
+ "walltime": "1d"
213
+ }
214
+ }
215
+ ```
216
+
217
+ **NB.** *error* and *output* are directory locations on the HPC. The file path will be `[directory]/[name]_[jobId].out` for output and `[directory]/[name]_[jobId].err` for error.
218
+
219
+ ### Complete Configuration
220
+
221
+ Here is a complete example for a configuration that customizes everything:
222
+
223
+ ``` json
224
+ {
225
+ "history_path": "path/to/history.json",
226
+ "install": [
227
+ "pip install -r requirements.txt"
228
+ ],
229
+ "remote_path": "path/to/project/on/hpc",
230
+ "ssh": {
231
+ "user": "your_dtu_username",
232
+ "identityfile": "/your/local/path/to/private/key"
233
+ },
234
+ "submit": {
235
+ "branch": "main",
236
+ "commands": [
237
+ "python my_script.py"
238
+ ],
239
+ "cores": 4,
240
+ "feature": [
241
+ "gpu32gb"
242
+ ],
243
+ "error": "path/to/error_dir",
244
+ "gpus": 1,
245
+ "hosts": 1,
246
+ "memory": "5GB",
247
+ "model": "XeonGold6230",
248
+ "name": "my_job",
249
+ "output": "path/to/output_dir_",
250
+ "queue": "hpc",
251
+ "split_every": "1d",
252
+ "start_after": "12345678",
253
+ "walltime": "1d"
254
+ }
255
+ }
256
+ ```