cmd-queue 0.1.12__py3-none-any.whl → 0.1.14__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.

Potentially problematic release.


This version of cmd-queue might be problematic. Click here for more details.

cmd_queue/__init__.py CHANGED
@@ -1,8 +1,16 @@
1
1
  r"""
2
- Simplify chaining of multiple shell commands
2
+ The cmd_queue module is a tool that lets users define a DAG of bash commands.
3
+ This DAG can be executed in a lightweight tmux backend, or a heavyweight slurm
4
+ backend, or in simple serial mode that runs in the foreground thread. Rich
5
+ provides monitoring / live control. For more information see the gitlab
6
+ `README <https://gitlab.kitware.com/computer-vision/cmd_queue>`_.
7
+ There is also a
8
+ `Google slides presentation <https://docs.google.com/presentation/d/1BjJkjMx6bxu1uek-hAGpwj760u9rraVn7st8J5OsZME>`_
9
+ that gives a high level overview.
10
+
11
+ The following examples show how to use the cmd_queue API in Python. For
12
+ examples of the Bash API see: :mod:`cmd_queue.__main__`.
3
13
 
4
- Serves as a frontend for several DAG backends, including our own custom tmux
5
- queue. We also support slurm and will soon support airflow.
6
14
 
7
15
  Example:
8
16
  >>> # The available backends classmethod lets you know which backends
@@ -295,7 +303,7 @@ Example:
295
303
  __mkinit__ = """
296
304
  mkinit -m cmd_queue
297
305
  """
298
- __version__ = '0.1.12'
306
+ __version__ = '0.1.14'
299
307
 
300
308
 
301
309
  __submodules__ = {
cmd_queue/__main__.py CHANGED
@@ -1,5 +1,15 @@
1
1
  #!/usr/bin/env python3
2
2
  # PYTHON_ARGCOMPLETE_OK
3
+ """
4
+ This is the main script for the cmd_queue CLI. The :class:`CmdQueueConfig`
5
+ defines the available options and its docstring provides a quick tutorial.
6
+ For help run:
7
+
8
+ .. code:: bash
9
+
10
+ cmd_queue --help
11
+
12
+ """
3
13
  import scriptconfig as scfg
4
14
  import ubelt as ub
5
15
 
@@ -12,13 +22,12 @@ class CmdQueueConfig(scfg.DataConfig):
12
22
  Most behaviors are related to creating and submitting custom queues.
13
23
 
14
24
  The ``cleanup`` action is for helping to manage the tmux backend, maingly
15
- killing session names that start with "cmdq_".
25
+ killing session names that start with ``"cmdq_"``.
16
26
 
17
- Example:
27
+ Step 1: Initialize a new queue
28
+ ###############################
18
29
 
19
- #################################
20
- # Step 1: Initialize a new queue
21
- #################################
30
+ .. code:: bash
22
31
 
23
32
  cmd_queue new "my_cli_queue"
24
33
 
@@ -32,9 +41,10 @@ class CmdQueueConfig(scfg.DataConfig):
32
41
  # e.g. for pyenv
33
42
  cmd_queue new "my_cli_queue" --header="pyenv shell 3.11.0 && source $PYENV_ROOT/versions/3.11.0/envs/pyenv3.11.0/bin/activate"
34
43
 
35
- #################################
36
- # Step 2: Initialize a new queue
37
- #################################
44
+ Step 2: Initialize a new queue
45
+ ###############################
46
+
47
+ .. code:: bash
38
48
 
39
49
  cmd_queue submit "my_cli_queue" -- echo hello world
40
50
  cmd_queue submit "my_cli_queue" -- echo "hello world"
@@ -45,14 +55,17 @@ class CmdQueueConfig(scfg.DataConfig):
45
55
  cmd_queue submit "my_cli_queue" -- 'cowsay MOOOOOO && sleep 3'
46
56
  cmd_queue submit "my_cli_queue" -- 'cowsay MOOOOOOOO && sleep 4'
47
57
 
48
- #################################
49
- # Step 3: Inspect your commands before you run
50
- #################################
58
+ Step 3: Inspect your commands before you run
59
+ #############################################
60
+
61
+ .. code:: bash
62
+
51
63
  cmd_queue show "my_cli_queue"
52
64
 
53
- #################################
54
- # Step 4: Run your commands
55
- #################################
65
+ Step 4: Run your commands
66
+ ##########################
67
+
68
+ .. code:: bash
56
69
 
57
70
  # Run using the serial backend
58
71
  cmd_queue run "my_cli_queue" --backend=serial
@@ -60,9 +73,10 @@ class CmdQueueConfig(scfg.DataConfig):
60
73
  # Run using the tmux backend
61
74
  cmd_queue run "my_cli_queue" --backend=tmux --workers=2
62
75
 
63
- #################################
64
- # Extra: other features
65
- #################################
76
+ Extra: other features
77
+ #####################
78
+
79
+ .. code:: bash
66
80
 
67
81
  # List all the known queues you've created
68
82
  cmd_queue list
@@ -99,7 +113,7 @@ class CmdQueueConfig(scfg.DataConfig):
99
113
  '''
100
114
  ))
101
115
 
102
- def normalize(config):
116
+ def __post_init__(config):
103
117
  if config['dpath'] == 'auto':
104
118
  config['dpath'] = str(ub.Path.appdir('cmd_queue/cli'))
105
119
 
@@ -109,8 +123,7 @@ def main(cmdline=1, **kwargs):
109
123
  Example:
110
124
  >>> # xdoctest: +SKIP
111
125
  >>> cmdline = 0
112
- >>> kwargs = dict(
113
- >>> )
126
+ >>> kwargs = dict()
114
127
  >>> main(cmdline=cmdline, **kwargs)
115
128
  """
116
129
  import json
@@ -131,7 +131,7 @@ class CMDQueueConfig(scfg.DataConfig):
131
131
  Command to start the appropriate virtual environment if your bashrc
132
132
  does not start it by default.'''), group='cmd-queue')
133
133
 
134
- tmux_workers = scfg.Value(4, help='number of tmux workers in the queue for the tmux backend', group='cmd-queue')
134
+ tmux_workers = scfg.Value(8, help='number of tmux workers in the queue for the tmux backend', group='cmd-queue')
135
135
 
136
136
  slurm_options = scfg.Value(None, help='if the backend is slurm, provide a YAML dictionary for things like partition / etc...', group='cmd-queue')
137
137
 
cmd_queue/tmux_queue.py CHANGED
@@ -54,7 +54,6 @@ import uuid
54
54
 
55
55
  from cmd_queue import base_queue
56
56
  from cmd_queue import serial_queue
57
- from cmd_queue.util import util_tags
58
57
  from cmd_queue.util.util_tmux import tmux
59
58
 
60
59
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cmd-queue
3
- Version: 0.1.12
3
+ Version: 0.1.14
4
4
  Summary: The cmd_queue module for a DAG of bash commands
5
5
  Home-page: https://gitlab.kitware.com/computer-vision/cmd_queue
6
6
  Author: Kitware Inc., Jon Crall
@@ -49,7 +49,7 @@ Requires-Dist: xdoctest ; extra == 'all'
49
49
  Provides-Extra: all-strict
50
50
  Requires-Dist: ubelt (==1.2.3) ; extra == 'all-strict'
51
51
  Requires-Dist: rich (==12.5.1) ; extra == 'all-strict'
52
- Requires-Dist: scriptconfig (==0.7.7) ; extra == 'all-strict'
52
+ Requires-Dist: scriptconfig (==0.7.8) ; extra == 'all-strict'
53
53
  Requires-Dist: psutil (==5.9.1) ; extra == 'all-strict'
54
54
  Requires-Dist: ruamel.yaml (==0.17.21) ; extra == 'all-strict'
55
55
  Requires-Dist: xdoctest (==1.0.1) ; extra == 'all-strict'
@@ -106,7 +106,7 @@ Requires-Dist: textual ; (python_version >= "3.7") and extra == 'optional'
106
106
  Provides-Extra: runtime-strict
107
107
  Requires-Dist: ubelt (==1.2.3) ; extra == 'runtime-strict'
108
108
  Requires-Dist: rich (==12.5.1) ; extra == 'runtime-strict'
109
- Requires-Dist: scriptconfig (==0.7.7) ; extra == 'runtime-strict'
109
+ Requires-Dist: scriptconfig (==0.7.8) ; extra == 'runtime-strict'
110
110
  Requires-Dist: psutil (==5.9.1) ; extra == 'runtime-strict'
111
111
  Requires-Dist: ruamel.yaml (==0.17.21) ; extra == 'runtime-strict'
112
112
  Requires-Dist: numpy (==1.19.3) ; (python_version < "3.10" and python_version >= "3.6.0") and extra == 'runtime-strict'
@@ -147,17 +147,15 @@ Requires-Dist: pytest ; (python_version >= "3.7") and extra == 'tests'
147
147
  Command Queue - cmd_queue
148
148
  =========================
149
149
 
150
- .. .. |GitlabCIPipeline| |GitlabCICoverage| |Appveyor| |Codecov|
150
+ .. .. |GitlabCIPipeline| |GitlabCICoverage| |Appveyor| |Codecov|
151
151
 
152
152
  |Pypi| |Downloads| |ReadTheDocs|
153
153
 
154
154
 
155
- .. The ``cmd_queue`` module.
156
-
157
155
  +------------------+-------------------------------------------------------------------------------------+
158
156
  | Read the docs | https://cmd_queue.readthedocs.io |
159
157
  +------------------+-------------------------------------------------------------------------------------+
160
- | Github | https://github.com/Erotemic/cmd_queue |
158
+ | Gitlab | https://gitlab.kitware.com/computer-vision/cmd_queue |
161
159
  +------------------+-------------------------------------------------------------------------------------+
162
160
  | Pypi | https://pypi.org/project/cmd_queue |
163
161
  +------------------+-------------------------------------------------------------------------------------+
@@ -170,13 +168,13 @@ jobs (in parallel if possible) on a single machine. There are 3 backends with
170
168
  increasing levels of complexity: serial, tmux, and slurm.
171
169
 
172
170
  In serial mode, a single bash script gets written that executes your jobs in
173
- sequence. There are no external dependencies
171
+ sequence. There are no external dependencies
174
172
 
175
173
  In tmux mode, multiple tmux sessions get opened and each of them executes your
176
174
  independent parts of your jobs. Dependencies are handled.
177
175
 
178
176
  In slurm mode, a real heavy-weight scheduling algorithm is used. In this mode
179
- we simply convert your jobs to slurm commands and execute them.
177
+ we simply convert your jobs to slurm commands and execute them.
180
178
 
181
179
  Under the hood we build a DAG based on your specified dependencies and use this
182
180
  to appropriately order jobs.
@@ -185,15 +183,54 @@ By default, bash scripts that would execute your jobs print to the console.
185
183
  This gives the user fine-grained control if they only want to run a subset of a
186
184
  pipeline manually. But if asked to run, cmd_queue will execute the bash jobs.
187
185
 
186
+ Features
187
+ ~~~~~~~~
188
+
189
+ * Bash command scheduling
190
+
191
+ * Execution is optional, can just print commands instead
192
+
193
+ * No-parallelism always-available serial backend
194
+
195
+ * Tmux based lightweight backend
196
+
197
+ * Slurm based heavyweight backend
198
+
199
+ * Python and Bash interface
200
+
201
+ * Rich monitoring / live-control
202
+
203
+
204
+ Installation
205
+ ============
206
+
207
+ The cmd_queue package is available on pypi.
208
+
209
+ .. code:: bash
210
+
211
+ pip install cmd_queue
212
+
213
+ The serial queue backend will always work. To gain access other backends you
214
+ must install their associated dependencies. The tmux backend is the easiest and
215
+ simply requires that tmux is installed (e.g. ``sudo apt install tmux`` on
216
+ Debian systems).
217
+
218
+ Other backends require more complex setups. The slurm backend will require that
219
+ `slurm is installed <https://slurm.schedmd.com/quickstart_admin.html>`_ and the
220
+ daemon is running. The slurm backend is functional and tested, but improvements
221
+ can still be made (help wanted). The airflow backend similarly requires a
222
+ configured airflow server, but is not fully functional or tested (contributions
223
+ to make airflow work / easier are wanted!).
224
+
188
225
 
189
226
  Tmux Queue Demo
190
227
  ===============
191
228
 
192
229
  After installing, the following command runs a demo of the tmux queue:
193
230
 
194
- .. code:: bash
231
+ .. code:: bash
195
232
 
196
- # Reproduce the
233
+ # Reproduce the
197
234
  INTERACTIVE_TEST=1 xdoctest -m cmd_queue.tmux_queue TMUXMultiQueue.monitor:1
198
235
 
199
236
 
@@ -221,7 +258,7 @@ submits several bash jobs with non-trivial dependencies.
221
258
  self.print_graph()
222
259
  if self.is_available():
223
260
  self.run(block=True, other_session_handler='kill')
224
-
261
+
225
262
 
226
263
  When running the ``print_commands`` command will first display all of the submitted
227
264
  commands that will be distributed across multiple new tmux sessions. These are
@@ -235,8 +272,8 @@ command templating is correct before the queue is executed with ``run``.
235
272
  :align: left
236
273
 
237
274
 
238
- The ``print_graph`` command will render the DAG to be executed using `network
239
- text <https://github.com/networkx/networkx/pull/5602>`_.
275
+ The ``print_graph`` command will render the DAG to be executed using
276
+ `network text <https://networkx.org/documentation/stable/reference/readwrite/generated/networkx.readwrite.text.write_network_text.html#networkx.readwrite.text.write_network_text>`_.
240
277
  And finally ``run`` is called with ``block=True``, which starts executing the
241
278
  DAG and displays progress and job status in rich or textual monitor.
242
279
 
@@ -255,7 +292,7 @@ While this is running it is possible to simply attach to a tmux sessions (e.g.
255
292
  using ``<ctrl-b>s`` inside of a tmux session to view and navigate through the
256
293
  tmux sessions). Unlike the slurm backend, the entire execution of the DAG is
257
294
  entirely transparent to the developer! The following screenshot shows the tmux
258
- sessions spawned while running this demo.
295
+ sessions spawned while running this demo.
259
296
 
260
297
  .. .. Screenshot of the tmux sessions
261
298
  .. image:: https://i.imgur.com/46LRK8M.png
@@ -327,7 +364,7 @@ use cmd_queue to "transpile" these sequences of commands to pure bash.
327
364
  self.print_commands()
328
365
 
329
366
  # Display the real bash that gets executed under the hood
330
- # that is independencly executable, tracks the success / failure of each job,
367
+ # that is independencly executable, tracks the success / failure of each job,
331
368
  # and manages dependencies.
332
369
  self.print_commands(1, 1)
333
370
 
@@ -336,7 +373,7 @@ use cmd_queue to "transpile" these sequences of commands to pure bash.
336
373
  self.run(block=True)
337
374
 
338
375
 
339
- This prints the bash commands in an appropriate order to resolve dependencies.
376
+ This prints the bash commands in an appropriate order to resolve dependencies.
340
377
 
341
378
 
342
379
  .. code:: bash
@@ -376,7 +413,7 @@ This prints the bash commands in an appropriate order to resolve dependencies.
376
413
  #
377
414
  ### Command 10 / 10 - demo_queue-job-9
378
415
  echo bazbiz && sleep 0.5
379
-
416
+
380
417
 
381
418
 
382
419
  .. code:: python
@@ -399,7 +436,7 @@ This prints the bash commands in an appropriate order to resolve dependencies.
399
436
  self.print_commands()
400
437
 
401
438
  # Display the real bash that gets executed under the hood
402
- # that is independencly executable, tracks the success / failure of each job,
439
+ # that is independencly executable, tracks the success / failure of each job,
403
440
  # and manages dependencies.
404
441
  self.print_commands(1, 1)
405
442
 
@@ -408,8 +445,8 @@ This prints the bash commands in an appropriate order to resolve dependencies.
408
445
  self.run(block=True)
409
446
 
410
447
 
411
- This prints the sequence of bash commands that will be executed in each tmux session.
412
-
448
+ This prints the sequence of bash commands that will be executed in each tmux session.
449
+
413
450
  .. code:: bash
414
451
 
415
452
  # --- /home/joncrall/.cache/base_queue/demo_queue_2022-04-08_a1ef7600/queue_demo_queue_0_2022-04-08_a1ef7600.sh
@@ -503,7 +540,7 @@ options here
503
540
  self.print_commands()
504
541
 
505
542
  # Display the real bash that gets executed under the hood
506
- # that is independencly executable, tracks the success / failure of each job,
543
+ # that is independencly executable, tracks the success / failure of each job,
507
544
  # and manages dependencies.
508
545
  self.print_commands(1, 1)
509
546
 
@@ -513,7 +550,7 @@ options here
513
550
 
514
551
 
515
552
  This prints the very simple slurm submission script:
516
-
553
+
517
554
  .. code:: bash
518
555
 
519
556
  # --- /home/joncrall/.cache/slurm_queue/demo_queue-20220408T170615-a9e238b5/demo_queue-20220408T170615-a9e238b5.sh
@@ -532,36 +569,14 @@ This prints the very simple slurm submission script:
532
569
 
533
570
 
534
571
 
535
- Installation
536
- ============
537
-
538
- The cmd_queue package is available on pypi.
539
-
540
- .. code:: bash
541
-
542
- pip install cmd_queue
543
-
544
- The serial queue backend will always work. To gain access other backends you
545
- must install their associated dependencies. The tmux backend is the easiest and
546
- simply requires that tmux is installed (e.g. ``sudo apt install tmux`` on
547
- Debian systems).
548
-
549
- Other backends require more complex setups. The slurm backend will require that
550
- slurm is installed and the daemon is running. The slurm backend is functional
551
- and tested, but improvements can still be made (help wanted). The airflow
552
- backend similarly requires a configured airflow server, but is not fully
553
- functional or tested (contributions to make airflow work / easier are wanted!).
554
-
555
-
556
-
557
572
  .. |Pypi| image:: https://img.shields.io/pypi/v/cmd_queue.svg
558
573
  :target: https://pypi.python.org/pypi/cmd_queue
559
574
 
560
575
  .. |Downloads| image:: https://img.shields.io/pypi/dm/cmd_queue.svg
561
576
  :target: https://pypistats.org/packages/cmd_queue
562
577
 
563
- .. |ReadTheDocs| image:: https://readthedocs.org/projects/cmd_queue/badge/?version=release
564
- :target: https://cmd_queue.readthedocs.io/en/release/
578
+ .. |ReadTheDocs| image:: https://readthedocs.org/projects/cmd-queue/badge/?version=release
579
+ :target: https://cmd-queue.readthedocs.io/en/release/
565
580
 
566
581
  .. # See: https://ci.appveyor.com/project/jon.crall/cmd_queue/settings/badges
567
582
  .. |Appveyor| image:: https://ci.appveyor.com/api/projects/status/py3s2d6tyfjc8lm3/branch/master?svg=true
@@ -1,12 +1,12 @@
1
- cmd_queue/__init__.py,sha256=GXwocyEx1v1UOQIYLyzMHre_jG1IUsGHeArJTQBbZUM,14386
2
- cmd_queue/__main__.py,sha256=yNgCJADmln3LQxFxBEUcI_EuiqV2NsxQ0F2rYICTYMQ,7170
1
+ cmd_queue/__init__.py,sha256=f2dntM8omHeqviSQ7lmSbsKk-rSam1fHwROXoZC8oNI,14870
2
+ cmd_queue/__main__.py,sha256=zgHtvXbQcpw3R2BXa5EF0BREeBdWJ4INPfSd0kYJ7WU,7192
3
3
  cmd_queue/airflow_queue.py,sha256=zJ86GckW5yXVcy9gCK7dmRlezs7H5ABpUWK7FeVtJSk,10414
4
4
  cmd_queue/base_queue.py,sha256=HQQAqioNn97UCh2qTSumww2zewdip6KEaSkg-FDcucg,13824
5
- cmd_queue/cli_boilerplate.py,sha256=jRL4PQkgCQShzmUj4xZniv5yROKqNjnvWuue-bzV3yY,8430
5
+ cmd_queue/cli_boilerplate.py,sha256=kGeStl6F5uY_sGQoYiYgHfpLN9Di9YymPJdEkS_9Kpc,8430
6
6
  cmd_queue/monitor_app.py,sha256=m0cROUkBvTfpArjdZBfDvBMYnVJKBU_gDiW4HqENm0o,4641
7
7
  cmd_queue/serial_queue.py,sha256=IugMzDoNAT7DaJGTtSlSLqG_T5CApkOybM9SbmOHM2U,26336
8
8
  cmd_queue/slurm_queue.py,sha256=ZnKc4GCVaaTRY6Uj2-9gUzwdpddRt9yFzRuXgbaCAMA,23641
9
- cmd_queue/tmux_queue.py,sha256=sbKooYZO-o8uXMqPteqOE3n98OVg25VwDuiul6ZvwFU,40464
9
+ cmd_queue/tmux_queue.py,sha256=GcY_mnRXADAvAmZLtMIauvUe7fXGgLpr1e4noVIJx3c,40427
10
10
  cmd_queue/util/__init__.py,sha256=QzlId47F1lzuLyeIIJoPGZR3b9ljJl50sFEcJzYWrB8,1450
11
11
  cmd_queue/util/richer.py,sha256=OPXpoXYgdhv_49sskF9FMwj6KCSiNcBo1kNhbuj6hoU,3373
12
12
  cmd_queue/util/texter.py,sha256=I6Fcrk0Yp3QTgbxF8cn8vSZWIkkytGBk3ZD4c1diMM0,2264
@@ -16,9 +16,9 @@ cmd_queue/util/util_networkx.py,sha256=5CV8MCAokAnHneC-_Sg2sQ4MOxkj3KYpRNn_t8kya
16
16
  cmd_queue/util/util_tags.py,sha256=Hlxpel759AduUy3Wdq3fCe-XKjxqBUFCLOr3Mw2bzsw,719
17
17
  cmd_queue/util/util_tmux.py,sha256=vC4xeYZCV8uVAp363zD24ROyKqUAdCynIULNJ8UgLQE,1078
18
18
  cmd_queue/util/util_yaml.py,sha256=uWyENCbjBt-tx7LtkI_JHWnBSe3jbx8d4H7JT1giH0k,9281
19
- cmd_queue-0.1.12.dist-info/LICENSE,sha256=o6jcFk_bwjiPUz6vHK0Ju7RwbFp9eXMwAS2BDnwER-4,11343
20
- cmd_queue-0.1.12.dist-info/METADATA,sha256=oEx0YcGBRyhytsC4QNw4tcKSnkNskaX3IWCgV2WbfVg,28733
21
- cmd_queue-0.1.12.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
22
- cmd_queue-0.1.12.dist-info/entry_points.txt,sha256=HDxa1dTf0Dne-a-QeDu7cWZVYRyEtCvqaau0GCCMEyw,54
23
- cmd_queue-0.1.12.dist-info/top_level.txt,sha256=C2JVEsOZsjnMx3jIAWhIQGWAXjGs-hyBzzjkOIm7qW8,10
24
- cmd_queue-0.1.12.dist-info/RECORD,,
19
+ cmd_queue-0.1.14.dist-info/LICENSE,sha256=o6jcFk_bwjiPUz6vHK0Ju7RwbFp9eXMwAS2BDnwER-4,11343
20
+ cmd_queue-0.1.14.dist-info/METADATA,sha256=v8Ji1ff1gQkXkRrahEB5C185oy9Q7aURFXTkhzq3gQw,29128
21
+ cmd_queue-0.1.14.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
22
+ cmd_queue-0.1.14.dist-info/entry_points.txt,sha256=HDxa1dTf0Dne-a-QeDu7cWZVYRyEtCvqaau0GCCMEyw,54
23
+ cmd_queue-0.1.14.dist-info/top_level.txt,sha256=C2JVEsOZsjnMx3jIAWhIQGWAXjGs-hyBzzjkOIm7qW8,10
24
+ cmd_queue-0.1.14.dist-info/RECORD,,