FlowerPower 0.9.0__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 FlowerPower might be problematic. Click here for more details.

Files changed (68) hide show
  1. flowerpower/__init__.py +3 -0
  2. flowerpower/_catalog.py +27 -0
  3. flowerpower/_cfg.py +0 -0
  4. flowerpower/_cli.py +618 -0
  5. flowerpower/cfg/__init__.py +204 -0
  6. flowerpower/cfg/base.py +39 -0
  7. flowerpower/cfg/pipeline/params.py +0 -0
  8. flowerpower/cfg/pipeline/run.py +17 -0
  9. flowerpower/cfg/pipeline/schedule.py +84 -0
  10. flowerpower/cfg/pipeline/tracker.py +14 -0
  11. flowerpower/cfg/project/open_telemetry.py +8 -0
  12. flowerpower/cfg/project/tracker.py +10 -0
  13. flowerpower/cfg/project/worker.py +19 -0
  14. flowerpower/cli/__init__.py +89 -0
  15. flowerpower/cli/cfg.py +44 -0
  16. flowerpower/cli/mqtt.py +18 -0
  17. flowerpower/cli/pipeline.py +529 -0
  18. flowerpower/cli/scheduler.py +308 -0
  19. flowerpower/cli/utils.py +94 -0
  20. flowerpower/event_handler.py +23 -0
  21. flowerpower/flowerpower.py +102 -0
  22. flowerpower/http/api/cfg.py +48 -0
  23. flowerpower/http/api/pipeline.py +407 -0
  24. flowerpower/http/api/scheduler.py +77 -0
  25. flowerpower/http/main.py +70 -0
  26. flowerpower/http/models/pipeline.py +50 -0
  27. flowerpower/http/models/scheduler.py +1 -0
  28. flowerpower/http/setup.py +39 -0
  29. flowerpower/http/ui.py +0 -0
  30. flowerpower/http/utils.py +18 -0
  31. flowerpower/io/base.py +746 -0
  32. flowerpower/io/loader/csv.py +37 -0
  33. flowerpower/io/loader/deltatable.py +78 -0
  34. flowerpower/io/loader/duckdb.py +333 -0
  35. flowerpower/io/loader/json.py +37 -0
  36. flowerpower/io/loader/mqtt.py +98 -0
  37. flowerpower/io/loader/parquet.py +13 -0
  38. flowerpower/io/metadata.py +221 -0
  39. flowerpower/io/saver/csv.py +36 -0
  40. flowerpower/io/saver/deltatable.py +127 -0
  41. flowerpower/io/saver/duckdb.py +261 -0
  42. flowerpower/io/saver/json.py +36 -0
  43. flowerpower/io/saver/mqtt.py +0 -0
  44. flowerpower/io/saver/parquet.py +36 -0
  45. flowerpower/mqtt.py +431 -0
  46. flowerpower/pipeline.py +2302 -0
  47. flowerpower/scheduler.py +676 -0
  48. flowerpower/tui.py +79 -0
  49. flowerpower/utils/_filesystem.py +1366 -0
  50. flowerpower/utils/datastore.py +62 -0
  51. flowerpower/utils/eventbroker.py +125 -0
  52. flowerpower/utils/executor.py +58 -0
  53. flowerpower/utils/filesystem/__init__.py +10 -0
  54. flowerpower/utils/filesystem/base.py +309 -0
  55. flowerpower/utils/filesystem/ext.py +1199 -0
  56. flowerpower/utils/misc.py +243 -0
  57. flowerpower/utils/monkey.py +85 -0
  58. flowerpower/utils/open_telemetry.py +29 -0
  59. flowerpower/utils/polars.py +567 -0
  60. flowerpower/utils/scheduler.py +311 -0
  61. flowerpower/utils/sql.py +241 -0
  62. flowerpower/utils/storage_options.py +259 -0
  63. flowerpower/utils/templates.py +155 -0
  64. flowerpower/utils/trigger.py +139 -0
  65. flowerpower-0.9.0.dist-info/METADATA +549 -0
  66. flowerpower-0.9.0.dist-info/RECORD +68 -0
  67. flowerpower-0.9.0.dist-info/WHEEL +4 -0
  68. flowerpower-0.9.0.dist-info/entry_points.txt +2 -0
@@ -0,0 +1,3 @@
1
+ from .flowerpower import init as init_flowerpower
2
+
3
+ # _ = init()
@@ -0,0 +1,27 @@
1
+ from pathlib import Path
2
+
3
+ from pydala.catalog import Catalog
4
+
5
+
6
+ def load_catalog(namespace: str | None = None, path: str | None = None) -> Catalog:
7
+ """
8
+ Load a catalog from a YAML file.
9
+
10
+ Args:
11
+ namespace (str | None, optional): The namespace of the catalog. Defaults to None.
12
+ path (str | None, optional): The path to the YAML file. If not provided, the function will search
13
+ for a file named "catalog*.y*ml" in the parent directories. Defaults to None.
14
+
15
+ Returns:
16
+ Catalog: The loaded catalog object.
17
+ """
18
+ if path is None:
19
+ path = list(Path.cwd().rglob("catalog*.y*ml"))
20
+ if not len(path):
21
+ return
22
+ path = path[0]
23
+
24
+ return Catalog(path=path, namespace=namespace)
25
+
26
+
27
+ CATALOG = load_catalog()
flowerpower/_cfg.py ADDED
File without changes
flowerpower/_cli.py ADDED
@@ -0,0 +1,618 @@
1
+ import importlib.util
2
+
3
+ from loguru import logger
4
+ from typer import Typer
5
+
6
+ from .pipeline import add as add_pipeline_
7
+ from .pipeline import add_job as add_pipeline_job_
8
+ from .pipeline import all_pipelines as all_pipelines_
9
+ from .pipeline import delete as delete_pipeline_
10
+ from .pipeline import get_summary as get_pipeline_summary_
11
+ from .pipeline import new as new_pipeline_
12
+ from .pipeline import run as run_pipeline_
13
+ from .pipeline import run_job as run_pipeline_job_
14
+ from .pipeline import save_dag as save_pipeline_dag_
15
+ from .pipeline import schedule as schedule_pipeline_
16
+ from .pipeline import show_dag as show_pipeline_dag_
17
+ from .pipeline import show_summary as show_pipeline_summary_
18
+ from .pipeline import start_mqtt_listener as start_mqtt_listener_
19
+
20
+ if importlib.util.find_spec("apscheduler"):
21
+ from .scheduler import get_schedule_manager
22
+ from .scheduler import start_worker as start_worker_
23
+ else:
24
+ get_schedule_manager = None
25
+ start_scheduler_ = None
26
+
27
+ from . import init as init_
28
+
29
+ app = Typer()
30
+
31
+
32
+ @app.command()
33
+ def run_pipeline(
34
+ pipeline_name: str,
35
+ executor: str = "local",
36
+ base_dir: str = None,
37
+ inputs: str = None,
38
+ final_vars: str = None,
39
+ with_tracker: bool = False,
40
+ reload: bool = False,
41
+ storage_options: str = None,
42
+ ):
43
+ """
44
+ Run the specified task.
45
+ Args:
46
+ pipeline_name (str): The name of the task.
47
+ executor (str, optional): The executor to use for running the task. Defaults to "local".
48
+ base_dir (str, optional): The base path for the task. Defaults to None.
49
+ inputs (str, optional): The inputs for the task. Defaults to None.
50
+ final_vars (str, optional): The final variables for the task. Defaults to None.
51
+ with_tracker (bool, optional): Whether to use a tracker for the task. Defaults to False.
52
+ reload (bool, optional): Whether to reload the task. Defaults to False.
53
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None.
54
+ """
55
+ inputs = eval(inputs) if inputs is not None else None
56
+ final_vars = eval(final_vars) if final_vars is not None else None
57
+ with_tracker = with_tracker if with_tracker is not None else None
58
+ storage_options = eval(storage_options) if storage_options is not None else {}
59
+
60
+ _ = run_pipeline_(
61
+ name=pipeline_name,
62
+ executor=executor,
63
+ base_dir=base_dir,
64
+ inputs=inputs,
65
+ final_vars=final_vars,
66
+ with_tracker=with_tracker,
67
+ reload=reload,
68
+ storage_options=storage_options,
69
+ )
70
+
71
+
72
+ @app.command()
73
+ def run_pipeline_job(
74
+ pipeline_name: str,
75
+ executor: str = "local",
76
+ base_dir: str = None,
77
+ inputs: str = None,
78
+ final_vars: str = None,
79
+ with_tracker: bool = False,
80
+ reload: bool = False,
81
+ storage_options: str = None,
82
+ ):
83
+ """
84
+ Add a job to run the pipeline with the given parameters to the scheduler.
85
+ Executes the job immediatly.
86
+
87
+ Args:
88
+ name (str): The name of the job.
89
+ executor (str, optional): The executor to use for the job. Defaults to None.
90
+ inputs (str, optional): The inputs for the job. Defaults to None.
91
+ final_vars (str, optional): The final variables for the job. Defaults to None.
92
+ with_tracker (bool, optional): Whether to use a tracker for the job. Defaults to None.
93
+ base_dir (str, optional): The base path for the job. Defaults to None.
94
+ reload (bool): Whether to reload the job. Defaults to False.
95
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None.
96
+ """
97
+
98
+ inputs = eval(inputs) if inputs else None
99
+ final_vars = eval(final_vars) if final_vars is not None else None
100
+ with_tracker = with_tracker if with_tracker is not None else None
101
+ storage_options = eval(storage_options) if storage_options is not None else {}
102
+
103
+ _ = run_pipeline_job_(
104
+ name=pipeline_name,
105
+ executor=executor,
106
+ base_dir=base_dir,
107
+ inputs=inputs,
108
+ final_vars=final_vars,
109
+ with_tracker=with_tracker,
110
+ reload=reload,
111
+ storage_options=storage_options,
112
+ )
113
+
114
+
115
+ @app.command()
116
+ def add_pipeline_job(
117
+ pipeline_name: str,
118
+ executor: str = "local",
119
+ base_dir: str = None,
120
+ inputs: str = None,
121
+ final_vars: str = None,
122
+ with_tracker: bool = False,
123
+ reload: bool = False,
124
+ storage_options: str = None,
125
+ ):
126
+ """
127
+ Add a job to run the pipeline with the given parameters to the scheduler data store.
128
+ Executes the job immediatly and returns the job id (UUID). The job result will be stored in the data store for the
129
+ given `result_expiration_time` and can be fetched using the job id (UUID).
130
+
131
+ Args:
132
+ pipeline_name (str): The name of the job.
133
+ executor (str, optional): The executor to use for the job. Defaults to None.
134
+ inputs (str, optional): The inputs for the job. Defaults to None.
135
+ final_vars (str, optional): The final variables for the job. Defaults to None.
136
+ with_tracker (bool, optional): Whether to use a tracker for the job. Defaults to None.
137
+ base_dir (str, optional): The base path for the job. Defaults to None.
138
+ reload (bool): Whether to reload the job. Defaults to False.
139
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None.
140
+ """
141
+
142
+ inputs = eval(inputs) if inputs else None
143
+ final_vars = eval(final_vars) if final_vars is not None else None
144
+ with_tracker = with_tracker if with_tracker is not None else None
145
+ storage_options = eval(storage_options) if storage_options is not None else {}
146
+
147
+ id_ = add_pipeline_job_(
148
+ name=pipeline_name,
149
+ executor=executor,
150
+ base_dir=base_dir,
151
+ inputs=inputs,
152
+ final_vars=final_vars,
153
+ with_tracker=with_tracker,
154
+ reload=reload,
155
+ storage_options=storage_options,
156
+ )
157
+ logger.info(f"Job {id_} added to the scheduler.")
158
+
159
+
160
+ @app.command()
161
+ def schedule_pipeline(
162
+ pipeline_name: str,
163
+ executor: str = "local",
164
+ base_dir: str = None,
165
+ type: str = "cron",
166
+ inputs: str = None,
167
+ final_vars: str = None,
168
+ with_tracker: bool = False,
169
+ paused: bool = False,
170
+ coalesce: str = "latest",
171
+ misfire_grace_time: float = None,
172
+ max_jitter: float = None,
173
+ max_running_jobs: int = None,
174
+ conflict_policy: str = "do_nothing",
175
+ crontab: str = None,
176
+ cron_params: str = None,
177
+ interval_params: str = None,
178
+ calendarinterval_params: str = None,
179
+ date_params: str = None,
180
+ storage_options: str = None,
181
+ ):
182
+ """
183
+ Schedule a job with the given parameters.
184
+
185
+ Args:
186
+ pipeline_name (str): The name of the job.
187
+ executor (str, optional): The executor to use for running the job. Defaults to "local".
188
+ base_dir (str, optional): The base path for the job. Defaults to None.
189
+ type (str, optional): The type of the job. Defaults to "cron".
190
+ inputs (str, optional): The inputs for the job. Defaults to None.
191
+ final_vars (str, optional): The final variables for the job. Defaults to None.
192
+ with_tracker (bool, optional): Whether to use a tracker for the job. Defaults to False.
193
+ paused (bool, optional): Whether the job should be initially paused. Defaults to False.
194
+ coalesce (str, optional): The coalesce strategy for the job. Defaults to "latest".
195
+ misfire_grace_time (float, optional): The misfire grace time for the job. Defaults to None.
196
+ max_jitter (float, optional): The maximum jitter for the job. Defaults to None.
197
+ max_running_jobs (int, optional): The maximum number of running jobs. Defaults to None.
198
+ conflict_policy (str, optional): The conflict policy for the job. Defaults to "do_nothing".
199
+ crontab (str, optional): The crontab expression for the job. Defaults to None.
200
+ cron_params (str, optional): Additional parameters for the cron job. Defaults to None.
201
+ interval_params (str, optional): Additional parameters for the interval job. Defaults to None.
202
+ calendarinterval_params (str, optional): Additional parameters for the calendar interval job. Defaults to None.
203
+ date_params (str, optional): Additional parameters for the date job. Defaults to None.
204
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None.
205
+ """
206
+ if get_schedule_manager is None:
207
+ raise ValueError("APScheduler not installed. Please install it first.")
208
+
209
+ inputs = eval(inputs) if inputs else None
210
+ final_vars = eval(final_vars) if final_vars is not None else None
211
+ with_tracker = with_tracker if with_tracker is not None else None
212
+ storage_options = eval(storage_options) if storage_options is not None else {}
213
+
214
+ crontab = crontab or None
215
+ cron_params = (
216
+ dict([kw.split("=") for kw in cron_params.split(",")]) if cron_params else {}
217
+ )
218
+ interval_params = (
219
+ dict([kw.split("=") for kw in interval_params.split(",")])
220
+ if interval_params
221
+ else {}
222
+ )
223
+
224
+ calendarinterval_params = (
225
+ dict([kw.split("=") for kw in calendarinterval_params.split(",")])
226
+ if calendarinterval_params
227
+ else {}
228
+ )
229
+ date_params = (
230
+ dict([kw.split("=") for kw in date_params.split(",")]) if date_params else {}
231
+ )
232
+ try:
233
+ for key in ["weeks", "days", "hours", "minutes", "seconds"]:
234
+ if key in interval_params:
235
+ interval_params[key] = float(interval_params[key])
236
+ if key in calendarinterval_params:
237
+ calendarinterval_params[key] = float(calendarinterval_params[key])
238
+ except ValueError:
239
+ pass
240
+ kwargs = {
241
+ **cron_params,
242
+ **interval_params,
243
+ **calendarinterval_params,
244
+ **date_params,
245
+ }
246
+ if crontab is not None:
247
+ kwargs["crontab"] = crontab
248
+
249
+ id_ = schedule_pipeline_(
250
+ name=pipeline_name,
251
+ executor=executor,
252
+ base_dir=base_dir,
253
+ type=type,
254
+ inputs=inputs,
255
+ final_vars=final_vars,
256
+ with_tracker=with_tracker,
257
+ paused=paused,
258
+ coalesce=coalesce,
259
+ misfire_grace_time=misfire_grace_time,
260
+ max_jitter=max_jitter,
261
+ max_running_jobs=max_running_jobs,
262
+ conflict_policy=conflict_policy,
263
+ storage_options=storage_options,
264
+ **kwargs,
265
+ )
266
+ logger.info(f"Job {id_} scheduled.")
267
+
268
+
269
+ @app.command()
270
+ def new_pipeline(
271
+ pipeline_name: str,
272
+ base_dir: str = None,
273
+ overwrite: bool = False,
274
+ storage_options: str = None,
275
+ ):
276
+ """
277
+ Create a new pipeline with the given parameters.
278
+
279
+ Args:
280
+ pipeline_name (str): The name of the pipeline.
281
+ base_dir (str, optional): The base path for the pipeline. Defaults to None.
282
+ overwrite (bool, optional): Whether to overwrite an existing pipeline with the same name. Defaults to False.
283
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
284
+ """
285
+
286
+ storage_options = eval(storage_options) if storage_options is not None else {}
287
+
288
+ new_pipeline_(
289
+ name=pipeline_name,
290
+ base_dir=base_dir,
291
+ overwrite=overwrite,
292
+ storage_options=storage_options,
293
+ )
294
+
295
+
296
+ @app.command()
297
+ def add_pipeline(
298
+ pipeline_name: str,
299
+ base_dir: str = None,
300
+ overwrite: bool = False,
301
+ pipeline_file: str = "",
302
+ pipeline_config: str = "",
303
+ storage_options: str = None,
304
+ ):
305
+ """
306
+ Create a new pipeline with the given parameters.
307
+
308
+ Args:
309
+ pipeline_name (str): The name of the pipeline.
310
+ base_dir (str, optional): The base path for the pipeline. Defaults to None.
311
+ overwrite (bool, optional): Whether to overwrite an existing pipeline with the same name. Defaults to False.
312
+ pipeline_file (str, optional): The path to the pipeline file. Defaults to "".
313
+ pipeline_config (str, optional): The path to the pipeline configuration. Defaults to "".
314
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
315
+ """
316
+
317
+ storage_options = eval(storage_options) if storage_options is not None else {}
318
+
319
+ add_pipeline_(
320
+ name=pipeline_name,
321
+ base_dir=base_dir,
322
+ overwrite=overwrite,
323
+ pipeline_config=pipeline_config,
324
+ pipeline_file=pipeline_file,
325
+ storage_options=storage_options,
326
+ )
327
+
328
+
329
+ @app.command()
330
+ def delete_pipeline(
331
+ pipeline_name: str,
332
+ base_dir: str = None,
333
+ module: bool = False,
334
+ storage_options: str = "{}",
335
+ ):
336
+ """
337
+ Delete a pipeline.
338
+
339
+ Args:
340
+ pipeline_name (str): The name of the pipeline to delete.
341
+ base_dir (str): The base path of the pipeline. Defaults to None.
342
+ module (bool, optional): Whether to delete the pipeline module. Defaults to False.
343
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
344
+ """
345
+
346
+ storage_options = eval(storage_options) if storage_options is not None else {}
347
+
348
+ delete_pipeline_(
349
+ name=pipeline_name,
350
+ base_dir=base_dir,
351
+ remove_module=module,
352
+ storage_options=storage_options,
353
+ )
354
+
355
+
356
+ @app.command()
357
+ def init(
358
+ project_name: str = None,
359
+ base_dir: str = None,
360
+ storage_options: str = None,
361
+ ):
362
+ """
363
+ Initialize the FlowerPower application.
364
+
365
+ Args:
366
+ name (str): The name of the application.
367
+ base_dir (str, optional): The base path of the application. Defaults to "".
368
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
369
+ """
370
+ storage_options = eval(storage_options) if storage_options is not None else {}
371
+
372
+ init_(
373
+ name=project_name,
374
+ base_dir=base_dir,
375
+ storage_options=storage_options,
376
+ )
377
+
378
+
379
+ @app.command()
380
+ def start_worker(worker_name: str, base_dir: str = None, storage_options: str = "{}"):
381
+ """
382
+ Start a worker.
383
+
384
+ Args:
385
+ name (str): The name of the worker.
386
+ base_dir (str, optional): The base path. Defaults to "".
387
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
388
+ """
389
+ storage_options = eval(storage_options) if storage_options is not None else {}
390
+
391
+ start_worker_(
392
+ name=worker_name,
393
+ base_dir=base_dir,
394
+ background=False,
395
+ storage_options=storage_options,
396
+ )
397
+
398
+
399
+ @app.command()
400
+ def save_pipeline_dag(
401
+ pipeline_name: str,
402
+ base_dir: str = None,
403
+ format: str = "png",
404
+ storage_options: str = "{}",
405
+ ):
406
+ """
407
+ Show the pipeline.
408
+
409
+ Args:
410
+ pipeline_name (str): The name of the pipeline.
411
+ base_dir (str, optional): The base path of the pipeline. Defaults to "".
412
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
413
+ """
414
+ storage_options = eval(storage_options) if storage_options is not None else {}
415
+ save_pipeline_dag_(
416
+ name=pipeline_name,
417
+ base_dir=base_dir,
418
+ format=format,
419
+ storage_options=storage_options,
420
+ )
421
+
422
+
423
+ @app.command()
424
+ def show_pipeline_dag(
425
+ pipeline_name: str,
426
+ base_dir: str = None,
427
+ storage_options: str = "{}",
428
+ ):
429
+ """
430
+ Show the pipeline.
431
+
432
+ Args:
433
+ pipeline_name (str): The name of the pipeline.
434
+ base_dir (str, optional): The base path of the pipeline. Defaults to "".
435
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
436
+ """
437
+ storage_options = eval(storage_options) if storage_options is not None else {}
438
+ show_pipeline_dag_(
439
+ name=pipeline_name,
440
+ base_dir=base_dir,
441
+ storage_options=storage_options,
442
+ )
443
+
444
+
445
+ @app.command()
446
+ def all_pipelines(base_dir: str = None, storage_options: str = "{}"):
447
+ """
448
+ List all pipelines.
449
+
450
+ Args:
451
+ base_dir (str, optional): The base path of the pipelines. Defaults to "".
452
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
453
+ """
454
+ storage_options = eval(storage_options) if storage_options is not None else {}
455
+ all_pipelines_(base_dir=base_dir, storage_options=storage_options)
456
+
457
+
458
+ @app.command()
459
+ def get_pipeline_summary(
460
+ pipeline_name: str = None,
461
+ config: bool = True,
462
+ module: bool = True,
463
+ base_dir: str = None,
464
+ storage_options: str = "{}",
465
+ ):
466
+ """
467
+ Get a summary of the pipeline.
468
+
469
+ Args:
470
+ pipeline_name (str, optional): The name of the pipeline.
471
+ show (bool, optional): Whether to show the summary. Defaults to True.
472
+ base_dir (str, optional): The base path of the pipeline. Defaults to "".
473
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
474
+ """
475
+ storage_options = eval(storage_options) if storage_options is not None else {}
476
+ summary = get_pipeline_summary_(
477
+ name=pipeline_name,
478
+ config=config,
479
+ module=module,
480
+ base_dir=base_dir,
481
+ storage_options=storage_options,
482
+ )
483
+ return summary
484
+
485
+
486
+ @app.command()
487
+ def show_pipeline_summary(
488
+ pipeline_name: str = None,
489
+ config: bool = True,
490
+ module: bool = True,
491
+ base_dir: str = None,
492
+ storage_options: str = "{}",
493
+ ):
494
+ """
495
+ Get a summary of the pipeline.
496
+
497
+ Args:
498
+ pipeline_name (str, optional): The name of the pipeline.
499
+ show (bool, optional): Whether to show the summary. Defaults to True.
500
+ base_dir (str, optional): The base path of the pipeline. Defaults to "".
501
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None".
502
+ """
503
+ storage_options = eval(storage_options) if storage_options is not None else {}
504
+ summary = show_pipeline_summary_(
505
+ name=pipeline_name,
506
+ config=config,
507
+ module=module,
508
+ base_dir=base_dir,
509
+ storage_options=storage_options,
510
+ )
511
+ return summary
512
+
513
+
514
+ @app.command()
515
+ def start_mqtt_listener(
516
+ pipeline_name: str,
517
+ topic: str = "#",
518
+ host: str = "localhost",
519
+ port: int = 1883,
520
+ user: str = None,
521
+ pw: str = None,
522
+ inputs: str = None,
523
+ final_vars: str = None,
524
+ executor: str = None,
525
+ with_tracker: bool = False,
526
+ with_opentelemetry: bool = False,
527
+ base_dir: str = None,
528
+ storage_options: str = None,
529
+ reload: bool = False,
530
+ result_expiration_time: float = 0.0,
531
+ as_job: bool = False,
532
+ background: bool = False,
533
+ ):
534
+ """
535
+ Start the MQTT listener.
536
+
537
+ Args:
538
+ pipeline_name (str): The name of the pipeline to run.
539
+ topic (str, optional): The MQTT topic to listen to. Defaults to "#".
540
+ host (str, optional): The MQTT host. Defaults to "localhost".
541
+ port (int, optional): The MQTT port. Defaults to 1883.
542
+ user (str, optional): The MQTT username. Defaults to None.
543
+ pw (str, optional): The MQTT password. Defaults to None.
544
+ inputs (str, optional): The inputs for the pipeline. Defaults to None.
545
+ final_vars (list, optional): The final variables for the pipeline. Defaults to None.
546
+ executor (str, optional): The executor to use for the pipeline. Defaults to None.
547
+ with_tracker (bool, optional): Whether to use a tracker for the pipeline. Defaults to False.
548
+ with_opentelemetry (bool, optional): Whether to use OpenTelemetry for the pipeline. Defaults to False.
549
+ base_dir (str, optional): The base path for the pipeline. Defaults to None.
550
+ storage_options (str, optional): The filesystem storage options for the task. Defaults to None.
551
+ reload (bool, optional): Whether to reload the pipeline. Defaults to False.
552
+ result_expiration_time (float, optional): The result expiration time for the pipeline. Defaults to 0.0.
553
+ as_job (bool, optional): Whether to run the pipeline as a job. Defaults to False.
554
+ background (bool, optional): Whether to run the listener in the background. Defaults to e.
555
+ """
556
+ storage_options = eval(storage_options) if storage_options is not None else {}
557
+ start_mqtt_listener_(
558
+ name=pipeline_name,
559
+ topic=topic,
560
+ host=host,
561
+ port=port,
562
+ user=user,
563
+ pw=pw,
564
+ inputs=inputs,
565
+ final_vars=final_vars,
566
+ executor=executor,
567
+ with_tracker=with_tracker,
568
+ with_opentelemetry=with_opentelemetry,
569
+ base_dir=base_dir,
570
+ storage_options=storage_options,
571
+ reload=reload,
572
+ result_expiration_time=result_expiration_time,
573
+ as_job=as_job,
574
+ background=background,
575
+ )
576
+
577
+
578
+ @app.command()
579
+ def hamilton_ui(
580
+ port: int = 8241,
581
+ base_dir: str = "~/.hamilton/db",
582
+ no_migration: bool = False,
583
+ no_open: bool = False,
584
+ settings_file: str = "mini",
585
+ config_file: str = None,
586
+ ):
587
+ """
588
+ Start the Hamilton UI.
589
+
590
+ Args:
591
+ port (int, optional): The port to run the UI on. Defaults to 8241.
592
+ base_dir (str, optional): The base path for the UI. Defaults to "~/.hamilton/db".
593
+ no_migration (bool, optional): Whether to run the migration. Defaults to False.
594
+ no_open (bool, optional): Whether to open the UI in the browser. Defaults to False.
595
+ settings_file (str, optional): The settings file to use. Defaults to "mini".
596
+ config_file (str, optional): The config file to use. Defaults to None.
597
+ """
598
+ try:
599
+ from hamilton_ui import commands
600
+ except ImportError:
601
+ logger.error(
602
+ "hamilton[ui] not installed -- you have to install this to run the UI. "
603
+ 'Run `pip install "sf-hamilton[ui]"` to install and get started with the UI!'
604
+ )
605
+ raise app.Exit(code=1)
606
+
607
+ commands.run(
608
+ port=port,
609
+ base_dir=base_dir,
610
+ no_migration=no_migration,
611
+ no_open=no_open,
612
+ settings_file=settings_file,
613
+ config_file=config_file,
614
+ )
615
+
616
+
617
+ if __name__ == "__main__":
618
+ app()