FlowerPower 1.0.0b2__py3-none-any.whl → 1.0.0b3__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.
Files changed (38) hide show
  1. flowerpower/__init__.py +2 -3
  2. flowerpower/cfg/__init__.py +10 -8
  3. flowerpower/cfg/pipeline/__init__.py +11 -7
  4. flowerpower/cfg/project/__init__.py +11 -8
  5. flowerpower/cfg/project/job_queue.py +10 -29
  6. flowerpower/cli/__init__.py +62 -28
  7. flowerpower/cli/job_queue.py +306 -123
  8. flowerpower/cli/mqtt.py +22 -16
  9. flowerpower/cli/pipeline.py +294 -114
  10. flowerpower/flowerpower.py +14 -8
  11. flowerpower/fs/__init__.py +7 -3
  12. flowerpower/fs/ext.py +6 -2
  13. flowerpower/io/base.py +17 -10
  14. flowerpower/io/loader/_duckdb.py +1 -0
  15. flowerpower/io/loader/deltatable.py +6 -2
  16. flowerpower/io/saver/deltatable.py +1 -2
  17. flowerpower/job_queue/__init__.py +16 -12
  18. flowerpower/job_queue/apscheduler/__init__.py +1 -1
  19. flowerpower/job_queue/apscheduler/manager.py +11 -6
  20. flowerpower/job_queue/apscheduler/utils.py +6 -4
  21. flowerpower/job_queue/base.py +1 -0
  22. flowerpower/job_queue/rq/__init__.py +1 -1
  23. flowerpower/job_queue/rq/manager.py +12 -3
  24. flowerpower/pipeline/io.py +11 -9
  25. flowerpower/pipeline/job_queue.py +5 -5
  26. flowerpower/pipeline/manager.py +35 -27
  27. flowerpower/pipeline/registry.py +26 -16
  28. flowerpower/pipeline/runner.py +3 -4
  29. flowerpower/plugins/mqtt/__init__.py +7 -7
  30. flowerpower/plugins/mqtt/cfg.py +3 -2
  31. flowerpower/plugins/mqtt/manager.py +25 -23
  32. flowerpower/utils/misc.py +6 -4
  33. flowerpower/utils/templates.py +1 -4
  34. {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b3.dist-info}/METADATA +1 -1
  35. {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b3.dist-info}/RECORD +38 -38
  36. {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b3.dist-info}/WHEEL +0 -0
  37. {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b3.dist-info}/entry_points.txt +0 -0
  38. {flowerpower-1.0.0b2.dist-info → flowerpower-1.0.0b3.dist-info}/top_level.txt +0 -0
@@ -1,31 +1,49 @@
1
1
  import typer
2
+ from loguru import logger
3
+
2
4
  from .. import settings
3
- from ..job_queue import JobQueue # Adjust import as needed
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 loguru import logger
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
- level=settings.LOG_LEVEL)
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(None, help="Type of job queue backend (rq, apscheduler)"),
17
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
18
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
19
- background: bool = typer.Option(False, "--background", "-b", help="Run the worker in the background"),
20
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
21
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
22
- num_workers: int | None = typer.Option(None, "--num-workers", "-n", help="Number of worker processes to start (pool mode)"),
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 JobQueue(
59
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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
- background=background
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(None, help="Type of job queue backend (rq, apscheduler)"),
76
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
77
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
78
- background: bool = typer.Option(False, "--background", "-b", help="Run the scheduler in the background"),
79
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
80
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
81
- interval: int = typer.Option(60, "--interval", "-i", help="Interval for checking jobs in seconds (RQ only)"),
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 JobQueue(
115
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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(f"No scheduler needed for {worker.cfg.backend.type} workers. Skipping.")
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 JobQueue(
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 JobQueue(
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(False, "--all", "-a", help="Cancel all jobs instead of a specific one"),
188
- queue_name: str | None = typer.Option(None, help="Name of the queue (RQ only). If provided with --all, cancels all jobs in the queue"),
189
- type: str | None = typer.Option(None, help="Type of job queue backend (rq, apscheduler)"),
190
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
191
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
192
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
193
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
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 JobQueue(
228
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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(f"Job cancellation is not supported for {worker.cfg.backend.type} workers. Skipping.")
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(queue_name=queue_name if worker.cfg.backend.type == "rq" else None)
235
- logger.info(f"Cancelled {count} jobs" + (f" in queue '{queue_name}'" if queue_name else ""))
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 JobQueue(
267
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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 JobQueue(
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 JobQueue(
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 JobQueue(
352
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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(queue_name=queue_name if worker.cfg.backend.type == "rq" else None)
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 JobQueue(
385
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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 JobQueue(
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 JobQueue(
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 JobQueue(
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 JobQueue(
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 JobQueue(
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(None, help="Type of job queue backend (rq, apscheduler)"),
528
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
529
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
530
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
531
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
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 JobQueue(
562
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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(None, help="Type of job queue backend (rq, apscheduler)"),
578
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
579
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
580
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
581
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
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 JobQueue(
612
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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 JobQueue(
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(False, "--all", "-a", help="Pause all schedules instead of a specific one"),
657
- type: str | None = typer.Option(None, help="Type of job queue backend (rq, apscheduler)"),
658
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
659
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
660
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
661
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
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 JobQueue(
692
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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(f"Schedule pausing is not supported for {worker.cfg.backend.type} workers.")
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 JobQueue(
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(False, "--all", "-a", help="Resume all schedules instead of a specific one"),
741
- type: str | None = typer.Option(None, help="Type of job queue backend (rq, apscheduler)"),
742
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
743
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
744
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
745
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
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 JobQueue(
779
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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(f"Schedule resuming is not supported for {worker.cfg.backend.type} workers.")
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(None, help="Type of job queue backend (rq, apscheduler)"),
797
- queue_name: str | None = typer.Option(None, help="Name of the queue to show jobs from (RQ only)"),
798
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
799
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
800
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
801
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
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 JobQueue(
835
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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(None, help="Type of job queue backend (rq, apscheduler)"),
842
- name: str | None = typer.Option(None, help="Name of the scheduler configuration to use"),
843
- base_dir: str | None = typer.Option(None, help="Base directory for the scheduler configuration"),
844
- storage_options: str | None = typer.Option(None, help="Storage options as JSON or key=value pairs"),
845
- log_level: str = typer.Option("info", help="Logging level (debug, info, warning, error, critical)"),
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 JobQueue(
875
- type=type, name=name, base_dir=base_dir, storage_options=parsed_storage_options, log_level=log_level
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
-