From a01d26249f2b88d07e433039e3b4b7fe033ff2d8 Mon Sep 17 00:00:00 2001 From: Simon Fishel Date: Tue, 4 Mar 2025 18:37:19 -0800 Subject: [PATCH 1/2] fix: move session type to request body as part of adding the session type to the smoke test script i realized i had added it to the wrong place, it should go in the request body not as a query parameter. also some minor docs cleanup --- README.md | 8 ++++---- pyproject.toml | 2 +- tests/smoke.py | 9 ++++++++- wherobots/db/driver.py | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 494c4f6..dab2838 100644 --- a/README.md +++ b/README.md @@ -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 Wherobots runtime; + if set to "multi", then multiple `connect()` calls with the same arguments + and credentials will connect to the sameshared 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 diff --git a/pyproject.toml b/pyproject.toml index 36e478f..6aef148 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "Apache 2.0" diff --git a/tests/smoke.py b/tests/smoke.py index 699b400..3e45d83 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -11,15 +11,21 @@ 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. 'single' or 'multi'", + default=DEFAULT_SESSION_TYPE, + ) parser.add_argument( "--debug", help="Enable debug logging", @@ -76,6 +82,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: diff --git a/wherobots/db/driver.py b/wherobots/db/driver.py index 841470d..81573b1 100644 --- a/wherobots/db/driver.py +++ b/wherobots/db/driver.py @@ -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, ) From 355fff2e72afe23a884e61bde4f12936279107d3 Mon Sep 17 00:00:00 2001 From: Simon Fishel Date: Wed, 5 Mar 2025 08:52:33 -0800 Subject: [PATCH 2/2] fix: pr feedback - use enum to generate cli arg choices - fix docs typo and improve exclusivity language --- README.md | 6 +++--- tests/smoke.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dab2838..5395f05 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,9 @@ 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 `connect()` establishes an exclusive connection to a Wherobots runtime; - if set to "multi", then multiple `connect()` calls with the same arguments - and credentials will connect to the sameshared Wherobots runtime; + 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 diff --git a/tests/smoke.py b/tests/smoke.py index 3e45d83..c3fc5b0 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -23,8 +23,9 @@ 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. 'single' or 'multi'", + help="Type of session to create", default=DEFAULT_SESSION_TYPE, + choices=[st.value for st in SessionType], ) parser.add_argument( "--debug",