Skip to content

Commit

Permalink
Merge pull request #34 from wherobots/simon/session-type-in-request-body
Browse files Browse the repository at this point in the history
fix: move session type to request body
  • Loading branch information
sfishel18 authored Mar 5, 2025
2 parents 0b1b413 + 355fff2 commit 438c72e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ users may find useful:
convenient for human inspection while still being usable by
libraries like Shapely.
* `session_type`: `"single"` or `"multi"`; if set to `"single"`, then each call
to `Connection.connect()` establishes an exclusive connection to a
Wherobots runtime; if set to "multi", then multiple `Connection.connect()`
calls with the same arguments and credentials will connect to the same
shared Wherobots runtime; `"single"` is the default.
to `connect()` establishes an exclusive connection to a distinct and dedicated
Wherobots runtime; if set to "multi", then multiple `connect()` calls with the
same arguments and credentials will connect to the same shared Wherobots runtime;
`"single"` is the default.

Consider multi-session for potential cost savings, but be mindful of
performance impacts from shared resources. You might need to adjust
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "wherobots-python-dbapi"

[tool.poetry]
name = "wherobots-python-dbapi"
version = "0.12.0"
version = "0.12.1"
description = "Python DB-API driver for Wherobots DB"
authors = ["Maxime Petazzoni <[email protected]>"]
license = "Apache 2.0"
Expand Down
10 changes: 9 additions & 1 deletion tests/smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@
from rich.table import Table

from wherobots.db import connect, connect_direct
from wherobots.db.constants import DEFAULT_ENDPOINT
from wherobots.db.constants import DEFAULT_ENDPOINT, DEFAULT_SESSION_TYPE
from wherobots.db.connection import Connection
from wherobots.db.region import Region
from wherobots.db.session_type import SessionType

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--api-key-file", help="File containing the API key")
parser.add_argument("--token-file", help="File containing the token")
parser.add_argument("--region", help="Region to connect to (ie. aws-us-west-2)")
parser.add_argument(
"--session-type",
help="Type of session to create",
default=DEFAULT_SESSION_TYPE,
choices=[st.value for st in SessionType],
)
parser.add_argument(
"--debug",
help="Enable debug logging",
Expand Down Expand Up @@ -76,6 +83,7 @@
shutdown_after_inactive_seconds=args.shutdown_after_inactive_seconds,
wait_timeout=900,
region=Region(args.region) if args.region else Region.AWS_US_WEST_2,
session_type=SessionType(args.session_type),
)

def render(results: pandas.DataFrame) -> None:
Expand Down
3 changes: 2 additions & 1 deletion wherobots/db/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ def connect(
try:
resp = requests.post(
url=f"{host}/sql/session",
params={"region": region.value, "sessionType": session_type.value},
params={"region": region.value},
json={
"runtimeId": runtime.value,
"shutdownAfterInactiveSeconds": shutdown_after_inactive_seconds,
"sessionType": session_type.value,
},
headers=headers,
)
Expand Down

0 comments on commit 438c72e

Please sign in to comment.