FlowerPower 1.0.0b2__py3-none-any.whl → 1.0.0b4__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.
- flowerpower/__init__.py +2 -3
- flowerpower/cfg/__init__.py +10 -8
- flowerpower/cfg/pipeline/__init__.py +11 -7
- flowerpower/cfg/project/__init__.py +11 -8
- flowerpower/cfg/project/job_queue.py +10 -29
- flowerpower/cli/__init__.py +62 -28
- flowerpower/cli/job_queue.py +306 -123
- flowerpower/cli/mqtt.py +22 -16
- flowerpower/cli/pipeline.py +294 -114
- flowerpower/flowerpower.py +14 -8
- flowerpower/fs/__init__.py +7 -3
- flowerpower/fs/ext.py +6 -2
- flowerpower/io/base.py +17 -10
- flowerpower/io/loader/_duckdb.py +1 -0
- flowerpower/io/loader/deltatable.py +6 -2
- flowerpower/io/saver/deltatable.py +1 -2
- flowerpower/job_queue/__init__.py +16 -12
- flowerpower/job_queue/apscheduler/__init__.py +1 -1
- flowerpower/job_queue/apscheduler/manager.py +11 -6
- flowerpower/job_queue/apscheduler/utils.py +6 -4
- flowerpower/job_queue/base.py +1 -0
- flowerpower/job_queue/rq/__init__.py +1 -1
- flowerpower/job_queue/rq/manager.py +12 -3
- flowerpower/pipeline/io.py +11 -9
- flowerpower/pipeline/job_queue.py +5 -5
- flowerpower/pipeline/manager.py +35 -27
- flowerpower/pipeline/registry.py +26 -16
- flowerpower/pipeline/runner.py +3 -4
- flowerpower/plugins/mqtt/__init__.py +7 -7
- flowerpower/plugins/mqtt/cfg.py +3 -2
- flowerpower/plugins/mqtt/manager.py +25 -23
- flowerpower/utils/misc.py +6 -4
- flowerpower/utils/templates.py +1 -4
- {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b4.dist-info}/METADATA +1 -1
- {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b4.dist-info}/RECORD +38 -38
- {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b4.dist-info}/WHEEL +0 -0
- {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b4.dist-info}/entry_points.txt +0 -0
- {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b4.dist-info}/top_level.txt +0 -0
flowerpower/cli/job_queue.py
CHANGED
@@ -1,31 +1,49 @@
|
|
1
1
|
import typer
|
2
|
+
from loguru import logger
|
3
|
+
|
2
4
|
from .. import settings
|
3
|
-
from ..job_queue import
|
4
|
-
from .utils import parse_dict_or_list_param
|
5
|
+
from ..job_queue import JobQueueManager # Adjust import as needed
|
5
6
|
from ..utils.logging import setup_logging
|
6
|
-
from
|
7
|
+
from .utils import parse_dict_or_list_param
|
7
8
|
|
8
9
|
# Create a Typer app for job queue management commands
|
9
10
|
app = typer.Typer(help="Job queue management commands")
|
10
11
|
|
11
|
-
setup_logging(
|
12
|
-
|
12
|
+
setup_logging(level=settings.LOG_LEVEL)
|
13
|
+
|
13
14
|
|
14
15
|
@app.command()
|
15
16
|
def start_worker(
|
16
|
-
type: str | None = typer.Option(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
type: str | None = typer.Option(
|
18
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
19
|
+
),
|
20
|
+
name: str | None = typer.Option(
|
21
|
+
None, help="Name of the scheduler configuration to use"
|
22
|
+
),
|
23
|
+
base_dir: str | None = typer.Option(
|
24
|
+
None, help="Base directory for the scheduler configuration"
|
25
|
+
),
|
26
|
+
background: bool = typer.Option(
|
27
|
+
False, "--background", "-b", help="Run the worker in the background"
|
28
|
+
),
|
29
|
+
storage_options: str | None = typer.Option(
|
30
|
+
None, help="Storage options as JSON or key=value pairs"
|
31
|
+
),
|
32
|
+
log_level: str = typer.Option(
|
33
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
34
|
+
),
|
35
|
+
num_workers: int | None = typer.Option(
|
36
|
+
None,
|
37
|
+
"--num-workers",
|
38
|
+
"-n",
|
39
|
+
help="Number of worker processes to start (pool mode)",
|
40
|
+
),
|
23
41
|
):
|
24
42
|
"""
|
25
43
|
Start a worker or worker pool to process jobs.
|
26
44
|
|
27
45
|
This command starts a worker process (or a pool of worker processes) that will
|
28
|
-
execute jobs from the queue. The worker will continue running until stopped
|
46
|
+
execute jobs from the queue. The worker will continue running until stopped
|
29
47
|
or can be run in the background.
|
30
48
|
|
31
49
|
Args:
|
@@ -55,36 +73,51 @@ def start_worker(
|
|
55
73
|
"""
|
56
74
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
57
75
|
|
58
|
-
with
|
59
|
-
type=type,
|
76
|
+
with JobQueueManager(
|
77
|
+
type=type,
|
78
|
+
name=name,
|
79
|
+
base_dir=base_dir,
|
80
|
+
storage_options=parsed_storage_options,
|
81
|
+
log_level=log_level,
|
60
82
|
) as worker:
|
61
83
|
if num_workers:
|
62
84
|
num_workers = worker.cfg.backend.num_workers
|
63
85
|
|
64
86
|
if num_workers and num_workers > 1:
|
65
|
-
worker.start_worker_pool(
|
66
|
-
num_workers=num_workers, background=background
|
67
|
-
)
|
87
|
+
worker.start_worker_pool(num_workers=num_workers, background=background)
|
68
88
|
else:
|
69
|
-
worker.start_worker(
|
70
|
-
|
71
|
-
)
|
89
|
+
worker.start_worker(background=background)
|
90
|
+
|
72
91
|
|
73
92
|
@app.command()
|
74
93
|
def start_scheduler(
|
75
|
-
type: str | None = typer.Option(
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
94
|
+
type: str | None = typer.Option(
|
95
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
96
|
+
),
|
97
|
+
name: str | None = typer.Option(
|
98
|
+
None, help="Name of the scheduler configuration to use"
|
99
|
+
),
|
100
|
+
base_dir: str | None = typer.Option(
|
101
|
+
None, help="Base directory for the scheduler configuration"
|
102
|
+
),
|
103
|
+
background: bool = typer.Option(
|
104
|
+
False, "--background", "-b", help="Run the scheduler in the background"
|
105
|
+
),
|
106
|
+
storage_options: str | None = typer.Option(
|
107
|
+
None, help="Storage options as JSON or key=value pairs"
|
108
|
+
),
|
109
|
+
log_level: str = typer.Option(
|
110
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
111
|
+
),
|
112
|
+
interval: int = typer.Option(
|
113
|
+
60, "--interval", "-i", help="Interval for checking jobs in seconds (RQ only)"
|
114
|
+
),
|
82
115
|
):
|
83
116
|
"""
|
84
117
|
Start the scheduler process for queued jobs.
|
85
|
-
|
118
|
+
|
86
119
|
This command starts a scheduler that manages queued jobs and scheduled tasks.
|
87
|
-
Note that this is only needed for RQ workers, as APScheduler workers have
|
120
|
+
Note that this is only needed for RQ workers, as APScheduler workers have
|
88
121
|
their own built-in scheduler.
|
89
122
|
|
90
123
|
Args:
|
@@ -111,13 +144,19 @@ def start_scheduler(
|
|
111
144
|
"""
|
112
145
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
113
146
|
|
114
|
-
with
|
115
|
-
type=type,
|
147
|
+
with JobQueueManager(
|
148
|
+
type=type,
|
149
|
+
name=name,
|
150
|
+
base_dir=base_dir,
|
151
|
+
storage_options=parsed_storage_options,
|
152
|
+
log_level=log_level,
|
116
153
|
) as worker:
|
117
154
|
if worker.cfg.backend.type != "rq":
|
118
|
-
logger.info(
|
155
|
+
logger.info(
|
156
|
+
f"No scheduler needed for {worker.cfg.backend.type} workers. Skipping."
|
157
|
+
)
|
119
158
|
return
|
120
|
-
|
159
|
+
|
121
160
|
worker.start_scheduler(background=background, interval=interval)
|
122
161
|
|
123
162
|
|
@@ -145,13 +184,13 @@ def start_scheduler(
|
|
145
184
|
# """
|
146
185
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
147
186
|
|
148
|
-
# with
|
187
|
+
# with JobQueueManager(
|
149
188
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
150
189
|
# ) as worker:
|
151
190
|
# if worker.cfg.backend.type != "rq":
|
152
191
|
# logger.info(f"Job cancellation is not supported for {worker.cfg.backend.type} workers. Skipping.")
|
153
192
|
# return
|
154
|
-
|
193
|
+
|
155
194
|
# worker.cancel_all_jobs(queue_name=queue_name)
|
156
195
|
|
157
196
|
# @app.command()
|
@@ -176,27 +215,43 @@ def start_scheduler(
|
|
176
215
|
# """
|
177
216
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
178
217
|
|
179
|
-
# with
|
218
|
+
# with JobQueueManager(
|
180
219
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
181
220
|
# ) as worker:
|
182
221
|
# worker.cancel_all_schedules()
|
183
222
|
|
223
|
+
|
184
224
|
@app.command()
|
185
225
|
def cancel_job(
|
186
226
|
job_id: str = typer.Argument(..., help="ID of the job to cancel"),
|
187
|
-
all: bool = typer.Option(
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
227
|
+
all: bool = typer.Option(
|
228
|
+
False, "--all", "-a", help="Cancel all jobs instead of a specific one"
|
229
|
+
),
|
230
|
+
queue_name: str | None = typer.Option(
|
231
|
+
None,
|
232
|
+
help="Name of the queue (RQ only). If provided with --all, cancels all jobs in the queue",
|
233
|
+
),
|
234
|
+
type: str | None = typer.Option(
|
235
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
236
|
+
),
|
237
|
+
name: str | None = typer.Option(
|
238
|
+
None, help="Name of the scheduler configuration to use"
|
239
|
+
),
|
240
|
+
base_dir: str | None = typer.Option(
|
241
|
+
None, help="Base directory for the scheduler configuration"
|
242
|
+
),
|
243
|
+
storage_options: str | None = typer.Option(
|
244
|
+
None, help="Storage options as JSON or key=value pairs"
|
245
|
+
),
|
246
|
+
log_level: str = typer.Option(
|
247
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
248
|
+
),
|
194
249
|
):
|
195
250
|
"""
|
196
251
|
Cancel a job or multiple jobs in the queue.
|
197
252
|
|
198
253
|
This command stops a job from executing (if it hasn't started yet) or signals
|
199
|
-
it to stop (if already running). Canceling is different from deleting as it
|
254
|
+
it to stop (if already running). Canceling is different from deleting as it
|
200
255
|
maintains the job history but prevents execution.
|
201
256
|
|
202
257
|
Args:
|
@@ -215,28 +270,40 @@ def cancel_job(
|
|
215
270
|
|
216
271
|
# Cancel all jobs in the default queue
|
217
272
|
$ flowerpower job-queue cancel-job --all dummy-id
|
218
|
-
|
273
|
+
|
219
274
|
# Cancel all jobs in a specific queue (RQ only)
|
220
275
|
$ flowerpower job-queue cancel-job --all dummy-id --queue-name high-priority
|
221
|
-
|
276
|
+
|
222
277
|
# Specify the backend type explicitly
|
223
278
|
$ flowerpower job-queue cancel-job job-123456 --type rq
|
224
279
|
"""
|
225
280
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
226
281
|
|
227
|
-
with
|
228
|
-
type=type,
|
282
|
+
with JobQueueManager(
|
283
|
+
type=type,
|
284
|
+
name=name,
|
285
|
+
base_dir=base_dir,
|
286
|
+
storage_options=parsed_storage_options,
|
287
|
+
log_level=log_level,
|
229
288
|
) as worker:
|
230
289
|
if worker.cfg.backend.type != "rq":
|
231
|
-
logger.info(
|
290
|
+
logger.info(
|
291
|
+
f"Job cancellation is not supported for {worker.cfg.backend.type} workers. Skipping."
|
292
|
+
)
|
232
293
|
return
|
233
294
|
if all:
|
234
|
-
count = worker.cancel_all_jobs(
|
235
|
-
|
295
|
+
count = worker.cancel_all_jobs(
|
296
|
+
queue_name=queue_name if worker.cfg.backend.type == "rq" else None
|
297
|
+
)
|
298
|
+
logger.info(
|
299
|
+
f"Cancelled {count} jobs"
|
300
|
+
+ (f" in queue '{queue_name}'" if queue_name else "")
|
301
|
+
)
|
236
302
|
else:
|
237
303
|
worker.cancel_job(job_id)
|
238
304
|
logger.info(f"Job {job_id} cancelled")
|
239
305
|
|
306
|
+
|
240
307
|
@app.command()
|
241
308
|
def cancel_schedule(
|
242
309
|
schedule_id: str,
|
@@ -263,14 +330,19 @@ def cancel_schedule(
|
|
263
330
|
"""
|
264
331
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
265
332
|
|
266
|
-
with
|
267
|
-
type=type,
|
333
|
+
with JobQueueManager(
|
334
|
+
type=type,
|
335
|
+
name=name,
|
336
|
+
base_dir=base_dir,
|
337
|
+
storage_options=parsed_storage_options,
|
338
|
+
log_level=log_level,
|
268
339
|
) as worker:
|
269
340
|
if all:
|
270
341
|
worker.cancel_all_schedules()
|
271
342
|
else:
|
272
343
|
worker.cancel_schedule(schedule_id)
|
273
344
|
|
345
|
+
|
274
346
|
# @app.command()
|
275
347
|
# def delete_all_jobs(
|
276
348
|
# type: str | None = None,
|
@@ -293,7 +365,7 @@ def cancel_schedule(
|
|
293
365
|
# """
|
294
366
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
295
367
|
|
296
|
-
# with
|
368
|
+
# with JobQueueManager(
|
297
369
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
298
370
|
# ) as worker:
|
299
371
|
# worker.delete_all_jobs(queue_name=queue_name if worker.cfg.backend.type == "rq" else None)
|
@@ -317,11 +389,12 @@ def cancel_schedule(
|
|
317
389
|
# """
|
318
390
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
319
391
|
|
320
|
-
# with
|
392
|
+
# with JobQueueManager(
|
321
393
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
322
394
|
# ) as worker:
|
323
395
|
# worker.delete_all_schedules()
|
324
396
|
|
397
|
+
|
325
398
|
@app.command()
|
326
399
|
def delete_job(
|
327
400
|
job_id: str,
|
@@ -348,14 +421,20 @@ def delete_job(
|
|
348
421
|
"""
|
349
422
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
350
423
|
|
351
|
-
with
|
352
|
-
type=type,
|
424
|
+
with JobQueueManager(
|
425
|
+
type=type,
|
426
|
+
name=name,
|
427
|
+
base_dir=base_dir,
|
428
|
+
storage_options=parsed_storage_options,
|
429
|
+
log_level=log_level,
|
353
430
|
) as worker:
|
354
431
|
if all:
|
355
|
-
worker.delete_all_jobs(
|
432
|
+
worker.delete_all_jobs(
|
433
|
+
queue_name=queue_name if worker.cfg.backend.type == "rq" else None
|
434
|
+
)
|
356
435
|
else:
|
357
436
|
worker.delete_job(job_id)
|
358
|
-
|
437
|
+
|
359
438
|
|
360
439
|
@app.command()
|
361
440
|
def delete_schedule(
|
@@ -381,14 +460,19 @@ def delete_schedule(
|
|
381
460
|
"""
|
382
461
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
383
462
|
|
384
|
-
with
|
385
|
-
type=type,
|
463
|
+
with JobQueueManager(
|
464
|
+
type=type,
|
465
|
+
name=name,
|
466
|
+
base_dir=base_dir,
|
467
|
+
storage_options=parsed_storage_options,
|
468
|
+
log_level=log_level,
|
386
469
|
) as worker:
|
387
470
|
if all:
|
388
471
|
worker.delete_all_schedules()
|
389
472
|
else:
|
390
473
|
worker.delete_schedule(schedule_id)
|
391
474
|
|
475
|
+
|
392
476
|
# @app.command()
|
393
477
|
# def get_job(
|
394
478
|
# job_id: str,
|
@@ -410,7 +494,7 @@ def delete_schedule(
|
|
410
494
|
# """
|
411
495
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
412
496
|
|
413
|
-
# with
|
497
|
+
# with JobQueueManager(
|
414
498
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
415
499
|
# ) as worker:
|
416
500
|
# # show_jobs should display the job info
|
@@ -439,7 +523,7 @@ def delete_schedule(
|
|
439
523
|
# """
|
440
524
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
441
525
|
|
442
|
-
# with
|
526
|
+
# with JobQueueManager(
|
443
527
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
444
528
|
# ) as worker:
|
445
529
|
# # worker's get_job_result method will handle the result display
|
@@ -466,7 +550,7 @@ def delete_schedule(
|
|
466
550
|
# """
|
467
551
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
468
552
|
|
469
|
-
# with
|
553
|
+
# with JobQueueManager(
|
470
554
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
471
555
|
# ) as worker:
|
472
556
|
# worker.show_jobs()
|
@@ -492,7 +576,7 @@ def delete_schedule(
|
|
492
576
|
# """
|
493
577
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
494
578
|
|
495
|
-
# with
|
579
|
+
# with JobQueueManager(
|
496
580
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
497
581
|
# ) as worker:
|
498
582
|
# # show_schedule should display the schedule info
|
@@ -517,18 +601,29 @@ def delete_schedule(
|
|
517
601
|
# """
|
518
602
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
519
603
|
|
520
|
-
# with
|
604
|
+
# with JobQueueManager(
|
521
605
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
522
606
|
# ) as worker:
|
523
607
|
# worker.show_schedules()
|
524
608
|
|
609
|
+
|
525
610
|
@app.command()
|
526
611
|
def show_job_ids(
|
527
|
-
type: str | None = typer.Option(
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
612
|
+
type: str | None = typer.Option(
|
613
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
614
|
+
),
|
615
|
+
name: str | None = typer.Option(
|
616
|
+
None, help="Name of the scheduler configuration to use"
|
617
|
+
),
|
618
|
+
base_dir: str | None = typer.Option(
|
619
|
+
None, help="Base directory for the scheduler configuration"
|
620
|
+
),
|
621
|
+
storage_options: str | None = typer.Option(
|
622
|
+
None, help="Storage options as JSON or key=value pairs"
|
623
|
+
),
|
624
|
+
log_level: str = typer.Option(
|
625
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
626
|
+
),
|
532
627
|
):
|
533
628
|
"""
|
534
629
|
Show all job IDs in the job queue.
|
@@ -558,8 +653,12 @@ def show_job_ids(
|
|
558
653
|
"""
|
559
654
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
560
655
|
|
561
|
-
with
|
562
|
-
type=type,
|
656
|
+
with JobQueueManager(
|
657
|
+
type=type,
|
658
|
+
name=name,
|
659
|
+
base_dir=base_dir,
|
660
|
+
storage_options=parsed_storage_options,
|
661
|
+
log_level=log_level,
|
563
662
|
) as worker:
|
564
663
|
# worker's job_ids property will print the IDs
|
565
664
|
ids = worker.job_ids
|
@@ -574,16 +673,26 @@ def show_job_ids(
|
|
574
673
|
|
575
674
|
@app.command()
|
576
675
|
def show_schedule_ids(
|
577
|
-
type: str | None = typer.Option(
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
676
|
+
type: str | None = typer.Option(
|
677
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
678
|
+
),
|
679
|
+
name: str | None = typer.Option(
|
680
|
+
None, help="Name of the scheduler configuration to use"
|
681
|
+
),
|
682
|
+
base_dir: str | None = typer.Option(
|
683
|
+
None, help="Base directory for the scheduler configuration"
|
684
|
+
),
|
685
|
+
storage_options: str | None = typer.Option(
|
686
|
+
None, help="Storage options as JSON or key=value pairs"
|
687
|
+
),
|
688
|
+
log_level: str = typer.Option(
|
689
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
690
|
+
),
|
582
691
|
):
|
583
692
|
"""
|
584
693
|
Show all schedule IDs in the job queue.
|
585
694
|
|
586
|
-
This command displays all schedule IDs currently in the system, helping you
|
695
|
+
This command displays all schedule IDs currently in the system, helping you
|
587
696
|
identify schedules for other operations like pausing, resuming, or deleting schedules.
|
588
697
|
|
589
698
|
Args:
|
@@ -608,8 +717,12 @@ def show_schedule_ids(
|
|
608
717
|
"""
|
609
718
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
610
719
|
|
611
|
-
with
|
612
|
-
type=type,
|
720
|
+
with JobQueueManager(
|
721
|
+
type=type,
|
722
|
+
name=name,
|
723
|
+
base_dir=base_dir,
|
724
|
+
storage_options=parsed_storage_options,
|
725
|
+
log_level=log_level,
|
613
726
|
) as worker:
|
614
727
|
# worker's schedule_ids property will print the IDs
|
615
728
|
ids = worker.schedule_ids
|
@@ -621,6 +734,7 @@ def show_schedule_ids(
|
|
621
734
|
for schedule_id in ids:
|
622
735
|
print(f"- {schedule_id}")
|
623
736
|
|
737
|
+
|
624
738
|
# @app.command()
|
625
739
|
# def pause_all_schedules(
|
626
740
|
# type: str | None = None,
|
@@ -642,7 +756,7 @@ def show_schedule_ids(
|
|
642
756
|
# """
|
643
757
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
644
758
|
|
645
|
-
# with
|
759
|
+
# with JobQueueManager(
|
646
760
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
647
761
|
# ) as worker:
|
648
762
|
# if worker.cfg.backend.type != "apscheduler":
|
@@ -650,21 +764,34 @@ def show_schedule_ids(
|
|
650
764
|
# return
|
651
765
|
# worker.pause_all_schedules()
|
652
766
|
|
767
|
+
|
653
768
|
@app.command()
|
654
769
|
def pause_schedule(
|
655
770
|
schedule_id: str = typer.Argument(..., help="ID of the schedule to pause"),
|
656
|
-
all: bool = typer.Option(
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
771
|
+
all: bool = typer.Option(
|
772
|
+
False, "--all", "-a", help="Pause all schedules instead of a specific one"
|
773
|
+
),
|
774
|
+
type: str | None = typer.Option(
|
775
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
776
|
+
),
|
777
|
+
name: str | None = typer.Option(
|
778
|
+
None, help="Name of the scheduler configuration to use"
|
779
|
+
),
|
780
|
+
base_dir: str | None = typer.Option(
|
781
|
+
None, help="Base directory for the scheduler configuration"
|
782
|
+
),
|
783
|
+
storage_options: str | None = typer.Option(
|
784
|
+
None, help="Storage options as JSON or key=value pairs"
|
785
|
+
),
|
786
|
+
log_level: str = typer.Option(
|
787
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
788
|
+
),
|
662
789
|
):
|
663
790
|
"""
|
664
791
|
Pause a schedule or multiple schedules.
|
665
792
|
|
666
793
|
This command temporarily stops a scheduled job from running while maintaining its
|
667
|
-
configuration. Paused schedules can be resumed later. Note that this functionality
|
794
|
+
configuration. Paused schedules can be resumed later. Note that this functionality
|
668
795
|
is only available for APScheduler workers.
|
669
796
|
|
670
797
|
Args:
|
@@ -682,17 +809,23 @@ def pause_schedule(
|
|
682
809
|
|
683
810
|
# Pause all schedules
|
684
811
|
$ flowerpower job-queue pause-schedule --all dummy-id
|
685
|
-
|
812
|
+
|
686
813
|
# Specify the backend type explicitly
|
687
814
|
$ flowerpower job-queue pause-schedule schedule-123456 --type apscheduler
|
688
815
|
"""
|
689
816
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
690
817
|
|
691
|
-
with
|
692
|
-
type=type,
|
818
|
+
with JobQueueManager(
|
819
|
+
type=type,
|
820
|
+
name=name,
|
821
|
+
base_dir=base_dir,
|
822
|
+
storage_options=parsed_storage_options,
|
823
|
+
log_level=log_level,
|
693
824
|
) as worker:
|
694
825
|
if worker.cfg.backend.type != "apscheduler":
|
695
|
-
logger.info(
|
826
|
+
logger.info(
|
827
|
+
f"Schedule pausing is not supported for {worker.cfg.backend.type} workers."
|
828
|
+
)
|
696
829
|
return
|
697
830
|
if all:
|
698
831
|
count = worker.pause_all_schedules()
|
@@ -726,7 +859,7 @@ def pause_schedule(
|
|
726
859
|
# """
|
727
860
|
# parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
728
861
|
|
729
|
-
# with
|
862
|
+
# with JobQueueManager(
|
730
863
|
# type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
|
731
864
|
# ) as worker:
|
732
865
|
# if worker.cfg.backend.type != "apscheduler":
|
@@ -734,21 +867,34 @@ def pause_schedule(
|
|
734
867
|
# return
|
735
868
|
# worker.resume_all_schedules()
|
736
869
|
|
870
|
+
|
737
871
|
@app.command()
|
738
872
|
def resume_schedule(
|
739
873
|
schedule_id: str = typer.Argument(..., help="ID of the schedule to resume"),
|
740
|
-
all: bool = typer.Option(
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
874
|
+
all: bool = typer.Option(
|
875
|
+
False, "--all", "-a", help="Resume all schedules instead of a specific one"
|
876
|
+
),
|
877
|
+
type: str | None = typer.Option(
|
878
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
879
|
+
),
|
880
|
+
name: str | None = typer.Option(
|
881
|
+
None, help="Name of the scheduler configuration to use"
|
882
|
+
),
|
883
|
+
base_dir: str | None = typer.Option(
|
884
|
+
None, help="Base directory for the scheduler configuration"
|
885
|
+
),
|
886
|
+
storage_options: str | None = typer.Option(
|
887
|
+
None, help="Storage options as JSON or key=value pairs"
|
888
|
+
),
|
889
|
+
log_level: str = typer.Option(
|
890
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
891
|
+
),
|
746
892
|
):
|
747
893
|
"""
|
748
894
|
Resume a paused schedule or multiple schedules.
|
749
895
|
|
750
896
|
This command restarts previously paused schedules, allowing them to run again according
|
751
|
-
to their original configuration. Note that this functionality is only available for
|
897
|
+
to their original configuration. Note that this functionality is only available for
|
752
898
|
APScheduler workers.
|
753
899
|
|
754
900
|
Args:
|
@@ -766,20 +912,26 @@ def resume_schedule(
|
|
766
912
|
|
767
913
|
# Resume all schedules
|
768
914
|
$ flowerpower job-queue resume-schedule --all dummy-id
|
769
|
-
|
915
|
+
|
770
916
|
# Specify the backend type explicitly
|
771
917
|
$ flowerpower job-queue resume-schedule schedule-123456 --type apscheduler
|
772
|
-
|
918
|
+
|
773
919
|
# Set a specific logging level
|
774
920
|
$ flowerpower job-queue resume-schedule schedule-123456 --log-level debug
|
775
921
|
"""
|
776
922
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
777
923
|
|
778
|
-
with
|
779
|
-
type=type,
|
924
|
+
with JobQueueManager(
|
925
|
+
type=type,
|
926
|
+
name=name,
|
927
|
+
base_dir=base_dir,
|
928
|
+
storage_options=parsed_storage_options,
|
929
|
+
log_level=log_level,
|
780
930
|
) as worker:
|
781
931
|
if worker.cfg.backend.type != "apscheduler":
|
782
|
-
logger.info(
|
932
|
+
logger.info(
|
933
|
+
f"Schedule resuming is not supported for {worker.cfg.backend.type} workers."
|
934
|
+
)
|
783
935
|
return
|
784
936
|
if all:
|
785
937
|
count = worker.resume_all_schedules()
|
@@ -791,14 +943,27 @@ def resume_schedule(
|
|
791
943
|
else:
|
792
944
|
logger.error(f"Failed to resume schedule {schedule_id}")
|
793
945
|
|
946
|
+
|
794
947
|
@app.command()
|
795
948
|
def show_jobs(
|
796
|
-
type: str | None = typer.Option(
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
949
|
+
type: str | None = typer.Option(
|
950
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
951
|
+
),
|
952
|
+
queue_name: str | None = typer.Option(
|
953
|
+
None, help="Name of the queue to show jobs from (RQ only)"
|
954
|
+
),
|
955
|
+
name: str | None = typer.Option(
|
956
|
+
None, help="Name of the scheduler configuration to use"
|
957
|
+
),
|
958
|
+
base_dir: str | None = typer.Option(
|
959
|
+
None, help="Base directory for the scheduler configuration"
|
960
|
+
),
|
961
|
+
storage_options: str | None = typer.Option(
|
962
|
+
None, help="Storage options as JSON or key=value pairs"
|
963
|
+
),
|
964
|
+
log_level: str = typer.Option(
|
965
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
966
|
+
),
|
802
967
|
format: str = typer.Option("table", help="Output format (table, json, yaml)"),
|
803
968
|
):
|
804
969
|
"""
|
@@ -831,18 +996,33 @@ def show_jobs(
|
|
831
996
|
"""
|
832
997
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
833
998
|
|
834
|
-
with
|
835
|
-
type=type,
|
999
|
+
with JobQueueManager(
|
1000
|
+
type=type,
|
1001
|
+
name=name,
|
1002
|
+
base_dir=base_dir,
|
1003
|
+
storage_options=parsed_storage_options,
|
1004
|
+
log_level=log_level,
|
836
1005
|
) as worker:
|
837
1006
|
worker.show_jobs(queue_name=queue_name, format=format)
|
838
1007
|
|
1008
|
+
|
839
1009
|
@app.command()
|
840
1010
|
def show_schedules(
|
841
|
-
type: str | None = typer.Option(
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
1011
|
+
type: str | None = typer.Option(
|
1012
|
+
None, help="Type of job queue backend (rq, apscheduler)"
|
1013
|
+
),
|
1014
|
+
name: str | None = typer.Option(
|
1015
|
+
None, help="Name of the scheduler configuration to use"
|
1016
|
+
),
|
1017
|
+
base_dir: str | None = typer.Option(
|
1018
|
+
None, help="Base directory for the scheduler configuration"
|
1019
|
+
),
|
1020
|
+
storage_options: str | None = typer.Option(
|
1021
|
+
None, help="Storage options as JSON or key=value pairs"
|
1022
|
+
),
|
1023
|
+
log_level: str = typer.Option(
|
1024
|
+
"info", help="Logging level (debug, info, warning, error, critical)"
|
1025
|
+
),
|
846
1026
|
format: str = typer.Option("table", help="Output format (table, json, yaml)"),
|
847
1027
|
):
|
848
1028
|
"""
|
@@ -871,8 +1051,11 @@ def show_schedules(
|
|
871
1051
|
"""
|
872
1052
|
parsed_storage_options = parse_dict_or_list_param(storage_options, "dict") or {}
|
873
1053
|
|
874
|
-
with
|
875
|
-
type=type,
|
1054
|
+
with JobQueueManager(
|
1055
|
+
type=type,
|
1056
|
+
name=name,
|
1057
|
+
base_dir=base_dir,
|
1058
|
+
storage_options=parsed_storage_options,
|
1059
|
+
log_level=log_level,
|
876
1060
|
) as worker:
|
877
1061
|
worker.show_schedules(format=format)
|
878
|
-
|