wherobots-python-dbapi 0.11.1__tar.gz → 0.12.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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wherobots-python-dbapi
3
- Version: 0.11.1
3
+ Version: 0.12.0
4
4
  Summary: Python DB-API driver for Wherobots DB
5
5
  License: Apache 2.0
6
6
  Author: Maxime Petazzoni
@@ -109,7 +109,13 @@ users may find useful:
109
109
  client application. The default is EWKT (string) and the most
110
110
  convenient for human inspection while still being usable by
111
111
  libraries like Shapely.
112
- * `reuse_session`: controls whether an existing runtime of the same type
113
- and in the same region that is available should be reused for this
114
- connection. This is the default behavior.
112
+ * `session_type`: `"single"` or `"multi"`; if set to `"single"`, then each call
113
+ to `Connection.connect()` establishes an exclusive connection to a
114
+ Wherobots runtime; if set to "multi", then multiple `Connection.connect()`
115
+ calls with the same arguments and credentials will connect to the same
116
+ shared Wherobots runtime; `"single"` is the default.
117
+
118
+ Consider multi-session for potential cost savings, but be mindful of
119
+ performance impacts from shared resources. You might need to adjust
120
+ cluster size if slowdowns occur, which could affect overall cost.
115
121
 
@@ -81,6 +81,12 @@ users may find useful:
81
81
  client application. The default is EWKT (string) and the most
82
82
  convenient for human inspection while still being usable by
83
83
  libraries like Shapely.
84
- * `reuse_session`: controls whether an existing runtime of the same type
85
- and in the same region that is available should be reused for this
86
- connection. This is the default behavior.
84
+ * `session_type`: `"single"` or `"multi"`; if set to `"single"`, then each call
85
+ to `Connection.connect()` establishes an exclusive connection to a
86
+ Wherobots runtime; if set to "multi", then multiple `Connection.connect()`
87
+ calls with the same arguments and credentials will connect to the same
88
+ shared Wherobots runtime; `"single"` is the default.
89
+
90
+ Consider multi-session for potential cost savings, but be mindful of
91
+ performance impacts from shared resources. You might need to adjust
92
+ cluster size if slowdowns occur, which could affect overall cost.
@@ -3,7 +3,7 @@ name = "wherobots-python-dbapi"
3
3
 
4
4
  [tool.poetry]
5
5
  name = "wherobots-python-dbapi"
6
- version = "0.11.1"
6
+ version = "0.12.0"
7
7
  description = "Python DB-API driver for Wherobots DB"
8
8
  authors = ["Maxime Petazzoni <max@wherobots.com>"]
9
9
  license = "Apache 2.0"
@@ -4,6 +4,7 @@ from strenum import LowercaseStrEnum, StrEnum
4
4
 
5
5
  from .region import Region
6
6
  from .runtime import Runtime
7
+ from .session_type import SessionType
7
8
 
8
9
 
9
10
  DEFAULT_ENDPOINT: str = "api.cloud.wherobots.com" # "api.cloud.wherobots.com"
@@ -11,9 +12,9 @@ STAGING_ENDPOINT: str = "api.staging.wherobots.com" # "api.staging.wherobots.co
11
12
 
12
13
  DEFAULT_RUNTIME: Runtime = Runtime.TINY
13
14
  DEFAULT_REGION: Region = Region.AWS_US_WEST_2
15
+ DEFAULT_SESSION_TYPE: SessionType = SessionType.SINGLE
14
16
  DEFAULT_READ_TIMEOUT_SECONDS: float = 0.25
15
17
  DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS: float = 900
16
- DEFAULT_REUSE_SESSION: bool = True
17
18
 
18
19
  MAX_MESSAGE_SIZE: int = 100 * 2**20 # 100MiB
19
20
  PROTOCOL_VERSION: Version = Version("1.0.0")
@@ -2,6 +2,7 @@
2
2
 
3
3
  A PEP-0249 compatible driver for interfacing with Wherobots DB.
4
4
  """
5
+
5
6
  import ssl
6
7
  from importlib import metadata
7
8
  from importlib.metadata import PackageNotFoundError
@@ -19,9 +20,9 @@ from .connection import Connection
19
20
  from .constants import (
20
21
  DEFAULT_ENDPOINT,
21
22
  DEFAULT_REGION,
22
- DEFAULT_REUSE_SESSION,
23
23
  DEFAULT_RUNTIME,
24
24
  DEFAULT_READ_TIMEOUT_SECONDS,
25
+ DEFAULT_SESSION_TYPE,
25
26
  DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS,
26
27
  MAX_MESSAGE_SIZE,
27
28
  PROTOCOL_VERSION,
@@ -29,6 +30,7 @@ from .constants import (
29
30
  DataCompression,
30
31
  GeometryRepresentation,
31
32
  ResultsFormat,
33
+ SessionType,
32
34
  )
33
35
  from .errors import (
34
36
  InterfaceError,
@@ -56,13 +58,13 @@ def gen_user_agent_header():
56
58
 
57
59
  def connect(
58
60
  host: str = DEFAULT_ENDPOINT,
59
- token: str = None,
60
- api_key: str = None,
61
- runtime: Runtime = None,
62
- region: Region = None,
61
+ token: Union[str, None] = None,
62
+ api_key: Union[str, None] = None,
63
+ runtime: Union[Runtime, None] = None,
64
+ region: Union[Region, None] = None,
63
65
  wait_timeout: float = DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS,
64
66
  read_timeout: float = DEFAULT_READ_TIMEOUT_SECONDS,
65
- reuse_session: bool = DEFAULT_REUSE_SESSION,
67
+ session_type: Union[SessionType, None] = None,
66
68
  shutdown_after_inactive_seconds: Union[int, None] = None,
67
69
  results_format: Union[ResultsFormat, None] = None,
68
70
  data_compression: Union[DataCompression, None] = None,
@@ -82,10 +84,10 @@ def connect(
82
84
  host = host or DEFAULT_ENDPOINT
83
85
  runtime = runtime or DEFAULT_RUNTIME
84
86
  region = region or DEFAULT_REGION
87
+ session_type = session_type or DEFAULT_SESSION_TYPE
85
88
 
86
89
  logging.info(
87
- "%s %s runtime in %s from %s ...",
88
- "Recycling" if reuse_session else "Requesting",
90
+ "Requesting %s runtime in %s from %s ...",
89
91
  runtime.value,
90
92
  region.value,
91
93
  host,
@@ -98,7 +100,7 @@ def connect(
98
100
  try:
99
101
  resp = requests.post(
100
102
  url=f"{host}/sql/session",
101
- params={"region": region.value, "reuse_session": reuse_session},
103
+ params={"region": region.value, "sessionType": session_type.value},
102
104
  json={
103
105
  "runtimeId": runtime.value,
104
106
  "shutdownAfterInactiveSeconds": shutdown_after_inactive_seconds,
@@ -163,7 +165,7 @@ def http_to_ws(uri: str) -> str:
163
165
  def connect_direct(
164
166
  uri: str,
165
167
  protocol: Version = PROTOCOL_VERSION,
166
- headers: Dict[str, str] = None,
168
+ headers: Union[Dict[str, str], None] = None,
167
169
  read_timeout: float = DEFAULT_READ_TIMEOUT_SECONDS,
168
170
  results_format: Union[ResultsFormat, None] = None,
169
171
  data_compression: Union[DataCompression, None] = None,
@@ -3,3 +3,4 @@ from enum import Enum
3
3
 
4
4
  class Region(Enum):
5
5
  AWS_US_WEST_2 = "aws-us-west-2"
6
+ AWS_EU_EAST_1 = "aws-eu-west-1"
@@ -0,0 +1,7 @@
1
+ from enum import auto
2
+ from strenum import LowercaseStrEnum
3
+
4
+
5
+ class SessionType(LowercaseStrEnum):
6
+ SINGLE = auto()
7
+ MULTI = auto()