oh-my-batch 0.5.6__tar.gz → 0.6.0__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.6 → oh_my_batch-0.6.0}/PKG-INFO +1 -1
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/batch.py +19 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/job.py +8 -5
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/pyproject.toml +1 -1
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/LICENSE +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/README.md +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/__init__.py +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/__main__.py +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/assets/__init__.py +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/assets/functions.sh +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/cli.py +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/combo.py +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/misc.py +0 -0
- {oh_my_batch-0.5.6 → oh_my_batch-0.6.0}/oh_my_batch/util.py +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
from typing import Optional
|
1
2
|
import shlex
|
2
3
|
import os
|
3
4
|
|
@@ -25,6 +26,24 @@ class BatchMaker:
|
|
25
26
|
self._work_dirs.extend(paths)
|
26
27
|
return self
|
27
28
|
|
29
|
+
def filter(self, expr: str):
|
30
|
+
"""
|
31
|
+
Filter working directories with a Python expression
|
32
|
+
|
33
|
+
:param expr: Python expression, the variable `{workdir} or {w}` is the directory path,
|
34
|
+
`{index} or {i}` is the index of the directory
|
35
|
+
|
36
|
+
Example: if expr is 'os.path.exits("{workdir}/input.json")',
|
37
|
+
then only the directories containing 'input.json' will be kept.
|
38
|
+
"""
|
39
|
+
filtered = []
|
40
|
+
for i, workdir in enumerate(self._work_dirs):
|
41
|
+
expr_eval = expr.format(workdir=workdir, w=workdir, index=i, i=i)
|
42
|
+
if eval(expr_eval):
|
43
|
+
filtered.append(workdir)
|
44
|
+
self._work_dirs = filtered
|
45
|
+
return self
|
46
|
+
|
28
47
|
def add_header_files(self, *file: str, encoding='utf-8'):
|
29
48
|
"""
|
30
49
|
Add script header from files
|
@@ -88,13 +88,16 @@ class BaseJobManager:
|
|
88
88
|
|
89
89
|
time.sleep(interval)
|
90
90
|
|
91
|
-
|
91
|
+
raise_err = False
|
92
92
|
for job in jobs:
|
93
|
-
if not JobState.
|
93
|
+
if not JobState.is_terminal(job['state']):
|
94
|
+
logger.warning('Job %s is running, current state: %s', job['script'], job['state'])
|
95
|
+
raise_err = True
|
96
|
+
elif not JobState.is_success(job['state']):
|
94
97
|
logger.error('Job %s failed', job['script'])
|
95
|
-
|
96
|
-
if
|
97
|
-
raise RuntimeError('Some jobs failed')
|
98
|
+
raise_err = True
|
99
|
+
if raise_err and wait:
|
100
|
+
raise RuntimeError('Some jobs failed or not finished yet')
|
98
101
|
|
99
102
|
def wait(self, *job_ids, timeout=None, interval=10):
|
100
103
|
"""
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|