wherobots-python-dbapi 0.19.0__tar.gz → 0.21.0__tar.gz

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.
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wherobots-python-dbapi
3
- Version: 0.19.0
3
+ Version: 0.21.0
4
4
  Summary: Python DB-API driver for Wherobots DB
5
5
  Project-URL: Homepage, https://github.com/wherobots/wherobots-python-dbapi-driver
6
6
  Project-URL: Tracker, https://github.com/wherobots/wherobots-python-dbapi-driver/issues
7
7
  Author-email: Maxime Petazzoni <max@wherobots.com>
8
8
  License-Expression: Apache-2.0
9
9
  License-File: LICENSE
10
- Requires-Python: ~=3.8
10
+ Requires-Python: <4,>=3.8
11
11
  Requires-Dist: cbor2>=5.6.3
12
12
  Requires-Dist: packaging
13
13
  Requires-Dist: pandas
@@ -103,6 +103,12 @@ into. Wherobots Cloud supports the following compute regions:
103
103
  > and customers; other regions are currently reserved to Professional
104
104
  > Edition customers.
105
105
 
106
+ > [!WARNING]
107
+ > To prepare for the expansion of Wherobots Cloud to new regions and cloud providers, the `region` parameter will become mandatory in a future SDK version.
108
+ > Before this support for new regions is added, we will release an updated version of the SDK.
109
+ > While you can continue using an older SDK version for your development,
110
+ > any new or existing SQL session you initialize without specifying the `region` parameter will be hosted in the `aws-us-west-2` region.
111
+
106
112
  ### Advanced parameters
107
113
 
108
114
  The `connect()` method takes some additional parameters that advanced
@@ -123,12 +129,26 @@ users may find useful:
123
129
  to you, if you need to pin your usage to a particular, supported
124
130
  WherobotsDB version. Defaults to `"latest"`.
125
131
  * `session_type`: `"single"` or `"multi"`; if set to `"single"`, then
126
- each call to `connect()` establishes an exclusive connection to a
127
- distinct and dedicated Wherobots runtime; if set to "multi", then
128
- multiple `connect()` calls with the same arguments and credentials
129
- will connect to the same shared Wherobots runtime; `"multi"` is the
130
- default.
131
-
132
- Consider multi-session for potential cost savings, but be mindful of
133
- performance impacts from shared resources. You might need to adjust
134
- cluster size if slowdowns occur, which could affect overall cost.
132
+ each call to `connect()` establishes an exclusive connection to a
133
+ distinct and dedicated Wherobots runtime; if set to "multi", then
134
+ multiple `connect()` calls with the same arguments and credentials
135
+ will connect to the same shared Wherobots runtime; `"multi"` is the
136
+ default.
137
+
138
+ Consider multi-session for potential cost savings, but be mindful of
139
+ performance impacts from shared resources. You might need to adjust
140
+ cluster size if slowdowns occur, which could affect overall cost.
141
+ * `force_new`: passing `force_new=True` forces Wherobots Cloud to create
142
+ and start a new SQL Session runtime for this connection instead of
143
+ attempting to reuse an existing, available one. Note that this can
144
+ severely impact the delay in obtaining a connection to your runtime.
145
+ * `shutdown_after_inactive_seconds`: how long the runtime waits and
146
+ stays running after all clients have disconnected. This delay gives
147
+ an opportunity for clients to reconnect to a previously-established
148
+ runtime without having to start a new one.
149
+
150
+ If you're using a simple "connect-query-disconnect" pattern from
151
+ your application, you can set this parameter to a value greater than
152
+ your expected time between queries and effectively get a continuously
153
+ running SQL session runtime without any complex connection management
154
+ in your application.
@@ -79,6 +79,12 @@ into. Wherobots Cloud supports the following compute regions:
79
79
  > and customers; other regions are currently reserved to Professional
80
80
  > Edition customers.
81
81
 
82
+ > [!WARNING]
83
+ > To prepare for the expansion of Wherobots Cloud to new regions and cloud providers, the `region` parameter will become mandatory in a future SDK version.
84
+ > Before this support for new regions is added, we will release an updated version of the SDK.
85
+ > While you can continue using an older SDK version for your development,
86
+ > any new or existing SQL session you initialize without specifying the `region` parameter will be hosted in the `aws-us-west-2` region.
87
+
82
88
  ### Advanced parameters
83
89
 
84
90
  The `connect()` method takes some additional parameters that advanced
@@ -99,12 +105,26 @@ users may find useful:
99
105
  to you, if you need to pin your usage to a particular, supported
100
106
  WherobotsDB version. Defaults to `"latest"`.
101
107
  * `session_type`: `"single"` or `"multi"`; if set to `"single"`, then
102
- each call to `connect()` establishes an exclusive connection to a
103
- distinct and dedicated Wherobots runtime; if set to "multi", then
104
- multiple `connect()` calls with the same arguments and credentials
105
- will connect to the same shared Wherobots runtime; `"multi"` is the
106
- default.
107
-
108
- Consider multi-session for potential cost savings, but be mindful of
109
- performance impacts from shared resources. You might need to adjust
110
- cluster size if slowdowns occur, which could affect overall cost.
108
+ each call to `connect()` establishes an exclusive connection to a
109
+ distinct and dedicated Wherobots runtime; if set to "multi", then
110
+ multiple `connect()` calls with the same arguments and credentials
111
+ will connect to the same shared Wherobots runtime; `"multi"` is the
112
+ default.
113
+
114
+ Consider multi-session for potential cost savings, but be mindful of
115
+ performance impacts from shared resources. You might need to adjust
116
+ cluster size if slowdowns occur, which could affect overall cost.
117
+ * `force_new`: passing `force_new=True` forces Wherobots Cloud to create
118
+ and start a new SQL Session runtime for this connection instead of
119
+ attempting to reuse an existing, available one. Note that this can
120
+ severely impact the delay in obtaining a connection to your runtime.
121
+ * `shutdown_after_inactive_seconds`: how long the runtime waits and
122
+ stays running after all clients have disconnected. This delay gives
123
+ an opportunity for clients to reconnect to a previously-established
124
+ runtime without having to start a new one.
125
+
126
+ If you're using a simple "connect-query-disconnect" pattern from
127
+ your application, you can set this parameter to a value greater than
128
+ your expected time between queries and effectively get a continuously
129
+ running SQL session runtime without any complex connection management
130
+ in your application.
@@ -1,9 +1,9 @@
1
1
  [project]
2
2
  name = "wherobots-python-dbapi"
3
- version = "0.19.0"
3
+ version = "0.21.0"
4
4
  description = "Python DB-API driver for Wherobots DB"
5
5
  authors = [{ name = "Maxime Petazzoni", email = "max@wherobots.com" }]
6
- requires-python = "~=3.8"
6
+ requires-python = ">=3.8, <4"
7
7
  readme = "README.md"
8
8
  license = "Apache-2.0"
9
9
  dependencies = [
@@ -68,6 +68,7 @@ def connect(
68
68
  wait_timeout: float = DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS,
69
69
  read_timeout: float = DEFAULT_READ_TIMEOUT_SECONDS,
70
70
  session_type: Union[SessionType, None] = None,
71
+ force_new: bool = False,
71
72
  shutdown_after_inactive_seconds: Union[int, None] = None,
72
73
  results_format: Union[ResultsFormat, None] = None,
73
74
  data_compression: Union[DataCompression, None] = None,
@@ -91,7 +92,8 @@ def connect(
91
92
  session_type = session_type or DEFAULT_SESSION_TYPE
92
93
 
93
94
  logging.info(
94
- "Requesting %s runtime running %s in %s from %s ...",
95
+ "Requesting %s%s runtime running %s in %s from %s ...",
96
+ "new " if force_new else "",
95
97
  runtime.value,
96
98
  version,
97
99
  region.value,
@@ -105,7 +107,7 @@ def connect(
105
107
  try:
106
108
  resp = requests.post(
107
109
  url=f"{host}/sql/session",
108
- params={"region": region.value},
110
+ params={"region": region.value, "force_new": force_new},
109
111
  json={
110
112
  "runtimeId": runtime.value,
111
113
  "shutdownAfterInactiveSeconds": shutdown_after_inactive_seconds,
@@ -116,7 +118,15 @@ def connect(
116
118
  )
117
119
  resp.raise_for_status()
118
120
  except requests.HTTPError as e:
119
- raise InterfaceError("Failed to create SQL session!", e)
121
+ details = str(e)
122
+ try:
123
+ info = e.response.json()
124
+ errors = info.get("errors", [])
125
+ if errors and isinstance(errors, list):
126
+ details = f"{errors[0]['message']}: {errors[0]['details']}"
127
+ except requests.JSONDecodeError:
128
+ pass
129
+ raise InterfaceError(f"Failed to create SQL session: {details}") from e
120
130
 
121
131
  # At this point we've been redirected to /sql/session/{session_id}, which we'll need to keep polling until the
122
132
  # session is in READY state.
@@ -2,6 +2,7 @@ from enum import Enum
2
2
 
3
3
 
4
4
  class Runtime(Enum):
5
+ MICRO = "micro"
5
6
  TINY = "tiny"
6
7
  SMALL = "small"
7
8
  MEDIUM = "medium"
@@ -18,6 +19,7 @@ class Runtime(Enum):
18
19
  XXXX_LARGE_HIMEM = "4x-large-himem"
19
20
 
20
21
  # GPU
22
+ MICRO_A10_GPU = "micro-a10-gpu"
21
23
  TINY_A10_GPU = "tiny-a10-gpu"
22
24
  SMALL_A10_GPU = "small-a10-gpu"
23
25
  MEDIUM_A10_GPU = "medium-a10-gpu"