singlestoredb 1.14.2__cp38-abi3-win_amd64.whl → 1.15.1__cp38-abi3-win_amd64.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 singlestoredb might be problematic. Click here for more details.

Files changed (55) hide show
  1. _singlestoredb_accel.pyd +0 -0
  2. singlestoredb/__init__.py +2 -2
  3. singlestoredb/ai/chat.py +14 -0
  4. singlestoredb/apps/_python_udfs.py +3 -3
  5. singlestoredb/config.py +11 -0
  6. singlestoredb/docstring/__init__.py +33 -0
  7. singlestoredb/docstring/attrdoc.py +126 -0
  8. singlestoredb/docstring/common.py +230 -0
  9. singlestoredb/docstring/epydoc.py +267 -0
  10. singlestoredb/docstring/google.py +412 -0
  11. singlestoredb/docstring/numpydoc.py +562 -0
  12. singlestoredb/docstring/parser.py +100 -0
  13. singlestoredb/docstring/py.typed +1 -0
  14. singlestoredb/docstring/rest.py +256 -0
  15. singlestoredb/docstring/tests/__init__.py +1 -0
  16. singlestoredb/docstring/tests/_pydoctor.py +21 -0
  17. singlestoredb/docstring/tests/test_epydoc.py +729 -0
  18. singlestoredb/docstring/tests/test_google.py +1007 -0
  19. singlestoredb/docstring/tests/test_numpydoc.py +1100 -0
  20. singlestoredb/docstring/tests/test_parse_from_object.py +109 -0
  21. singlestoredb/docstring/tests/test_parser.py +248 -0
  22. singlestoredb/docstring/tests/test_rest.py +547 -0
  23. singlestoredb/docstring/tests/test_util.py +70 -0
  24. singlestoredb/docstring/util.py +141 -0
  25. singlestoredb/functions/decorator.py +51 -31
  26. singlestoredb/functions/ext/asgi.py +381 -35
  27. singlestoredb/functions/ext/timer.py +98 -0
  28. singlestoredb/functions/signature.py +374 -241
  29. singlestoredb/functions/typing/numpy.py +20 -0
  30. singlestoredb/functions/typing/pandas.py +2 -0
  31. singlestoredb/functions/typing/polars.py +2 -0
  32. singlestoredb/functions/typing/pyarrow.py +2 -0
  33. singlestoredb/fusion/handlers/files.py +4 -4
  34. singlestoredb/fusion/handlers/models.py +1 -1
  35. singlestoredb/fusion/handlers/stage.py +4 -4
  36. singlestoredb/magics/run_personal.py +82 -1
  37. singlestoredb/magics/run_shared.py +82 -1
  38. singlestoredb/management/__init__.py +1 -0
  39. singlestoredb/management/cluster.py +1 -1
  40. singlestoredb/management/manager.py +15 -5
  41. singlestoredb/management/region.py +104 -2
  42. singlestoredb/management/workspace.py +174 -3
  43. singlestoredb/tests/ext_funcs/__init__.py +133 -55
  44. singlestoredb/tests/test.sql +22 -0
  45. singlestoredb/tests/test_connection.py +18 -8
  46. singlestoredb/tests/test_ext_func.py +90 -0
  47. singlestoredb/tests/test_management.py +190 -0
  48. singlestoredb/tests/test_udf.py +43 -15
  49. {singlestoredb-1.14.2.dist-info → singlestoredb-1.15.1.dist-info}/METADATA +1 -1
  50. {singlestoredb-1.14.2.dist-info → singlestoredb-1.15.1.dist-info}/RECORD +55 -31
  51. /singlestoredb/functions/{typing.py → typing/__init__.py} +0 -0
  52. {singlestoredb-1.14.2.dist-info → singlestoredb-1.15.1.dist-info}/LICENSE +0 -0
  53. {singlestoredb-1.14.2.dist-info → singlestoredb-1.15.1.dist-info}/WHEEL +0 -0
  54. {singlestoredb-1.14.2.dist-info → singlestoredb-1.15.1.dist-info}/entry_points.txt +0 -0
  55. {singlestoredb-1.14.2.dist-info → singlestoredb-1.15.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,98 @@
1
+ import json
2
+ import time
3
+ from typing import Any
4
+ from typing import Dict
5
+ from typing import Optional
6
+
7
+ from . import utils
8
+
9
+ logger = utils.get_logger('singlestoredb.functions.ext.metrics')
10
+
11
+
12
+ class RoundedFloatEncoder(json.JSONEncoder):
13
+
14
+ def encode(self, obj: Any) -> str:
15
+ if isinstance(obj, dict):
16
+ return '{' + ', '.join(
17
+ f'"{k}": {self._format_value(v)}'
18
+ for k, v in obj.items()
19
+ ) + '}'
20
+ return super().encode(obj)
21
+
22
+ def _format_value(self, value: Any) -> str:
23
+ if isinstance(value, float):
24
+ return f'{value:.2f}'
25
+ return json.dumps(value)
26
+
27
+
28
+ class Timer:
29
+ """
30
+ Timer context manager that supports nested timing using a stack.
31
+
32
+ Example
33
+ -------
34
+ timer = Timer()
35
+
36
+ with timer('total'):
37
+ with timer('receive_data'):
38
+ time.sleep(0.1)
39
+ with timer('parse_input'):
40
+ time.sleep(0.2)
41
+ with timer('call_function'):
42
+ with timer('inner_operation'):
43
+ time.sleep(0.05)
44
+ time.sleep(0.3)
45
+
46
+ print(timer.metrics)
47
+ # {'receive_data': 0.1, 'parse_input': 0.2, 'inner_operation': 0.05,
48
+ # 'call_function': 0.35, 'total': 0.65}
49
+
50
+ """
51
+
52
+ def __init__(self, **kwargs: Any) -> None:
53
+ self.metadata: Dict[str, Any] = kwargs
54
+ self.metrics: Dict[str, float] = dict()
55
+ self.entries: Dict[str, float] = dict()
56
+ self._current_key: Optional[str] = None
57
+ self.start_time = time.perf_counter()
58
+
59
+ def __call__(self, key: str) -> 'Timer':
60
+ self._current_key = key
61
+ return self
62
+
63
+ def __enter__(self) -> 'Timer':
64
+ if self._current_key is None:
65
+ raise ValueError(
66
+ "No key specified. Use timer('key_name') as context manager.",
67
+ )
68
+ self.entries[self._current_key] = time.perf_counter()
69
+ return self
70
+
71
+ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
72
+ key = self._current_key
73
+ if key and key in self.entries:
74
+ start = self.entries.pop(key)
75
+ elapsed = time.perf_counter() - start
76
+ self.metrics[key] = elapsed
77
+ self._current_key = None
78
+
79
+ async def __aenter__(self) -> 'Timer':
80
+ return self.__enter__()
81
+
82
+ async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
83
+ self.__exit__(exc_type, exc_val, exc_tb)
84
+
85
+ def reset(self) -> None:
86
+ self.metrics.clear()
87
+ self.entries.clear()
88
+ self._current_key = None
89
+
90
+ def finish(self) -> None:
91
+ """Finish the current timing context and store the elapsed time."""
92
+ self.metrics['total'] = time.perf_counter() - self.start_time
93
+ self.log_metrics()
94
+
95
+ def log_metrics(self) -> None:
96
+ if self.metadata.get('function'):
97
+ result = dict(type='function_metrics', **self.metadata, **self.metrics)
98
+ logger.info(json.dumps(result, cls=RoundedFloatEncoder))