oh-my-batch 0.4.0__tar.gz → 0.4.1__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.
@@ -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,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
  [tool.poetry]
2
2
  name = "oh-my-batch"
3
- version = "0.4.0"
3
+ version = "0.4.1"
4
4
  description = ""
5
5
  authors = ["weihong.xu <xuweihong.cn@gmail.com>"]
6
6
  license = "GPL"
File without changes
@@ -67,9 +67,9 @@ omb combo \
67
67
  add_files DATA_FILE tmp/*.data - \
68
68
  add_var TEMP 300 400 500 - \
69
69
  add_randint RANDOM -n 3 -a 1 -b 1000 - \
70
+ set_broadcast RANDOM - \
70
71
  make_files tmp/tasks/{i}-T-{TEMP}/in.lmp --template tmp/in.lmp.tmp - \
71
72
  make_files tmp/tasks/{i}-T-{TEMP}/run.sh --template tmp/run.sh.tmp --mode 755 - \
72
- set_broadcast RANDOM - \
73
73
  done
74
74
  ```
75
75