oh-my-batch 0.4.2__py3-none-any.whl → 0.4.4__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
@@ -33,7 +33,7 @@ class ComboMaker:
33
33
  self.add_var(key, *args)
34
34
  return self
35
35
 
36
- def add_randint(self, key: str, n: int, a: int, b: int, seed=None):
36
+ def add_randint(self, key: str, n: int, a: int, b: int, uniq=False, seed=None):
37
37
  """
38
38
  Add a variable with random integer values
39
39
 
@@ -41,11 +41,17 @@ class ComboMaker:
41
41
  :param n: Number of values
42
42
  :param a: Lower bound
43
43
  :param b: Upper bound
44
+ :param uniq: If True, values are unique, default is False
44
45
  :param seed: Seed for random number generator
45
46
  """
46
47
  if seed is not None:
47
48
  random.seed(seed)
48
- args = [random.randint(a, b) for _ in range(n)]
49
+ if uniq:
50
+ if b - a + 1 < n:
51
+ raise ValueError("Not enough unique values")
52
+ args = random.sample(range(a, b + 1), n)
53
+ else:
54
+ args = [random.randint(a, b) for _ in range(n)]
49
55
  self.add_var(key, *args)
50
56
  return self
51
57
 
@@ -221,7 +227,7 @@ class ComboMaker:
221
227
 
222
228
  For example,
223
229
 
224
- run_cmd "cp {DATA_FIEL} ./path/to/workdir/{i}/data.txt"
230
+ run_cmd "cp {DATA_FILE} ./path/to/workdir/{i}/data.txt"
225
231
 
226
232
  will copy each file in DATA_FILE to ./path/to/workdir/{i}/data.txt
227
233
 
@@ -237,6 +243,20 @@ class ComboMaker:
237
243
  raise RuntimeError(f"Failed to run command: {_cmd}")
238
244
  return self
239
245
 
246
+ def show_combos(self):
247
+ combos = self._make_combos()
248
+ if not combos:
249
+ print("No combos")
250
+ keys = combos[0].keys()
251
+
252
+ for i, combo in enumerate(combos):
253
+ print(f"> Combo {i}:")
254
+ for k in keys:
255
+ v = str(combo[k])
256
+ if '\n' in v:
257
+ v = f"\n{v}"
258
+ print(f"@{k}: {v}")
259
+
240
260
  def done(self):
241
261
  """
242
262
  End of command chain
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oh-my-batch
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary:
5
5
  License: GPL
6
6
  Author: weihong.xu
@@ -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=XK1t3rOQozf9oBYPr_CER7jhCMYpqJaZo0ke4ctK7t0,9307
7
+ oh_my_batch/combo.py,sha256=A5flYsjugcelj105P6Nq4M3kNGtdqh3c7QaSIL3hUcg,9954
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.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
- oh_my_batch-0.4.2.dist-info/METADATA,sha256=VrGmQGhqGB3RGqy8E5sxS4o288Ddd-uNqjTKnZmtAts,5509
13
- oh_my_batch-0.4.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
- oh_my_batch-0.4.2.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
- oh_my_batch-0.4.2.dist-info/RECORD,,
11
+ oh_my_batch-0.4.4.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
12
+ oh_my_batch-0.4.4.dist-info/METADATA,sha256=D9pKRVr4csOtcs05l-hvNku0CL8UQi57ZBScaAMc06M,5509
13
+ oh_my_batch-0.4.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
14
+ oh_my_batch-0.4.4.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
15
+ oh_my_batch-0.4.4.dist-info/RECORD,,