oh-my-batch 0.4.1__py3-none-any.whl → 0.4.3__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 +25 -11
- {oh_my_batch-0.4.1.dist-info → oh_my_batch-0.4.3.dist-info}/METADATA +1 -2
- {oh_my_batch-0.4.1.dist-info → oh_my_batch-0.4.3.dist-info}/RECORD +6 -6
- {oh_my_batch-0.4.1.dist-info → oh_my_batch-0.4.3.dist-info}/WHEEL +1 -1
- {oh_my_batch-0.4.1.dist-info → oh_my_batch-0.4.3.dist-info}/LICENSE +0 -0
- {oh_my_batch-0.4.1.dist-info → oh_my_batch-0.4.3.dist-info}/entry_points.txt +0 -0
oh_my_batch/combo.py
CHANGED
@@ -85,13 +85,13 @@ class ComboMaker:
|
|
85
85
|
self.add_var(key, *args)
|
86
86
|
return self
|
87
87
|
|
88
|
-
def
|
88
|
+
def add_file_set(self, key: str, *path: str, format=None,
|
89
89
|
sep=' ', abs=False, raise_invalid=False):
|
90
90
|
"""
|
91
91
|
Add a variable with files by glob pattern as one string
|
92
92
|
Unlike add_files, this function joins the files with a delimiter.
|
93
93
|
For example, suppose there are 1.txt, 2.txt, 3.txt in data directory,
|
94
|
-
then calling
|
94
|
+
then calling add_file_set('DATA_FILE', 'data/*.txt') will add string "data/1.txt data/2.txt data/3.txt"
|
95
95
|
to the variable DATA_FILE.
|
96
96
|
|
97
97
|
:param key: Variable name
|
@@ -144,7 +144,7 @@ class ComboMaker:
|
|
144
144
|
else:
|
145
145
|
raise ValueError(f"Variable {key} not found")
|
146
146
|
return self
|
147
|
-
|
147
|
+
|
148
148
|
def set_broadcast(self, *keys: str):
|
149
149
|
"""
|
150
150
|
Specify variables use broadcast strategy instead of cartesian product
|
@@ -214,17 +214,17 @@ class ComboMaker:
|
|
214
214
|
else:
|
215
215
|
print(out)
|
216
216
|
return self
|
217
|
-
|
217
|
+
|
218
218
|
def run_cmd(self, cmd: str):
|
219
219
|
"""
|
220
220
|
Run command against each combo
|
221
221
|
|
222
|
-
For example,
|
223
|
-
|
224
|
-
run_cmd "cp {
|
222
|
+
For example,
|
223
|
+
|
224
|
+
run_cmd "cp {DATA_FILE} ./path/to/workdir/{i}/data.txt"
|
225
225
|
|
226
226
|
will copy each file in DATA_FILE to ./path/to/workdir/{i}/data.txt
|
227
|
-
|
227
|
+
|
228
228
|
:param cmd: Command to run, can include format style variables, e.g. {i}, {i:03d}, {TEMP}
|
229
229
|
"""
|
230
230
|
combos = self._make_combos()
|
@@ -237,6 +237,20 @@ class ComboMaker:
|
|
237
237
|
raise RuntimeError(f"Failed to run command: {_cmd}")
|
238
238
|
return self
|
239
239
|
|
240
|
+
def show_combos(self):
|
241
|
+
combos = self._make_combos()
|
242
|
+
if not combos:
|
243
|
+
print("No combos")
|
244
|
+
keys = combos[0].keys()
|
245
|
+
|
246
|
+
for i, combo in enumerate(combos):
|
247
|
+
print(f"> Combo {i}:")
|
248
|
+
for k in keys:
|
249
|
+
v = str(combo[k])
|
250
|
+
if '\n' in v:
|
251
|
+
v = f"\n{v}"
|
252
|
+
print(f"@{k}: {v}")
|
253
|
+
|
240
254
|
def done(self):
|
241
255
|
"""
|
242
256
|
End of command chain
|
@@ -246,13 +260,13 @@ class ComboMaker:
|
|
246
260
|
def _make_combos(self):
|
247
261
|
if not self._vars:
|
248
262
|
return self._combos
|
249
|
-
|
263
|
+
|
250
264
|
broadcast_vars = {}
|
251
|
-
|
265
|
+
|
252
266
|
for k in self._broadcast_keys:
|
253
267
|
broadcast_vars[k] = self._vars[k]
|
254
268
|
del self._vars[k]
|
255
|
-
|
269
|
+
|
256
270
|
keys = self._vars.keys()
|
257
271
|
values_list = product(*self._vars.values())
|
258
272
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: oh-my-batch
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.3
|
4
4
|
Summary:
|
5
5
|
License: GPL
|
6
6
|
Author: weihong.xu
|
@@ -13,7 +13,6 @@ Classifier: Programming Language :: Python :: 3.9
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
16
|
-
Classifier: Programming Language :: Python :: 3.13
|
17
16
|
Requires-Dist: fire (>=0.7.0,<0.8.0)
|
18
17
|
Description-Content-Type: text/markdown
|
19
18
|
|
@@ -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=
|
7
|
+
oh_my_batch/combo.py,sha256=pMhqwcN1oBmKx0LBCI4BtpPUvCuFIBe3n7Wx3sRPf7A,9697
|
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.
|
12
|
-
oh_my_batch-0.4.
|
13
|
-
oh_my_batch-0.4.
|
14
|
-
oh_my_batch-0.4.
|
15
|
-
oh_my_batch-0.4.
|
11
|
+
oh_my_batch-0.4.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
12
|
+
oh_my_batch-0.4.3.dist-info/METADATA,sha256=XhtI1jKDBXXxkK8QUdM_uJLfwTJcE9b1BtkJe5DLstM,5509
|
13
|
+
oh_my_batch-0.4.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
14
|
+
oh_my_batch-0.4.3.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
|
15
|
+
oh_my_batch-0.4.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|