oh-my-batch 0.4.0__py3-none-any.whl → 0.4.1__py3-none-any.whl

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/combo.py CHANGED
@@ -4,7 +4,7 @@ import random
4
4
  import json
5
5
  import os
6
6
 
7
- from .util import expand_globs, mode_translate, ensure_dir
7
+ from .util import expand_globs, mode_translate, ensure_dir, shell_run
8
8
 
9
9
  class ComboMaker:
10
10
 
@@ -214,6 +214,28 @@ class ComboMaker:
214
214
  else:
215
215
  print(out)
216
216
  return self
217
+
218
+ def run_cmd(self, cmd: str):
219
+ """
220
+ Run command against each combo
221
+
222
+ For example,
223
+
224
+ run_cmd "cp {DATA_FIEL} ./path/to/workdir/{i}/data.txt"
225
+
226
+ will copy each file in DATA_FILE to ./path/to/workdir/{i}/data.txt
227
+
228
+ :param cmd: Command to run, can include format style variables, e.g. {i}, {i:03d}, {TEMP}
229
+ """
230
+ combos = self._make_combos()
231
+ for i, combo in enumerate(combos):
232
+ _cmd = cmd.format(i=i, **combo)
233
+ cp = shell_run(_cmd)
234
+ if cp.returncode != 0:
235
+ print(cp.stdout.decode('utf-8'))
236
+ print(cp.stderr.decode('utf-8'))
237
+ raise RuntimeError(f"Failed to run command: {_cmd}")
238
+ return self
217
239
 
218
240
  def done(self):
219
241
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oh-my-batch
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary:
5
5
  License: GPL
6
6
  Author: weihong.xu
@@ -86,9 +86,9 @@ omb combo \
86
86
  add_files DATA_FILE tmp/*.data - \
87
87
  add_var TEMP 300 400 500 - \
88
88
  add_randint RANDOM -n 3 -a 1 -b 1000 - \
89
+ set_broadcast RANDOM - \
89
90
  make_files tmp/tasks/{i}-T-{TEMP}/in.lmp --template tmp/in.lmp.tmp - \
90
91
  make_files tmp/tasks/{i}-T-{TEMP}/run.sh --template tmp/run.sh.tmp --mode 755 - \
91
- set_broadcast RANDOM - \
92
92
  done
93
93
  ```
94
94
 
@@ -4,12 +4,12 @@ oh_my_batch/assets/__init__.py,sha256=Exub46UbQaz2V2eXpQeiVfnThQpXaNeuyjlGY6gBSZ
4
4
  oh_my_batch/assets/functions.sh,sha256=LaiavZBu84D7C1r-dWhf91vPTuHXCMV1DQZUIPVQnjE,1001
5
5
  oh_my_batch/batch.py,sha256=6qnaXEVyA493heGzzbCrdZXCcnYk8zgl7WP0rmo7KlU,3690
6
6
  oh_my_batch/cli.py,sha256=Jyz8q2pUYke3mfJS6F_G9S9hApddgXxQw1BsN6Kfkjc,553
7
- oh_my_batch/combo.py,sha256=63F6plpGcVjKwdKCQ8b0dQhNCjHwXVirfnHPZDLe49U,8598
7
+ oh_my_batch/combo.py,sha256=K1pkmdDbpe-FCqUHe8fnuvWHz9aVHptGTvPds-jt_XA,9368
8
8
  oh_my_batch/job.py,sha256=Uk0E-WxnexBu9wuUV3uc1aAwVF_5rWdNdLEOB8Y9B-U,6252
9
9
  oh_my_batch/misc.py,sha256=G_iOovRCrShBJJCc82QLN0CvMqW4adOefEoY1GedEiw,452
10
10
  oh_my_batch/util.py,sha256=5ve2QcviuF0UHFLrsXmjMTj0ogXJ4g05q1y-yWCFuOk,2409
11
- oh_my_batch-0.4.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
- oh_my_batch-0.4.0.dist-info/METADATA,sha256=cOScID0UVLkM7O2Y8D4bBOTUWVqwxHss-DpN1ZH1Ctg,5560
13
- oh_my_batch-0.4.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
14
- oh_my_batch-0.4.0.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
- oh_my_batch-0.4.0.dist-info/RECORD,,
11
+ oh_my_batch-0.4.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
+ oh_my_batch-0.4.1.dist-info/METADATA,sha256=lOMdg0K_zSzMR-tlhcET2jowvBicqBTAHLBnm4Y6H6M,5560
13
+ oh_my_batch-0.4.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
14
+ oh_my_batch-0.4.1.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
+ oh_my_batch-0.4.1.dist-info/RECORD,,