oh-my-batch 0.5.1__tar.gz → 0.5.3__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.
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/PKG-INFO +4 -1
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/README.md +3 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/batch.py +0 -1
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/combo.py +31 -19
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/job.py +6 -5
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/pyproject.toml +1 -1
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/LICENSE +0 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/__init__.py +0 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/__main__.py +0 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/assets/__init__.py +0 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/assets/functions.sh +0 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/cli.py +0 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/misc.py +0 -0
- {oh_my_batch-0.5.1 → oh_my_batch-0.5.3}/oh_my_batch/util.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: oh-my-batch
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.3
|
4
4
|
Summary:
|
5
5
|
License: GPL
|
6
6
|
Author: weihong.xu
|
@@ -37,6 +37,9 @@ pip install oh-my-batch
|
|
37
37
|
|
38
38
|
## Examples
|
39
39
|
* [TESLA workflow](./examples/tesla/): A customizable active learning workflow for training machine learning potentials.
|
40
|
+
* [TESLA PIMD workflow](./examples/tesla-pimd/): A customizable active learning workflow for training machine learning potentials with path integral molecular dynamics.
|
41
|
+
* [LAMMPS benchmark](./examples/lammps-benchmark/): Find out the best MPI and OpenMP setup for LAMMPS through benchmarking.
|
42
|
+
|
40
43
|
|
41
44
|
## Use cases
|
42
45
|
|
@@ -19,6 +19,9 @@ pip install oh-my-batch
|
|
19
19
|
|
20
20
|
## Examples
|
21
21
|
* [TESLA workflow](./examples/tesla/): A customizable active learning workflow for training machine learning potentials.
|
22
|
+
* [TESLA PIMD workflow](./examples/tesla-pimd/): A customizable active learning workflow for training machine learning potentials with path integral molecular dynamics.
|
23
|
+
* [LAMMPS benchmark](./examples/lammps-benchmark/): Find out the best MPI and OpenMP setup for LAMMPS through benchmarking.
|
24
|
+
|
22
25
|
|
23
26
|
## Use cases
|
24
27
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from itertools import product
|
2
2
|
from string import Template
|
3
|
+
import traceback
|
3
4
|
import random
|
4
5
|
import json
|
5
6
|
import os
|
@@ -164,7 +165,7 @@ class ComboMaker:
|
|
164
165
|
return self
|
165
166
|
|
166
167
|
def make_files(self, file: str, template: str, delimiter='@', mode=None, encoding='utf-8',
|
167
|
-
extra_vars_from_file=None):
|
168
|
+
extra_vars_from_file=None, ignore_error=False):
|
168
169
|
"""
|
169
170
|
Make files from template against each combo
|
170
171
|
The template file can include variables with delimiter.
|
@@ -181,6 +182,7 @@ class ComboMaker:
|
|
181
182
|
:param mode: File mode, e.g. 755, 644, ...
|
182
183
|
:param encoding: File encoding
|
183
184
|
:param extra_vars_from_file: Load extra variables from json file, which can be used in template
|
185
|
+
:param ignore_error: If True, ignore error when making files
|
184
186
|
"""
|
185
187
|
_delimiter = delimiter
|
186
188
|
|
@@ -189,24 +191,31 @@ class ComboMaker:
|
|
189
191
|
|
190
192
|
combos = self._make_combos()
|
191
193
|
for i, combo in enumerate(combos):
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
194
|
+
try:
|
195
|
+
_template = template.format(i=i, **combo)
|
196
|
+
with open(_template, 'r') as f:
|
197
|
+
template_text = f.read()
|
198
|
+
|
199
|
+
if extra_vars_from_file is not None:
|
200
|
+
_vars_file = extra_vars_from_file.format(i=i, **combo)
|
201
|
+
with open(_vars_file, 'r') as f:
|
202
|
+
extra_vars = json.load(f)
|
203
|
+
else:
|
204
|
+
extra_vars = {}
|
205
|
+
text = _Template(template_text).safe_substitute(combo, **extra_vars)
|
206
|
+
_file = file.format(i=i, **combo)
|
207
|
+
ensure_dir(_file)
|
208
|
+
|
209
|
+
with open(_file, 'w', encoding=encoding) as f:
|
210
|
+
f.write(text)
|
211
|
+
if mode is not None:
|
212
|
+
os.chmod(_file, mode_translate(str(mode)))
|
213
|
+
except Exception as e:
|
214
|
+
if ignore_error:
|
215
|
+
print(f"Error during making file, ignore: {e}")
|
216
|
+
traceback.print_exc()
|
217
|
+
else:
|
218
|
+
raise e
|
210
219
|
return self
|
211
220
|
|
212
221
|
def print(self, *line: str, file: str = '', mode=None, encoding='utf-8'):
|
@@ -254,6 +263,9 @@ class ComboMaker:
|
|
254
263
|
return self
|
255
264
|
|
256
265
|
def show_combos(self):
|
266
|
+
"""
|
267
|
+
Show all combos in a human-readable format for debugging
|
268
|
+
"""
|
257
269
|
combos = self._make_combos()
|
258
270
|
if not combos:
|
259
271
|
print("No combos")
|
@@ -87,14 +87,15 @@ class BaseJobManager:
|
|
87
87
|
break
|
88
88
|
|
89
89
|
time.sleep(interval)
|
90
|
+
|
91
|
+
error = False
|
90
92
|
for job in jobs:
|
91
|
-
error = False
|
92
93
|
if not JobState.is_success(job['state']):
|
93
94
|
logger.error('Job %s failed', job['script'])
|
94
95
|
error = True
|
95
|
-
if error:
|
96
|
+
if error and not wait:
|
96
97
|
raise RuntimeError('Some jobs failed')
|
97
|
-
|
98
|
+
|
98
99
|
def wait(self, *job_ids, timeout=None, interval=10):
|
99
100
|
"""
|
100
101
|
Wait for jobs to finish
|
@@ -135,7 +136,7 @@ class BaseJobManager:
|
|
135
136
|
|
136
137
|
def _update_state(self, jobs: List[dict]):
|
137
138
|
raise NotImplementedError
|
138
|
-
|
139
|
+
|
139
140
|
def _submit_job(self, job: dict, submit_opts: str):
|
140
141
|
raise NotImplementedError
|
141
142
|
|
@@ -170,7 +171,7 @@ class Slurm(BaseJobManager):
|
|
170
171
|
break
|
171
172
|
else:
|
172
173
|
logger.error('Job %s not found in sacct output', job['id'])
|
173
|
-
return jobs
|
174
|
+
return jobs
|
174
175
|
|
175
176
|
def _submit_job(self, job:dict, submit_opts:str):
|
176
177
|
submit_cmd = f'{self._sbatch_bin} {submit_opts} {job["script"]}'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|