oh-my-batch 0.1.0.dev1__py3-none-any.whl → 0.1.0.dev3__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/cli.py CHANGED
@@ -1,5 +1,8 @@
1
+ import logging
1
2
  import fire
2
3
 
4
+ logging.basicConfig(format='%(asctime)s %(name)s: %(message)s', level=logging.INFO)
5
+
3
6
  class JobCli:
4
7
 
5
8
  def slurm(self):
oh_my_batch/job.py CHANGED
@@ -12,29 +12,22 @@ from .util import expand_globs, shell_run, parse_csv
12
12
 
13
13
  logger = logging.getLogger(__name__)
14
14
 
15
+ class JobState:
16
+ NULL = 0
17
+ PENDING = 1
18
+ RUNNING = 2
19
+ CANCELLED = 3
20
+ COMPLETED = 4
21
+ FAILED = 5
22
+ UNKNOWN = 6
15
23
 
16
- class JobState(bytes, Enum):
17
- """
18
- Job state enumeration
19
- """
20
- def __new__(cls, value: int, terminal: bool, status_name: str) -> "JobState":
21
- obj = bytes.__new__(cls, [value])
22
- obj._value_ = value
23
- obj.terminal = terminal
24
- obj.status_name = status_name
25
- return obj
26
-
27
- value: int # type: ignore
28
- terminal: bool
29
- status_name: str
30
-
31
- NULL = (0, True, "NULL")
32
- PENDING = (1, False, "PENDING")
33
- RUNNING = (2, False, "RUNNING")
34
- CANCELLED = (3, True, "CANCELLED")
35
- COMPLETED = (4, True, "COMPLETED")
36
- FAILED = (5, True, "FAILED")
37
- UNKNOWN = (6, False, "UNKNOWN")
24
+ @classmethod
25
+ def is_terminal(cls, state: int):
26
+ return state in (JobState.NULL, JobState.COMPLETED, JobState.FAILED, JobState.CANCELLED)
27
+
28
+ @classmethod
29
+ def is_success(cls, state: int):
30
+ return state == JobState.COMPLETED
38
31
 
39
32
 
40
33
  def new_job(script: str):
@@ -84,7 +77,7 @@ class BaseJobManager:
84
77
  break
85
78
 
86
79
  # stop if all jobs are terminal and not job to be submitted
87
- if (all(j['state'].terminal for j in jobs) and
80
+ if (all(JobState.is_terminal(j['state']) for j in jobs) and
88
81
  not any(should_submit(j, max_tries) for j in jobs)):
89
82
  break
90
83
 
@@ -129,8 +122,8 @@ class Slurm(BaseJobManager):
129
122
  logger.warning('Unknown job %s state: %s',row['JobID'], row['State'])
130
123
  break
131
124
  else:
132
- job['state'] = JobState.FAILED
133
- logger.error('Job %s not found in sacct output', job['id'])
125
+ if job['id']:
126
+ logger.error('Job %s not found in sacct output', job['id'])
134
127
 
135
128
  # check if there are jobs to be (re)submitted
136
129
  for job in jobs:
@@ -170,8 +163,8 @@ class Slurm(BaseJobManager):
170
163
 
171
164
 
172
165
  def should_submit(job: dict, max_tries: int):
173
- state: JobState = job['state']
174
- if not state.terminal:
166
+ state: int = job['state']
167
+ if not JobState.is_terminal(state):
175
168
  return False
176
169
  if job['tries'] >= max_tries:
177
170
  return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oh-my-batch
3
- Version: 0.1.0.dev1
3
+ Version: 0.1.0.dev3
4
4
  Summary:
5
5
  License: GPL
6
6
  Author: weihong.xu
@@ -17,9 +17,9 @@ Requires-Dist: fire (>=0.7.0,<0.8.0)
17
17
  Description-Content-Type: text/markdown
18
18
 
19
19
  # oh-my-batch
20
- A simple tool to manipulate batch tasks.
20
+ A simple tool to manipulate batch tasks designed for scientific computing community.
21
21
 
22
- The goal of this to is to provide a handy command tool for
22
+ ## Features
23
23
  * `omb combo`: generate folders/files from different combinations of parameters
24
24
  * `omb batch`: generate batch scripts from multiple working directories
25
25
  * `omb job`: track the state of job in job schedular
@@ -3,12 +3,12 @@ oh_my_batch/__main__.py,sha256=sWyFZMwWNvhkanwZSJRGfBBDoIevhC028dTSB67i6yI,61
3
3
  oh_my_batch/assets/__init__.py,sha256=Exub46UbQaz2V2eXpQeiVfnThQpXaNeuyjlGY6gBSZc,130
4
4
  oh_my_batch/assets/functions.sh,sha256=eORxFefV-XrWbG-2I6u-c8uf1XxOQ31LaeVHBumwzJ4,708
5
5
  oh_my_batch/batch.py,sha256=e73N-xwxMvgxnWwFMp33PQD1Dy-T-ATjANlwtPRHPQM,3016
6
- oh_my_batch/cli.py,sha256=G_JxqX0Zbx_EbcDxXbYjJ_4O-EOhmkF1lcMWgQ5ZPqo,375
6
+ oh_my_batch/cli.py,sha256=uelW9ms1N30DipJOcsiuG5K-5VN8O6yu1RNEqex00GY,475
7
7
  oh_my_batch/combo.py,sha256=AHFD5CLoczqtjcfl2Rb4A2ucoQU40-cWtDOYjtP-yY4,7680
8
- oh_my_batch/job.py,sha256=z4iOydxzDNG_L3rgDa4qUVsRAH4L-GOk_RSxCx4GLNA,6035
8
+ oh_my_batch/job.py,sha256=_fETBYpuSd_hNHKnXSwYcSU3OXtU7PO-P2QMfhE-Wfs,5788
9
9
  oh_my_batch/util.py,sha256=H8B4zVNH5xRp-NG_uypgvtmz2YSpXy_6LK5ROv6SYrc,2116
10
- oh_my_batch-0.1.0.dev1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
11
- oh_my_batch-0.1.0.dev1.dist-info/METADATA,sha256=yTzn4_dXZIJG2iZhJwFGxatYupAPUWUlyN-ciQZfWQw,4456
12
- oh_my_batch-0.1.0.dev1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
- oh_my_batch-0.1.0.dev1.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
14
- oh_my_batch-0.1.0.dev1.dist-info/RECORD,,
10
+ oh_my_batch-0.1.0.dev3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
11
+ oh_my_batch-0.1.0.dev3.dist-info/METADATA,sha256=sFfJrqAmymhuKZIv4-ydeDX6Y3oby3NWVfiPjQPUAUM,4453
12
+ oh_my_batch-0.1.0.dev3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
13
+ oh_my_batch-0.1.0.dev3.dist-info/entry_points.txt,sha256=ZY2GutSoNjjSyJ4qO2pTeseKUFgoTYdvmgkuZZkwi68,77
14
+ oh_my_batch-0.1.0.dev3.dist-info/RECORD,,