singlestoredb 1.0.0__cp38-abi3-win_amd64.whl → 1.0.2__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.

_singlestoredb_accel.pyd CHANGED
Binary file
singlestoredb/__init__.py CHANGED
@@ -13,7 +13,7 @@ Examples
13
13
 
14
14
  """
15
15
 
16
- __version__ = '1.0.0'
16
+ __version__ = '1.0.2'
17
17
 
18
18
  from typing import Any
19
19
 
@@ -18,11 +18,12 @@ An example of starting a server is shown below.
18
18
 
19
19
  Example
20
20
  -------
21
- $ SINGLESTOREDB_EXT_FUNCTIONS='myfuncs.[percentage_90,percentage_95]' \
21
+ $ SINGLESTOREDB_EXT_FUNCTIONS='myfuncs.[percentile_90,percentile_95]' \
22
22
  uvicorn --factory singlestoredb.functions.ext:create_app
23
23
 
24
24
  '''
25
25
  import importlib.util
26
+ import io
26
27
  import itertools
27
28
  import os
28
29
  import urllib
@@ -184,7 +185,7 @@ def make_func(name: str, func: Callable[..., Any]) -> Callable[..., Any]:
184
185
  return do_func
185
186
 
186
187
 
187
- def create_app(
188
+ def create_app( # noqa: C901
188
189
  functions: Optional[
189
190
  Union[
190
191
  str,
@@ -539,4 +540,44 @@ def create_app(
539
540
 
540
541
  app.drop_functions = drop_functions # type: ignore
541
542
 
543
+ async def call(
544
+ name: str,
545
+ data_in: io.BytesIO,
546
+ data_out: io.BytesIO,
547
+ data_format: str = 'rowdat_1',
548
+ data_version: str = '1.0',
549
+ ) -> None:
550
+
551
+ async def receive() -> Dict[str, Any]:
552
+ return dict(body=data_in.read())
553
+
554
+ async def send(content: Dict[str, Any]) -> None:
555
+ status = content.get('status', 200)
556
+ if status != 200:
557
+ raise KeyError(f'error occurred when calling `{name}`: {status}')
558
+ data_out.write(content.get('body', b''))
559
+
560
+ accepts = dict(
561
+ json=b'application/json',
562
+ rowdat_1=b'application/octet-stream',
563
+ arrow=b'application/vnd.apache.arrow.file',
564
+ )
565
+
566
+ # Mock an ASGI scope
567
+ scope = dict(
568
+ type='http',
569
+ path='invoke',
570
+ method='POST',
571
+ headers={
572
+ b'content-type': accepts[data_format.lower()],
573
+ b'accepts': accepts[data_format.lower()],
574
+ b's2-ef-name': name.encode('utf-8'),
575
+ b's2-ef-version': data_version.encode('utf-8'),
576
+ },
577
+ )
578
+
579
+ await app(scope, receive, send)
580
+
581
+ app.call = call # type: ignore
582
+
542
583
  return app
@@ -315,8 +315,8 @@ def _dump_vectors(
315
315
 
316
316
  def dump_pandas(
317
317
  returns: List[int],
318
- row_ids: List[int],
319
- cols: List[Tuple[Any, Any]],
318
+ row_ids: 'pd.Series[int]',
319
+ cols: List[Tuple['pd.Series[int]', 'pd.Series[bool]']],
320
320
  ) -> bytes:
321
321
  '''
322
322
  Convert a list of pd.Series of data into JSON format.
@@ -336,6 +336,7 @@ def dump_pandas(
336
336
 
337
337
  '''
338
338
  import pandas as pd
339
+ row_ids.index = row_ids
339
340
  df = pd.concat([row_ids] + [x[0] for x in cols], axis=1)
340
341
  return ('{"data": %s}' % df.to_json(orient='values')).encode('utf-8')
341
342
 
@@ -218,9 +218,9 @@ class DropStageFolderHandler(SQLHandler):
218
218
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
219
219
  wg = get_workspace_group(params)
220
220
  if params['recursive']:
221
- wg.stage.rmdir(params['stage_path'])
222
- else:
223
221
  wg.stage.removedirs(params['stage_path'])
222
+ else:
223
+ wg.stage.rmdir(params['stage_path'])
224
224
  return None
225
225
 
226
226
 
@@ -128,8 +128,6 @@ class ShowFusionCommandsHandler(SQLHandler):
128
128
 
129
129
  data: List[Tuple[Any, ...]] = []
130
130
  for _, v in sorted(_handlers.items()):
131
- if v is type(self):
132
- continue
133
131
  data.append((v.help.lstrip(),))
134
132
 
135
133
  res.set_rows(data)
@@ -2,4 +2,5 @@
2
2
  from .cluster import manage_cluster
3
3
  from .manager import get_organization
4
4
  from .manager import get_token
5
+ from .workspace import get_secret
5
6
  from .workspace import manage_workspaces
@@ -57,14 +57,15 @@ class Manager(object):
57
57
  base_url: Optional[str] = None, *, organization_id: Optional[str] = None,
58
58
  ):
59
59
  from .. import __version__ as client_version
60
- access_token = (
60
+ new_access_token = (
61
61
  access_token or get_token()
62
62
  )
63
- if not access_token:
63
+ if not new_access_token:
64
64
  raise ManagementError(msg='No management token was configured.')
65
+ self._is_jwt = not access_token and new_access_token and is_jwt(new_access_token)
65
66
  self._sess = requests.Session()
66
67
  self._sess.headers.update({
67
- 'Authorization': f'Bearer {access_token}',
68
+ 'Authorization': f'Bearer {new_access_token}',
68
69
  'Content-Type': 'application/json',
69
70
  'Accept': 'application/json',
70
71
  'User-Agent': f'SingleStoreDB-Python/{client_version}',
@@ -116,6 +117,9 @@ class Manager(object):
116
117
  **kwargs: Any,
117
118
  ) -> requests.Response:
118
119
  """Perform HTTP request."""
120
+ # Refresh the JWT as needed
121
+ if self._is_jwt:
122
+ self._sess.headers.update({'Authorization': f'Bearer {get_token()}'})
119
123
  return getattr(self._sess, method.lower())(
120
124
  urljoin(self._base_url, path), *args, **kwargs,
121
125
  )
@@ -7,6 +7,7 @@ import glob
7
7
  import io
8
8
  import os
9
9
  import re
10
+ import socket
10
11
  import time
11
12
  from typing import Any
12
13
  from typing import BinaryIO
@@ -31,6 +32,11 @@ from .utils import ttl_property
31
32
  from .utils import vars_to_str
32
33
 
33
34
 
35
+ def get_secret(name: str) -> str:
36
+ """Get a secret from the organization."""
37
+ return manage_workspaces().organization.get_secret(name).value
38
+
39
+
34
40
  class StageObject(object):
35
41
  """
36
42
  Stage file / folder object.
@@ -1334,7 +1340,7 @@ class WorkspaceGroup(object):
1334
1340
  def create_workspace(
1335
1341
  self, name: str, size: Optional[str] = None,
1336
1342
  wait_on_active: bool = False, wait_interval: int = 10,
1337
- wait_timeout: int = 600,
1343
+ wait_timeout: int = 600, add_endpoint_to_firewall_ranges: bool = True,
1338
1344
  ) -> Workspace:
1339
1345
  """
1340
1346
  Create a new workspace.
@@ -1352,6 +1358,9 @@ class WorkspaceGroup(object):
1352
1358
  if wait=True
1353
1359
  wait_interval : int, optional
1354
1360
  Number of seconds between each polling interval
1361
+ add_endpoint_to_firewall_ranges : bool, optional
1362
+ Should the workspace endpoint be added to the workspace group
1363
+ firewall ranges?
1355
1364
 
1356
1365
  Returns
1357
1366
  -------
@@ -1362,11 +1371,18 @@ class WorkspaceGroup(object):
1362
1371
  raise ManagementError(
1363
1372
  msg='No workspace manager is associated with this object.',
1364
1373
  )
1365
- return self._manager.create_workspace(
1374
+
1375
+ out = self._manager.create_workspace(
1366
1376
  name=name, workspace_group=self, size=size, wait_on_active=wait_on_active,
1367
1377
  wait_interval=wait_interval, wait_timeout=wait_timeout,
1368
1378
  )
1369
1379
 
1380
+ if add_endpoint_to_firewall_ranges and out.endpoint is not None:
1381
+ ip_address = '{}/32'.format(socket.gethostbyname(out.endpoint))
1382
+ self.update(firewall_ranges=self.firewall_ranges+[ip_address])
1383
+
1384
+ return out
1385
+
1370
1386
  @property
1371
1387
  def workspaces(self) -> NamedList[Workspace]:
1372
1388
  """Return a list of available workspaces."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: singlestoredb
3
- Version: 1.0.0
3
+ Version: 1.0.2
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
@@ -38,18 +38,13 @@ Requires-Dist: pytest ; extra == 'pytest'
38
38
  Provides-Extra: rsa
39
39
  Requires-Dist: cryptography ; extra == 'rsa'
40
40
  Provides-Extra: sqlalchemy
41
- Requires-Dist: sqlalchemy-singlestoredb ; extra == 'sqlalchemy'
41
+ Requires-Dist: sqlalchemy-singlestoredb >=1.0.0 ; extra == 'sqlalchemy'
42
42
 
43
- # <img src="https://github.com/singlestore-labs/singlestoredb-python/blob/main/resources/singlestore-logo.png" height="60" valign="middle"/> SingleStoreDB Python Interface
43
+ # <img src="https://github.com/singlestore-labs/singlestoredb-python/blob/main/resources/singlestore-logo.png" height="60" valign="middle"/> SingleStoreDB Python SDK
44
44
 
45
45
  This project contains a [DB-API 2.0](https://www.python.org/dev/peps/pep-0249/)
46
46
  compatible Python interface to the SingleStore database and workspace management API.
47
47
 
48
- > **Warning**
49
- > As of version v0.5.0, the parameter substitution syntax has changed from `:1`, `:2`, etc.
50
- > for list parameters and `:foo`, `:bar`, etc. for dictionary parameters to `%s` and `%(foo)s`,
51
- > `%(bar)s` etc., respectively.
52
-
53
48
  ## Install
54
49
 
55
50
  This package can be install from PyPI using `pip`:
@@ -142,17 +137,3 @@ This library is licensed under the [Apache 2.0 License](https://raw.githubuserco
142
137
 
143
138
  * [SingleStore](https://singlestore.com)
144
139
  * [Python](https://python.org)
145
-
146
- ## User agreement
147
-
148
- SINGLESTORE, INC. ("SINGLESTORE") AGREES TO GRANT YOU AND YOUR COMPANY ACCESS TO THIS OPEN SOURCE SOFTWARE CONNECTOR ONLY IF (A) YOU AND YOUR COMPANY REPRESENT AND WARRANT THAT YOU, ON BEHALF OF YOUR COMPANY, HAVE THE AUTHORITY TO LEGALLY BIND YOUR COMPANY AND (B) YOU, ON BEHALF OF YOUR COMPANY ACCEPT AND AGREE TO BE BOUND BY ALL OF THE OPEN SOURCE TERMS AND CONDITIONS APPLICABLE TO THIS OPEN SOURCE CONNECTOR AS SET FORTH BELOW (THIS “AGREEMENT”), WHICH SHALL BE DEFINITIVELY EVIDENCED BY ANY ONE OF THE FOLLOWING MEANS: YOU, ON BEHALF OF YOUR COMPANY, CLICKING THE “DOWNLOAD, “ACCEPTANCE” OR “CONTINUE” BUTTON, AS APPLICABLE OR COMPANY’S INSTALLATION, ACCESS OR USE OF THE OPEN SOURCE CONNECTOR AND SHALL BE EFFECTIVE ON THE EARLIER OF THE DATE ON WHICH THE DOWNLOAD, ACCESS, COPY OR INSTALL OF THE CONNECTOR OR USE ANY SERVICES (INCLUDING ANY UPDATES OR UPGRADES) PROVIDED BY SINGLESTORE.
149
- BETA SOFTWARE CONNECTOR
150
-
151
- Customer Understands and agrees that it is being granted access to pre-release or “beta” versions of SingleStore’s open source software connector (“Beta Software Connector”) for the limited purposes of non-production testing and evaluation of such Beta Software Connector. Customer acknowledges that SingleStore shall have no obligation to release a generally available version of such Beta Software Connector or to provide support or warranty for such versions of the Beta Software Connector for any production or non-evaluation use.
152
-
153
- NOTWITHSTANDING ANYTHING TO THE CONTRARY IN ANY DOCUMENTATION, AGREEMENT OR IN ANY ORDER DOCUMENT, SINGLESTORE WILL HAVE NO WARRANTY, INDEMNITY, SUPPORT, OR SERVICE LEVEL, OBLIGATIONS WITH
154
- RESPECT TO THIS BETA SOFTWARE CONNECTOR (INCLUDING TOOLS AND UTILITIES).
155
-
156
- APPLICABLE OPEN SOURCE LICENSE: Apache 2.0
157
-
158
- IF YOU OR YOUR COMPANY DO NOT AGREE TO THESE TERMS AND CONDITIONS, DO NOT CHECK THE ACCEPTANCE BOX, AND DO NOT DOWNLOAD, ACCESS, COPY, INSTALL OR USE THE SOFTWARE OR THE SERVICES.
@@ -1,5 +1,5 @@
1
- _singlestoredb_accel.pyd,sha256=heqJggz9vA1cTfF9Vzb7W7fhxMcsdgoRJJQhYbr5Pco,56832
2
- singlestoredb/__init__.py,sha256=Dow95NwX5kPd1wP_DIP-H_TOSPSjL4I2c9pt4akQNB4,1697
1
+ _singlestoredb_accel.pyd,sha256=TvXWAA_xqnLgJC73ZMDLnVu92inM92_lXgdTBwuntIg,56832
2
+ singlestoredb/__init__.py,sha256=QUULd5Cdoh9hxuxYZXVAss5PoWN6LFGnPhwtnhQt51o,1697
3
3
  singlestoredb/auth.py,sha256=RmYiH0Wlc2RXc4pTlRMysxtBI445ggCIwojWKC_eDLE,7844
4
4
  singlestoredb/config.py,sha256=Uq7LWKlIwMAJC3_G3j5dUIQVJf2JzbDVtRK6votjuDw,7746
5
5
  singlestoredb/connection.py,sha256=gSKmMN1d_ZSXVTmzfuHK3BXcLyNGiaSi2Vy6z7nymjg,45657
@@ -14,28 +14,28 @@ singlestoredb/functions/dtypes.py,sha256=gwDokEe7P8gvvld158CWoCKsb6Sv-77FzeKXMQi
14
14
  singlestoredb/functions/signature.py,sha256=5RGRspj_au0YJfRFeUjRmQMFzvg3a0RCpMb_uA1Poi8,20025
15
15
  singlestoredb/functions/ext/__init__.py,sha256=NrwbyL86NeG_Kv1N23R4VwL1Ap-pY9Z1By6vnKzyZBE,68
16
16
  singlestoredb/functions/ext/arrow.py,sha256=mQhwaMpvCH_dP92WIhP_j-stu272n4UAHsFUOBTgnq0,9436
17
- singlestoredb/functions/ext/asgi.py,sha256=o0epdRGUfhRWRg2t3_FNNiKDwv0HFJEtC-usCx0ko5I,18204
18
- singlestoredb/functions/ext/json.py,sha256=HOyTpgYsqCAcfeSdH_oAmEu9JivaM1HlA4fXsiWNYHM,10736
17
+ singlestoredb/functions/ext/asgi.py,sha256=n5c6U7yWyu23Cgkm8pGJyY9FJ2JRp_sih7zl932wLgU,19494
18
+ singlestoredb/functions/ext/json.py,sha256=h0n4BZCbOWUM2le6wiysZR16bku_xgOMGmjN4Qx3Hw4,10799
19
19
  singlestoredb/functions/ext/rowdat_1.py,sha256=24mNX-1Z-ala6QwSj4_WPNk4oxbruRtCBXZoFIYqUt8,23018
20
20
  singlestoredb/fusion/__init__.py,sha256=FHWtrg6OJFTf6Ye197V5sU6ssryr2h6FBcDIgXP7-H4,367
21
21
  singlestoredb/fusion/graphql.py,sha256=SHqsPe4xgawdsTPHEtJGQlybYGWqPrGMmyK-v20RLac,5420
22
22
  singlestoredb/fusion/handler.py,sha256=giIk4KwB0xYEaLnPJNUwBul1UWunG8TgWSecjo5EJ9w,18959
23
- singlestoredb/fusion/registry.py,sha256=fOaOGkxBbS297TlSUOKExzjNXwo9_WIxD-l3H1ZexM4,4307
23
+ singlestoredb/fusion/registry.py,sha256=9XBKuuCEBZMX9F_W993bxYezFvruWJRr7_nC39qwFxc,4248
24
24
  singlestoredb/fusion/result.py,sha256=EcFY5Qv43ySlQsfl_JB-I3ko7PzVdjuhhoKN96uHSAM,12171
25
25
  singlestoredb/fusion/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- singlestoredb/fusion/handlers/stage.py,sha256=o0o6ev63OmDtbiEVXV8AYGbTKuS8fFB4Ydq7ptdGqq8,6643
26
+ singlestoredb/fusion/handlers/stage.py,sha256=GtjssF28XoMPAjaM-DDtaRpm-WFUx0sVFJKBH0XcH70,6643
27
27
  singlestoredb/fusion/handlers/utils.py,sha256=7xWb_1mJzxW0po9iHVY2ZVnRvHIQgOlKZQZ1zllJBjk,5271
28
28
  singlestoredb/fusion/handlers/workspace.py,sha256=ulxyFFLVpam83fPHI87Bwqc2V6AoGGHM-W8en3xq75s,11754
29
29
  singlestoredb/http/__init__.py,sha256=4cEDvLloGc3LSpU-PnIwacyu0n5oIIIE6xk2SPyWD_w,939
30
30
  singlestoredb/http/connection.py,sha256=8JO08meeJFHtTEqFSb_ju3dCVPLL8jQ4CLESeJ-JRyw,38602
31
- singlestoredb/management/__init__.py,sha256=kdKM-wErALWaEHYBLx_raHkJ8xUvUPflhOk8OBJyn58,173
31
+ singlestoredb/management/__init__.py,sha256=1xAck9ehp2aGsDMAk5paS1Ek1EdjkDlpG1GqMJwm7h0,208
32
32
  singlestoredb/management/billing_usage.py,sha256=0UHFSPCrN0nyeGFFM-HXS3NP8pYmYo2BCCahDEPXvzg,3883
33
33
  singlestoredb/management/cluster.py,sha256=0GhpuSt_rcFz5f1hzcRHK911KWFewljlV4GFtckB8uM,14822
34
- singlestoredb/management/manager.py,sha256=w9QVuj-zn5ubLOLx36bsW-Ok6KFzZRMU8ElG6hEJY9k,8812
34
+ singlestoredb/management/manager.py,sha256=_IDqeixakf5tlYRr1Nfsp2a7yU7_8K-YRq3IpMr_ewk,9061
35
35
  singlestoredb/management/organization.py,sha256=EywczC4uU1i70x_OkSqKnP6V_9D-ZuHBlETCogvJk_8,5104
36
36
  singlestoredb/management/region.py,sha256=oGoLLS88dE1GmY7GCc0BV7X3f7bWwKQyeXOVBFmK9Pk,1678
37
37
  singlestoredb/management/utils.py,sha256=Q9GXxbbSbYYFLHeCI9LSR1FqZarSAMvVdrMxq3JfjeQ,8613
38
- singlestoredb/management/workspace.py,sha256=Dnxk19hdKwd8SPO9Bf50fVnr-DQMW4AwvATpQEcTqkw,52966
38
+ singlestoredb/management/workspace.py,sha256=1ymFz45UH5VtkTgVO9bEtzf9UeWxQawUSQILumxMXXc,53596
39
39
  singlestoredb/mysql/__init__.py,sha256=CbpwzNUJPAmKPpIobC0-ugBta_RgHCMq7X7N75QLReY,4669
40
40
  singlestoredb/mysql/_auth.py,sha256=YaqqyvAHmeraBv3BM207rNveUVPM-mPnW20ts_ynVWg,8341
41
41
  singlestoredb/mysql/charset.py,sha256=mnCdMpvdub1S2mm2PSk2j5JddgsWRjsVLtGx-y9TskE,10724
@@ -104,9 +104,9 @@ singlestoredb/utils/debug.py,sha256=y7dnJeJGt3U_BWXz9pLt1qNQREpPtumYX_sk1DiqG6Y,
104
104
  singlestoredb/utils/mogrify.py,sha256=gCcn99-vgsGVjTUV7RHJ6hH4vCNrsGB_Xo4z8kiSPDQ,4201
105
105
  singlestoredb/utils/results.py,sha256=ely2XVAHHejObjLibS3UcrPOuCO2g5aRtA3PxAMtE-g,5432
106
106
  singlestoredb/utils/xdict.py,sha256=-wi1lSPTnY99fhVMBhPKJ8cCsQhNG4GMUfkEBDKYgCw,13321
107
- singlestoredb-1.0.0.dist-info/LICENSE,sha256=Bojenzui8aPNjlF3w4ojguDP7sTf8vFV_9Gc2UAG1sg,11542
108
- singlestoredb-1.0.0.dist-info/METADATA,sha256=4LzHkTaogDPBY1ZkmqQLoTfQUU6o_jRueZQHexhLeMI,7898
109
- singlestoredb-1.0.0.dist-info/WHEEL,sha256=UyMHzmWA0xVqVPKfTiLs2eN3OWWZUl-kQemNbpIqlKo,100
110
- singlestoredb-1.0.0.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
111
- singlestoredb-1.0.0.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
112
- singlestoredb-1.0.0.dist-info/RECORD,,
107
+ singlestoredb-1.0.2.dist-info/LICENSE,sha256=Bojenzui8aPNjlF3w4ojguDP7sTf8vFV_9Gc2UAG1sg,11542
108
+ singlestoredb-1.0.2.dist-info/METADATA,sha256=f8iyBg2HQwK1qbaBzuDwmz76OikJXJ0DFEE0ayz6qlY,5654
109
+ singlestoredb-1.0.2.dist-info/WHEEL,sha256=UyMHzmWA0xVqVPKfTiLs2eN3OWWZUl-kQemNbpIqlKo,100
110
+ singlestoredb-1.0.2.dist-info/entry_points.txt,sha256=bSLaTWB5zGjpVYPAaI46MkkDup0su-eb3uAhCNYuRV0,48
111
+ singlestoredb-1.0.2.dist-info/top_level.txt,sha256=SDtemIXf-Kp-_F2f_S6x0db33cHGOILdAEsIQZe2LZc,35
112
+ singlestoredb-1.0.2.dist-info/RECORD,,