Skip to content

Commit 438c72e

Browse files
authored
Merge pull request #34 from wherobots/simon/session-type-in-request-body
fix: move session type to request body
2 parents 0b1b413 + 355fff2 commit 438c72e

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ users may find useful:
8282
convenient for human inspection while still being usable by
8383
libraries like Shapely.
8484
* `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.
85+
to `connect()` establishes an exclusive connection to a distinct and dedicated
86+
Wherobots runtime; if set to "multi", then multiple `connect()` calls with the
87+
same arguments and credentials will connect to the same shared Wherobots runtime;
88+
`"single"` is the default.
8989

9090
Consider multi-session for potential cost savings, but be mindful of
9191
performance impacts from shared resources. You might need to adjust

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "wherobots-python-dbapi"
33

44
[tool.poetry]
55
name = "wherobots-python-dbapi"
6-
version = "0.12.0"
6+
version = "0.12.1"
77
description = "Python DB-API driver for Wherobots DB"
88
authors = ["Maxime Petazzoni <[email protected]>"]
99
license = "Apache 2.0"

tests/smoke.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@
1111
from rich.table import Table
1212

1313
from wherobots.db import connect, connect_direct
14-
from wherobots.db.constants import DEFAULT_ENDPOINT
14+
from wherobots.db.constants import DEFAULT_ENDPOINT, DEFAULT_SESSION_TYPE
1515
from wherobots.db.connection import Connection
1616
from wherobots.db.region import Region
17+
from wherobots.db.session_type import SessionType
1718

1819
if __name__ == "__main__":
1920
parser = argparse.ArgumentParser()
2021
parser.add_argument("--api-key-file", help="File containing the API key")
2122
parser.add_argument("--token-file", help="File containing the token")
2223
parser.add_argument("--region", help="Region to connect to (ie. aws-us-west-2)")
24+
parser.add_argument(
25+
"--session-type",
26+
help="Type of session to create",
27+
default=DEFAULT_SESSION_TYPE,
28+
choices=[st.value for st in SessionType],
29+
)
2330
parser.add_argument(
2431
"--debug",
2532
help="Enable debug logging",
@@ -76,6 +83,7 @@
7683
shutdown_after_inactive_seconds=args.shutdown_after_inactive_seconds,
7784
wait_timeout=900,
7885
region=Region(args.region) if args.region else Region.AWS_US_WEST_2,
86+
session_type=SessionType(args.session_type),
7987
)
8088

8189
def render(results: pandas.DataFrame) -> None:

wherobots/db/driver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ def connect(
100100
try:
101101
resp = requests.post(
102102
url=f"{host}/sql/session",
103-
params={"region": region.value, "sessionType": session_type.value},
103+
params={"region": region.value},
104104
json={
105105
"runtimeId": runtime.value,
106106
"shutdownAfterInactiveSeconds": shutdown_after_inactive_seconds,
107+
"sessionType": session_type.value,
107108
},
108109
headers=headers,
109110
)

0 commit comments

Comments
 (0)