meerschaum 2.0.0rc6__py3-none-any.whl → 2.0.0rc8__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 (52) hide show
  1. meerschaum/_internal/arguments/_parse_arguments.py +12 -1
  2. meerschaum/_internal/arguments/_parser.py +23 -1
  3. meerschaum/actions/__init__.py +97 -48
  4. meerschaum/actions/bootstrap.py +1 -1
  5. meerschaum/actions/clear.py +1 -1
  6. meerschaum/actions/deduplicate.py +1 -1
  7. meerschaum/actions/delete.py +8 -7
  8. meerschaum/actions/drop.py +1 -10
  9. meerschaum/actions/edit.py +1 -1
  10. meerschaum/actions/install.py +1 -1
  11. meerschaum/actions/pause.py +1 -1
  12. meerschaum/actions/register.py +1 -1
  13. meerschaum/actions/setup.py +1 -1
  14. meerschaum/actions/show.py +1 -1
  15. meerschaum/actions/start.py +18 -7
  16. meerschaum/actions/stop.py +5 -4
  17. meerschaum/actions/sync.py +17 -2
  18. meerschaum/actions/uninstall.py +1 -1
  19. meerschaum/actions/upgrade.py +1 -1
  20. meerschaum/actions/verify.py +54 -3
  21. meerschaum/config/_default.py +71 -65
  22. meerschaum/config/_formatting.py +26 -0
  23. meerschaum/config/_jobs.py +28 -5
  24. meerschaum/config/_paths.py +21 -5
  25. meerschaum/config/_version.py +1 -1
  26. meerschaum/connectors/api/_fetch.py +1 -1
  27. meerschaum/connectors/api/_pipes.py +6 -11
  28. meerschaum/connectors/sql/_fetch.py +29 -11
  29. meerschaum/connectors/sql/_pipes.py +11 -4
  30. meerschaum/connectors/sql/_sql.py +1 -6
  31. meerschaum/core/Pipe/__init__.py +5 -1
  32. meerschaum/core/Pipe/_data.py +58 -9
  33. meerschaum/core/Pipe/_deduplicate.py +61 -11
  34. meerschaum/core/Pipe/_dtypes.py +2 -1
  35. meerschaum/core/Pipe/_verify.py +174 -34
  36. meerschaum/plugins/__init__.py +3 -0
  37. meerschaum/utils/daemon/Daemon.py +108 -27
  38. meerschaum/utils/daemon/__init__.py +35 -1
  39. meerschaum/utils/dataframe.py +10 -5
  40. meerschaum/utils/formatting/__init__.py +144 -1
  41. meerschaum/utils/formatting/_pipes.py +28 -5
  42. meerschaum/utils/misc.py +183 -187
  43. meerschaum/utils/packages/__init__.py +1 -1
  44. meerschaum/utils/packages/_packages.py +1 -0
  45. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/METADATA +4 -1
  46. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/RECORD +52 -52
  47. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/LICENSE +0 -0
  48. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/NOTICE +0 -0
  49. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/WHEEL +0 -0
  50. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/entry_points.txt +0 -0
  51. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/top_level.txt +0 -0
  52. {meerschaum-2.0.0rc6.dist-info → meerschaum-2.0.0rc8.dist-info}/zip-safe +0 -0
meerschaum/utils/misc.py CHANGED
@@ -6,25 +6,39 @@ Miscellaneous functions go here
6
6
  """
7
7
 
8
8
  from __future__ import annotations
9
+ from datetime import timedelta
9
10
  from meerschaum.utils.typing import (
10
- Union, Mapping, Any, Callable, Optional, List, Dict, SuccessTuple, Iterable, PipesDict, Tuple,
11
- InstanceConnector, Hashable, Generator, Iterator,
11
+ Union,
12
+ Any,
13
+ Callable,
14
+ Optional,
15
+ List,
16
+ Dict,
17
+ SuccessTuple,
18
+ Iterable,
19
+ PipesDict,
20
+ Tuple,
21
+ InstanceConnector,
22
+ Hashable,
23
+ Generator,
24
+ Iterator,
12
25
  )
13
26
  import meerschaum as mrsm
14
27
 
15
- ### Import from other modules to retain legacy behavior.
16
- from meerschaum.utils.dtypes import to_pandas_dtype
17
- from meerschaum.utils.dataframe import (
18
- filter_unseen_df,
19
- add_missing_cols_to_df,
20
- parse_df_datetimes,
21
- df_from_literal,
22
- get_json_cols,
23
- get_unhashable_cols,
24
- enforce_dtypes,
25
- get_datetime_bound_from_df,
26
- df_is_chunk_generator,
27
- )
28
+ __pdoc__: Dict[str, bool] = {
29
+ 'to_pandas_dtype': False,
30
+ 'filter_unseen_df': False,
31
+ 'add_missing_cols_to_df': False,
32
+ 'parse_df_datetimes': False,
33
+ 'df_from_literal': False,
34
+ 'get_json_cols': False,
35
+ 'get_unhashable_cols': False,
36
+ 'enforce_dtypes': False,
37
+ 'get_datetime_bound_from_df': False,
38
+ 'df_is_chunk_generator': False,
39
+ 'choices_docstring': False,
40
+ '_get_subaction_names': False,
41
+ }
28
42
 
29
43
 
30
44
  def add_method_to_class(
@@ -270,178 +284,6 @@ def is_pipe_registered(
270
284
  return ck in pipes and mk in pipes[ck] and lk in pipes[ck][mk]
271
285
 
272
286
 
273
- def _get_subaction_names(action : str, globs : dict = None) -> List[str]:
274
- """NOTE: Don't use this function. You should use `meerschaum.actions.get_subactions()` instead.
275
- This only exists for internal use.
276
- """
277
- if globs is None:
278
- import importlib
279
- module = importlib.import_module(f'meerschaum.actions.{action}')
280
- globs = vars(module)
281
- subactions = []
282
- for item in globs:
283
- if f'_{action}' in item and 'complete' not in item.lstrip('_'):
284
- subactions.append(globs[item])
285
- return subactions
286
-
287
-
288
- def choices_docstring(action: str, globs : Optional[Dict[str, Any]] = None) -> str:
289
- """
290
- Append the an action's available options to the module docstring.
291
- This function is to be placed at the bottom of each action module.
292
-
293
- Parameters
294
- ----------
295
- action: str
296
- The name of the action module (e.g. 'install').
297
-
298
- globs: Optional[Dict[str, Any]], default None
299
- An optional dictionary of global variables.
300
-
301
- Returns
302
- -------
303
- The generated docstring for the module.
304
-
305
- Examples
306
- --------
307
- >>> from meerschaum.utils.misc import choices_docstring as _choices_docstring
308
- >>> install.__doc__ += _choices_docstring('install')
309
-
310
- """
311
- options_str = f"\n Options:\n `{action} "
312
- subactions = _get_subaction_names(action, globs=globs)
313
- options_str += "["
314
- sa_names = []
315
- for sa in subactions:
316
- try:
317
- sa_names.append(sa.__name__[len(f"_{action}") + 1:])
318
- except Exception as e:
319
- print(e)
320
- return ""
321
- for sa_name in sorted(sa_names):
322
- options_str += f"{sa_name}, "
323
- options_str = options_str[:-2] + "]`"
324
- return options_str
325
-
326
-
327
- def print_options(
328
- options: Optional[Dict[str, Any]] = None,
329
- nopretty: bool = False,
330
- no_rich: bool = False,
331
- name: str = 'options',
332
- header: Optional[str] = None,
333
- num_cols: Optional[int] = None,
334
- adjust_cols: bool = True,
335
- **kw
336
- ) -> None:
337
- """
338
- Print items in an iterable as a fancy table.
339
-
340
- Parameters
341
- ----------
342
- options: Optional[Dict[str, Any]], default None
343
- The iterable to be printed.
344
-
345
- nopretty: bool, default False
346
- If `True`, don't use fancy formatting.
347
-
348
- no_rich: bool, default False
349
- If `True`, don't use `rich` to format the output.
350
-
351
- name: str, default 'options'
352
- The text in the default header after `'Available'`.
353
-
354
- header: Optional[str], default None
355
- If provided, override `name` and use this as the header text.
356
-
357
- num_cols: Optional[int], default None
358
- How many columns in the table. Depends on the terminal size. If `None`, use 8.
359
-
360
- adjust_cols: bool, default True
361
- If `True`, adjust the number of columns depending on the terminal size.
362
-
363
- """
364
- import os
365
- from meerschaum.utils.packages import import_rich
366
- from meerschaum.utils.formatting import make_header, highlight_pipes
367
- from meerschaum.actions import actions as _actions
368
-
369
-
370
- if options is None:
371
- options = {}
372
- _options = []
373
- for o in options:
374
- _options.append(str(o))
375
- _header = f"Available {name}" if header is None else header
376
-
377
- if num_cols is None:
378
- num_cols = 8
379
-
380
- def _print_options_no_rich():
381
- if not nopretty:
382
- print()
383
- print(make_header(_header))
384
- ### print actions
385
- for option in sorted(_options):
386
- if not nopretty:
387
- print(" - ", end="")
388
- print(option)
389
- if not nopretty:
390
- print()
391
-
392
- rich = import_rich()
393
- if rich is None or nopretty or no_rich:
394
- _print_options_no_rich()
395
- return None
396
-
397
- ### Prevent too many options from being truncated on small terminals.
398
- if adjust_cols and _options:
399
- _cols, _lines = get_cols_lines()
400
- while num_cols > 1:
401
- cell_len = int(((_cols - 4) - (3 * (num_cols - 1))) / num_cols)
402
- num_too_big = sum([(1 if string_width(o) > cell_len else 0) for o in _options])
403
- if num_too_big > int(len(_options) / 3):
404
- num_cols -= 1
405
- continue
406
- break
407
-
408
- from meerschaum.utils.formatting import pprint, get_console
409
- from meerschaum.utils.packages import attempt_import
410
- rich_columns = attempt_import('rich.columns')
411
- rich_panel = attempt_import('rich.panel')
412
- rich_table = attempt_import('rich.table')
413
- Text = attempt_import('rich.text').Text
414
- box = attempt_import('rich.box')
415
- Panel = rich_panel.Panel
416
- Columns = rich_columns.Columns
417
- Table = rich_table.Table
418
-
419
- if _header is not None:
420
- table = Table(
421
- title = '\n' + _header,
422
- box = box.SIMPLE,
423
- show_header = False,
424
- show_footer = False,
425
- title_style = '',
426
- expand = True,
427
- )
428
- else:
429
- table = Table.grid(padding=(0, 2))
430
- for i in range(num_cols):
431
- table.add_column()
432
-
433
- chunks = iterate_chunks(
434
- [Text.from_ansi(highlight_pipes(o)) for o in sorted(_options)],
435
- num_cols,
436
- fillvalue=''
437
- )
438
- for c in chunks:
439
- table.add_row(*c)
440
-
441
- get_console().print(table)
442
- return None
443
-
444
-
445
287
  def get_cols_lines(default_cols: int = 100, default_lines: int = 120) -> Tuple[int, int]:
446
288
  """
447
289
  Determine the columns and lines in the terminal.
@@ -1128,6 +970,7 @@ def async_wrap(func):
1128
970
  return await loop.run_in_executor(executor, pfunc)
1129
971
  return run
1130
972
 
973
+
1131
974
  def debug_trace(browser: bool = True):
1132
975
  """
1133
976
  Open a web-based debugger to trace the execution of the program.
@@ -1136,6 +979,7 @@ def debug_trace(browser: bool = True):
1136
979
  heartrate = attempt_import('heartrate')
1137
980
  heartrate.trace(files=heartrate.files.all, browser=browser)
1138
981
 
982
+
1139
983
  def items_str(
1140
984
  items: List[Any],
1141
985
  quotes: bool = True,
@@ -1224,6 +1068,29 @@ def items_str(
1224
1068
  return output
1225
1069
 
1226
1070
 
1071
+ def interval_str(delta: Union[timedelta, int]) -> str:
1072
+ """
1073
+ Return a human-readable string for a `timedelta` (or `int` minutes).
1074
+
1075
+ Parameters
1076
+ ----------
1077
+ delta: Union[timedelta, int]
1078
+ The interval to print. If `delta` is an integer, assume it corresponds to minutes.
1079
+
1080
+ Returns
1081
+ -------
1082
+ A formatted string, fit for human eyes.
1083
+ """
1084
+ from meerschaum.utils.packages import attempt_import
1085
+ humanfriendly = attempt_import('humanfriendly')
1086
+ delta_seconds = (
1087
+ delta.total_seconds()
1088
+ if isinstance(delta, timedelta)
1089
+ else (delta * 60)
1090
+ )
1091
+ return humanfriendly.format_timespan(delta_seconds)
1092
+
1093
+
1227
1094
  def is_docker_available() -> bool:
1228
1095
  """Check if we can connect to the Docker engine."""
1229
1096
  import subprocess
@@ -1518,3 +1385,132 @@ def safely_extract_tar(tarf: 'file', output_dir: Union[str, 'pathlib.Path']) ->
1518
1385
  tar.extractall(path=path, members=members, numeric_owner=numeric_owner)
1519
1386
 
1520
1387
  return safe_extract(tarf, output_dir)
1388
+
1389
+ ##################
1390
+ # Legacy imports #
1391
+ ##################
1392
+
1393
+ def choose_subaction(*args, **kwargs) -> Any:
1394
+ """
1395
+ Placeholder function to prevent breaking legacy behavior.
1396
+ See `meerschaum.actions.choose_subaction`.
1397
+ """
1398
+ from meerschaum.actions import choose_subaction as _choose_subactions
1399
+ return _choose_subactions(*args, **kwargs)
1400
+
1401
+
1402
+ def print_options(*args, **kwargs) -> None:
1403
+ """
1404
+ Placeholder function to prevent breaking legacy behavior.
1405
+ See `meerschaum.utils.formatting.print_options`.
1406
+ """
1407
+ from meerschaum.utils.formatting import print_options as _print_options
1408
+ return _print_options(*args, **kwargs)
1409
+
1410
+
1411
+ def to_pandas_dtype(*args, **kwargs) -> Any:
1412
+ """
1413
+ Placeholder function to prevent breaking legacy behavior.
1414
+ See `meerschaum.utils.dtypes.to_pandas_dtype`.
1415
+ """
1416
+ from meerschaum.utils.dtypes import to_pandas_dtype as _to_pandas_dtype
1417
+ return _to_pandas_dtype(*args, **kwargs)
1418
+
1419
+
1420
+ def filter_unseen_df(*args, **kwargs) -> Any:
1421
+ """
1422
+ Placeholder function to prevent breaking legacy behavior.
1423
+ See `meerschaum.utils.dataframe.filter_unseen_df`.
1424
+ """
1425
+ from meerschaum.utils.dataframe import filter_unseen_df as real_function
1426
+ return real_function(*args, **kwargs)
1427
+
1428
+
1429
+ def add_missing_cols_to_df(*args, **kwargs) -> Any:
1430
+ """
1431
+ Placeholder function to prevent breaking legacy behavior.
1432
+ See `meerschaum.utils.dataframe.add_missing_cols_to_df`.
1433
+ """
1434
+ from meerschaum.utils.dataframe import add_missing_cols_to_df as real_function
1435
+ return real_function(*args, **kwargs)
1436
+
1437
+
1438
+ def parse_df_datetimes(*args, **kwargs) -> Any:
1439
+ """
1440
+ Placeholder function to prevent breaking legacy behavior.
1441
+ See `meerschaum.utils.dataframe.parse_df_datetimes`.
1442
+ """
1443
+ from meerschaum.utils.dataframe import parse_df_datetimes as real_function
1444
+ return real_function(*args, **kwargs)
1445
+
1446
+
1447
+ def df_from_literal(*args, **kwargs) -> Any:
1448
+ """
1449
+ Placeholder function to prevent breaking legacy behavior.
1450
+ See `meerschaum.utils.dataframe.df_from_literal`.
1451
+ """
1452
+ from meerschaum.utils.dataframe import df_from_literal as real_function
1453
+ return real_function(*args, **kwargs)
1454
+
1455
+
1456
+ def get_json_cols(*args, **kwargs) -> Any:
1457
+ """
1458
+ Placeholder function to prevent breaking legacy behavior.
1459
+ See `meerschaum.utils.dataframe.get_json_cols`.
1460
+ """
1461
+ from meerschaum.utils.dataframe import get_json_cols as real_function
1462
+ return real_function(*args, **kwargs)
1463
+
1464
+
1465
+ def get_unhashable_cols(*args, **kwargs) -> Any:
1466
+ """
1467
+ Placeholder function to prevent breaking legacy behavior.
1468
+ See `meerschaum.utils.dataframe.get_unhashable_cols`.
1469
+ """
1470
+ from meerschaum.utils.dataframe import get_unhashable_cols as real_function
1471
+ return real_function(*args, **kwargs)
1472
+
1473
+
1474
+ def enforce_dtypes(*args, **kwargs) -> Any:
1475
+ """
1476
+ Placeholder function to prevent breaking legacy behavior.
1477
+ See `meerschaum.utils.dataframe.enforce_dtypes`.
1478
+ """
1479
+ from meerschaum.utils.dataframe import enforce_dtypes as real_function
1480
+ return real_function(*args, **kwargs)
1481
+
1482
+
1483
+ def get_datetime_bound_from_df(*args, **kwargs) -> Any:
1484
+ """
1485
+ Placeholder function to prevent breaking legacy behavior.
1486
+ See `meerschaum.utils.dataframe.get_datetime_bound_from_df`.
1487
+ """
1488
+ from meerschaum.utils.dataframe import get_datetime_bound_from_df as real_function
1489
+ return real_function(*args, **kwargs)
1490
+
1491
+
1492
+ def df_is_chunk_generator(*args, **kwargs) -> Any:
1493
+ """
1494
+ Placeholder function to prevent breaking legacy behavior.
1495
+ See `meerschaum.utils.dataframe.df_is_chunk_generator`.
1496
+ """
1497
+ from meerschaum.utils.dataframe import df_is_chunk_generator as real_function
1498
+ return real_function(*args, **kwargs)
1499
+
1500
+
1501
+ def choices_docstring(*args, **kwargs) -> Any:
1502
+ """
1503
+ Placeholder function to prevent breaking legacy behavior.
1504
+ See `meerschaum.actions.choices_docstring`.
1505
+ """
1506
+ from meerschaum.actions import choices_docstring as real_function
1507
+ return real_function(*args, **kwargs)
1508
+
1509
+
1510
+ def _get_subaction_names(*args, **kwargs) -> Any:
1511
+ """
1512
+ Placeholder function to prevent breaking legacy behavior.
1513
+ See `meerschaum.actions._get_subaction_names`.
1514
+ """
1515
+ from meerschaum.actions import _get_subaction_names as real_function
1516
+ return real_function(*args, **kwargs)
@@ -1292,7 +1292,7 @@ def import_pandas(
1292
1292
  (
1293
1293
  "You are using an alternative Pandas implementation "
1294
1294
  + f"'{pandas_module_name}'"
1295
- + "\nFeatures may not work as expected."
1295
+ + "\n Features may not work as expected."
1296
1296
  ),
1297
1297
  stack = False,
1298
1298
  )
@@ -121,6 +121,7 @@ packages: Dict[str, Dict[str, str]] = {
121
121
  packages['sql'] = {
122
122
  'numpy' : 'numpy>=1.18.5',
123
123
  'pandas' : 'pandas[parquet]>=2.0.1',
124
+ 'pyarrow' : 'pyarrow>=7.0.0',
124
125
  'dask' : 'dask>=2023.9.0',
125
126
  'pytz' : 'pytz',
126
127
  'joblib' : 'joblib>=0.17.0',
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: meerschaum
3
- Version: 2.0.0rc6
3
+ Version: 2.0.0rc8
4
4
  Summary: Sync Time-Series Pipes with Meerschaum
5
5
  Home-page: https://meerschaum.io
6
6
  Author: Bennett Meares
@@ -70,6 +70,7 @@ Requires-Dist: pydantic (>=1.7.4) ; extra == 'api'
70
70
  Requires-Dist: httpx (>=0.24.1) ; extra == 'api'
71
71
  Requires-Dist: numpy (>=1.18.5) ; extra == 'api'
72
72
  Requires-Dist: pandas[parquet] (>=2.0.1) ; extra == 'api'
73
+ Requires-Dist: pyarrow (>=7.0.0) ; extra == 'api'
73
74
  Requires-Dist: dask (>=2023.9.0) ; extra == 'api'
74
75
  Requires-Dist: pytz ; extra == 'api'
75
76
  Requires-Dist: joblib (>=0.17.0) ; extra == 'api'
@@ -232,6 +233,7 @@ Requires-Dist: pywebview (>=3.6.3) ; extra == 'full'
232
233
  Requires-Dist: pycparser (>=2.21.0) ; extra == 'full'
233
234
  Requires-Dist: numpy (>=1.18.5) ; extra == 'full'
234
235
  Requires-Dist: pandas[parquet] (>=2.0.1) ; extra == 'full'
236
+ Requires-Dist: pyarrow (>=7.0.0) ; extra == 'full'
235
237
  Requires-Dist: dask (>=2023.9.0) ; extra == 'full'
236
238
  Requires-Dist: pytz ; extra == 'full'
237
239
  Requires-Dist: joblib (>=0.17.0) ; extra == 'full'
@@ -270,6 +272,7 @@ Provides-Extra: setup
270
272
  Provides-Extra: sql
271
273
  Requires-Dist: numpy (>=1.18.5) ; extra == 'sql'
272
274
  Requires-Dist: pandas[parquet] (>=2.0.1) ; extra == 'sql'
275
+ Requires-Dist: pyarrow (>=7.0.0) ; extra == 'sql'
273
276
  Requires-Dist: dask (>=2023.9.0) ; extra == 'sql'
274
277
  Requires-Dist: pytz ; extra == 'sql'
275
278
  Requires-Dist: joblib (>=0.17.0) ; extra == 'sql'