diff --git a/README.md b/README.md index 494c4f6..5395f05 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 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 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..c3fc5b0 100644 --- a/tests/smoke.py +++ b/tests/smoke.py @@ -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", @@ -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: 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, )