singlestoredb 1.7.0__cp38-abi3-macosx_10_9_universal2.whl → 1.7.1__cp38-abi3-macosx_10_9_universal2.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.

Binary file
singlestoredb/__init__.py CHANGED
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.7.0'
16
+ __version__ = '1.7.1'
17
17
 
18
18
  from typing import Any
19
19
 
@@ -1,8 +1,10 @@
1
1
  import asyncio
2
+ import textwrap
2
3
  import typing
3
4
  import urllib.parse
4
5
 
5
6
  from ._config import AppConfig
7
+ from ._connection_info import ConnectionInfo
6
8
  from ._process import kill_process_by_port
7
9
 
8
10
  if typing.TYPE_CHECKING:
@@ -17,8 +19,7 @@ async def run_function_app(
17
19
  app: 'FastAPI',
18
20
  log_level: str = 'error',
19
21
  kill_existing_app_server: bool = True,
20
- ) -> None:
21
-
22
+ ) -> ConnectionInfo:
22
23
  global _running_server
23
24
  from ._uvicorn_util import AwaitableUvicornServer
24
25
 
@@ -52,7 +53,7 @@ async def run_function_app(
52
53
  def ping() -> str:
53
54
  return 'Success!'
54
55
 
55
- base_path = urllib.parse.urlparse(app_config.url).path
56
+ base_path = urllib.parse.urlparse(app_config.base_url).path
56
57
  app.root_path = base_path
57
58
 
58
59
  config = uvicorn.Config(
@@ -66,5 +67,26 @@ async def run_function_app(
66
67
  asyncio.create_task(_running_server.serve())
67
68
  await _running_server.wait_for_startup()
68
69
 
70
+ connection_info = ConnectionInfo(app_config.base_url, app_config.token)
71
+
69
72
  if app_config.running_interactively:
70
- print(f'Cloud function available at {app_config.url}')
73
+ if app_config.is_gateway_enabled:
74
+ print(
75
+ 'Cloud function available at '
76
+ f'{app_config.base_url}docs?authToken={app_config.token}',
77
+ )
78
+ else:
79
+ curl_header = f'-H "Authorization: Bearer {app_config.token}"'
80
+ curl_example = f'curl "{app_config.base_url}" {curl_header}'
81
+ print(
82
+ textwrap.dedent(f"""
83
+ Cloud function available at {app_config.base_url}
84
+
85
+ Auth Token: {app_config.token}
86
+
87
+ Curl example: {curl_example}
88
+
89
+ """).strip(),
90
+ )
91
+
92
+ return connection_info
@@ -1,33 +1,63 @@
1
1
  import os
2
2
  from dataclasses import dataclass
3
+ from typing import Optional
3
4
 
4
5
 
5
6
  @dataclass
6
7
  class AppConfig:
7
8
  listen_port: int
8
- url: str
9
+ base_url: str
10
+ app_token: Optional[str]
11
+ user_token: Optional[str]
9
12
  running_interactively: bool
13
+ is_gateway_enabled: bool
10
14
 
11
- @classmethod
12
- def from_env(cls) -> 'AppConfig':
13
- port = os.environ.get('SINGLESTOREDB_APP_LISTEN_PORT')
14
- if port is None:
15
- raise RuntimeError(
16
- 'Missing SINGLESTOREDB_APP_LISTEN_PORT environment variable. '
17
- 'Is the code running outside SingleStoreDB notebook environment?',
18
- )
19
- url = os.environ.get('SINGLESTOREDB_APP_URL')
20
- if url is None:
15
+ @staticmethod
16
+ def _read_variable(name: str) -> str:
17
+ value = os.environ.get(name)
18
+ if value is None:
21
19
  raise RuntimeError(
22
- 'Missing SINGLESTOREDB_APP_URL environment variable. '
20
+ f'Missing {name} environment variable. '
23
21
  'Is the code running outside SingleStoreDB notebook environment?',
24
22
  )
23
+ return value
24
+
25
+ @classmethod
26
+ def from_env(cls) -> 'AppConfig':
27
+ port = cls._read_variable('SINGLESTOREDB_APP_LISTEN_PORT')
28
+ base_url = cls._read_variable('SINGLESTOREDB_APP_BASE_URL')
25
29
 
26
30
  workload_type = os.environ.get('SINGLESTOREDB_WORKLOAD_TYPE')
27
31
  running_interactively = workload_type == 'InteractiveNotebook'
28
32
 
33
+ is_gateway_enabled = 'SINGLESTOREDB_NOVA_GATEWAY_ENDPOINT' in os.environ
34
+
35
+ app_token = os.environ.get('SINGLESTOREDB_APP_TOKEN')
36
+ user_token = os.environ.get('SINGLESTOREDB_USER_TOKEN')
37
+
38
+ # Make sure the required variables are present
39
+ # and present useful error message if not
40
+ if running_interactively:
41
+ if is_gateway_enabled:
42
+ app_token = cls._read_variable('SINGLESTOREDB_APP_TOKEN')
43
+ else:
44
+ user_token = cls._read_variable('SINGLESTOREDB_USER_TOKEN')
45
+
29
46
  return cls(
30
47
  listen_port=int(port),
31
- url=url,
48
+ base_url=base_url,
49
+ app_token=app_token,
50
+ user_token=user_token,
32
51
  running_interactively=running_interactively,
52
+ is_gateway_enabled=is_gateway_enabled,
33
53
  )
54
+
55
+ @property
56
+ def token(self) -> Optional[str]:
57
+ """
58
+ Returns None if running non-interactively
59
+ """
60
+ if self.is_gateway_enabled:
61
+ return self.app_token
62
+ else:
63
+ return self.user_token
@@ -0,0 +1,10 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+
4
+
5
+ @dataclass
6
+ class ConnectionInfo:
7
+ url: str
8
+
9
+ # Only present in interactive mode
10
+ token: Optional[str]
@@ -3,16 +3,18 @@ import urllib.parse
3
3
 
4
4
  from ._config import AppConfig
5
5
  from ._process import kill_process_by_port
6
+ from ._stdout_supress import StdoutSuppressor
7
+ from singlestoredb.apps._connection_info import ConnectionInfo
6
8
 
7
9
  if typing.TYPE_CHECKING:
8
10
  from plotly.graph_objs import Figure
9
11
 
10
12
 
11
- def run_dashboard_app(
13
+ async def run_dashboard_app(
12
14
  figure: 'Figure',
13
15
  debug: bool = False,
14
16
  kill_existing_app_server: bool = True,
15
- ) -> None:
17
+ ) -> ConnectionInfo:
16
18
  try:
17
19
  import dash
18
20
  except ImportError:
@@ -31,7 +33,7 @@ def run_dashboard_app(
31
33
  if kill_existing_app_server:
32
34
  kill_process_by_port(app_config.listen_port)
33
35
 
34
- base_path = urllib.parse.urlparse(app_config.url).path
36
+ base_path = urllib.parse.urlparse(app_config.base_url).path
35
37
 
36
38
  app = dash.Dash(requests_pathname_prefix=base_path)
37
39
  app.layout = dash.html.Div(
@@ -40,12 +42,14 @@ def run_dashboard_app(
40
42
  ],
41
43
  )
42
44
 
43
- app.run(
44
- host='0.0.0.0',
45
- debug=debug,
46
- port=str(app_config.listen_port),
47
- jupyter_mode='external',
48
- )
45
+ with StdoutSuppressor():
46
+ app.run(
47
+ host='0.0.0.0',
48
+ debug=debug,
49
+ port=str(app_config.listen_port),
50
+ jupyter_mode='external',
51
+ )
49
52
 
50
53
  if app_config.running_interactively:
51
- print(f'Dash app available at {app_config.url}')
54
+ print(f'Dash app available at {app_config.base_url}?authToken={app_config.token}')
55
+ return ConnectionInfo(app_config.base_url, app_config.token)
@@ -0,0 +1,30 @@
1
+ import io
2
+ import sys
3
+ from typing import Optional
4
+
5
+
6
+ class StdoutSuppressor:
7
+ """
8
+ Supresses the stdout for code executed within the context.
9
+ This should not be used for asynchronous or threaded executions.
10
+
11
+ ```py
12
+ with Supressor():
13
+ print("This won't be printed")
14
+ ```
15
+
16
+ """
17
+
18
+ def __enter__(self) -> None:
19
+ self.stdout = sys.stdout
20
+ self.buffer = io.StringIO()
21
+ sys.stdout = self.buffer
22
+
23
+ def __exit__(
24
+ self,
25
+ exc_type: Optional[object],
26
+ exc_value: Optional[Exception],
27
+ exc_traceback: Optional[str],
28
+ ) -> None:
29
+ del self.buffer
30
+ sys.stdout = self.stdout
@@ -1432,6 +1432,8 @@ class TestConnection(unittest.TestCase):
1432
1432
  conn.close()
1433
1433
 
1434
1434
  def test_alltypes_polars(self):
1435
+ self.skipTest('Polars API needs to be fixed')
1436
+
1435
1437
  if self.conn.driver in ['http', 'https']:
1436
1438
  self.skipTest('Data API does not surface unsigned int information')
1437
1439
 
@@ -1574,6 +1576,8 @@ class TestConnection(unittest.TestCase):
1574
1576
  conn.close()
1575
1577
 
1576
1578
  def test_alltypes_no_nulls_polars(self):
1579
+ self.skipTest('Polars API needs to be fixed')
1580
+
1577
1581
  if self.conn.driver in ['http', 'https']:
1578
1582
  self.skipTest('Data API does not surface unsigned int information')
1579
1583
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: singlestoredb
3
- Version: 1.7.0
3
+ Version: 1.7.1
4
4
  Summary: Interface to the SingleStoreDB database and workspace management APIs
5
5
  Home-page: https://github.com/singlestore-labs/singlestoredb-python
6
6
  Author: SingleStore
@@ -1,13 +1,13 @@
1
- _singlestoredb_accel.abi3.so,sha256=Bhp_dNISUeLSJN5pSxsh_WwgFz_x1yARhZwlLyxyBuI,206633
2
- singlestoredb-1.7.0.dist-info/RECORD,,
3
- singlestoredb-1.7.0.dist-info/LICENSE,sha256=Mlq78idURT-9G026aMYswwwnnrLcgzTLuXeAs5hjDLM,11341
4
- singlestoredb-1.7.0.dist-info/WHEEL,sha256=_VEguvlLpUd-c8RbFMA4yMIVNMBv2LhpxYLCEQ-Bogk,113
5
- singlestoredb-1.7.0.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
6
- singlestoredb-1.7.0.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
7
- singlestoredb-1.7.0.dist-info/METADATA,sha256=Sz6h_DAWFU2EzH93VB7cVmp837wJz_ReJ6EmmuS0dB8,5570
1
+ _singlestoredb_accel.abi3.so,sha256=OqPy-UWGebajD1O4XJtNQFeGxAIFeEs8cWG2uO5C9NU,206633
2
+ singlestoredb-1.7.1.dist-info/RECORD,,
3
+ singlestoredb-1.7.1.dist-info/LICENSE,sha256=Mlq78idURT-9G026aMYswwwnnrLcgzTLuXeAs5hjDLM,11341
4
+ singlestoredb-1.7.1.dist-info/WHEEL,sha256=_VEguvlLpUd-c8RbFMA4yMIVNMBv2LhpxYLCEQ-Bogk,113
5
+ singlestoredb-1.7.1.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
6
+ singlestoredb-1.7.1.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
7
+ singlestoredb-1.7.1.dist-info/METADATA,sha256=Osc4yfUZBS_Ogzp09d0ZuaShEYrjM0Ps7yIBeh785JY,5570
8
8
  singlestoredb/auth.py,sha256=u8D9tpKzrqa4ssaHjyZnGDX1q8XBpGtuoOkTkSv7B28,7599
9
9
  singlestoredb/config.py,sha256=NtONv4Etpraoy1nenHqRAS08xHJZmho00J95uDjLxQM,12290
10
- singlestoredb/__init__.py,sha256=dYAymV6mtmpkfZMMdLoAUjKcpN7Lh7jEOdNeFM3I7jM,1634
10
+ singlestoredb/__init__.py,sha256=MbDErI01usfGrRDuim_0q51kppgXnuix5LIRnqnkQAk,1634
11
11
  singlestoredb/types.py,sha256=FIqO1A7e0Gkk7ITmIysBy-P5S--ItbMSlYvblzqGS30,9969
12
12
  singlestoredb/connection.py,sha256=x5lINBa9kB_GoEEeL2uUZi9G8pNwKuFtA1uqJirR6HI,45352
13
13
  singlestoredb/pytest.py,sha256=OyF3BO9mgxenifYhOihnzGk8WzCJ_zN5_mxe8XyFPOc,9074
@@ -30,7 +30,7 @@ singlestoredb/tests/test_fusion.py,sha256=W79zv1XcPiiYIYAGtUxLadAMwcJlo2QMmGgU_6
30
30
  singlestoredb/tests/test_plugin.py,sha256=qpO9wmWc62VaijN1sJ97YSYIX7I7Y5C6sY-WzwrutDQ,812
31
31
  singlestoredb/tests/test_basics.py,sha256=1__lEF7FmQF4_pFi5R53TtJidtQznmQ592Ci6aDVgrc,46368
32
32
  singlestoredb/tests/test_ext_func.py,sha256=OWd-CJ1Owhx72nikSWWEF2EQFCJk7vEXZM2Oy9EbYQo,37357
33
- singlestoredb/tests/test_connection.py,sha256=fvn-kPdeIMI9RGNz0dNk5ZmTCep1amwWQDHYfPdqO60,119699
33
+ singlestoredb/tests/test_connection.py,sha256=8F3Q0Q9dJ0Ywa-gb6Z3yH_nY4OECY83TKr9OVM3g17o,119809
34
34
  singlestoredb/tests/test_ext_func_data.py,sha256=yTADD93nPxX6_rZXXLZaOWEI_yPvYyir9psn5PK9ctU,47695
35
35
  singlestoredb/tests/test_exceptions.py,sha256=tfr_8X2w1UmG4nkSBzWGB0C7ehrf1GAVgj6_ODaG-TM,1131
36
36
  singlestoredb/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -122,10 +122,12 @@ singlestoredb/functions/ext/rowdat_1.py,sha256=JgKRsVSQYczFD6cmo2xLilbNPYpyLL2tP
122
122
  singlestoredb/notebook/__init__.py,sha256=v0j1E3MFAtaC8wTrR-F7XY0nytUvQ4XpYhVXddv2xA0,533
123
123
  singlestoredb/notebook/_objects.py,sha256=MkB1eowEq5SQXFHY00xAKAyyeLqHu_uaZiA20BCJPaE,8043
124
124
  singlestoredb/notebook/_portal.py,sha256=DLerIEQmAUymtYcx8RBeuYJ4pJSy_xl1K6t1Oc-eTf8,9698
125
- singlestoredb/apps/_dashboards.py,sha256=dSyc2NO8ocni6HC_ooruokiJgzEYUBLFg4ybS1FD9mM,1272
125
+ singlestoredb/apps/_dashboards.py,sha256=ozee2Tnq8YNdvnxOzltVtukEOckFqp_1Xr8p3idCR9A,1554
126
126
  singlestoredb/apps/__init__.py,sha256=uuEH2WZ1ROpmkMBBdz1tSkQSdYR9blXXU2nn7E5P4qQ,118
127
- singlestoredb/apps/_cloud_functions.py,sha256=qIykvR7TuTXvrNMOi25ejklQx79CpScC3tV49cejJR0,2036
127
+ singlestoredb/apps/_cloud_functions.py,sha256=wlZH9M-rMTMltpB6M-Iv3dKyT9giR8oXoa6bAOizPhY,2777
128
128
  singlestoredb/apps/_uvicorn_util.py,sha256=rEK4nEmq5hbpRgsmK16UVlxe2DyQSq7C5w5WZSp0kX8,962
129
129
  singlestoredb/apps/_process.py,sha256=G37fk6bzIxzhfEqp2aJBk3JCij-T2HFtTd078k5Xq9I,944
130
- singlestoredb/apps/_config.py,sha256=kCkuEnW8rXvGvG48o4QY35PSiIm4AyltqJn_bNoHmDI,1056
130
+ singlestoredb/apps/_stdout_supress.py,sha256=8s9zMIIRPpeu44yluJFc_0VueAxZDmr9QVGT6TGiFeY,659
131
+ singlestoredb/apps/_config.py,sha256=0rRp6iqjnhSlBQRWO4wFpTxM-sOno9kVOz21NAG0wqA,1996
132
+ singlestoredb/apps/_connection_info.py,sha256=gQPYzJrBQUEH76zVTkxJ7FAypNoN2T7GYHVOSgJ7Q8Q,175
131
133
  singlestoredb/alchemy/__init__.py,sha256=dXRThusYrs_9GjrhPOw0-vw94in_T8yY9jE7SGCqiQk,2523