diff --git a/README.md b/README.md index d91d8c5..edcafa2 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,10 @@ users may find useful: Consider multi-session for potential cost savings, but be mindful of performance impacts from shared resources. You might need to adjust cluster size if slowdowns occur, which could affect overall cost. +* `force_new`: passing `force_new=True` forces Wherobots Cloud to create + and start a new SQL Session runtime for this connection instead of + attempting to reuse an existing, available one. Note that this can + severely impact the delay in obtaining a connection to your runtime. * `shutdown_after_inactive_seconds`: how long the runtime waits and stays running after all clients have disconnected. This delay gives an opportunity for clients to reconnect to a previously-established diff --git a/pyproject.toml b/pyproject.toml index fc98594..54201ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "wherobots-python-dbapi" -version = "0.20.0" +version = "0.21.0" description = "Python DB-API driver for Wherobots DB" authors = [{ name = "Maxime Petazzoni", email = "max@wherobots.com" }] requires-python = ">=3.8, <4" diff --git a/uv.lock b/uv.lock index 1d73065..8eb878c 100644 --- a/uv.lock +++ b/uv.lock @@ -1593,7 +1593,7 @@ wheels = [ [[package]] name = "wherobots-python-dbapi" -version = "0.20.0" +version = "0.21.0" source = { editable = "." } dependencies = [ { name = "cbor2" }, diff --git a/wherobots/db/driver.py b/wherobots/db/driver.py index 4482e9c..ef26191 100644 --- a/wherobots/db/driver.py +++ b/wherobots/db/driver.py @@ -68,6 +68,7 @@ def connect( wait_timeout: float = DEFAULT_SESSION_WAIT_TIMEOUT_SECONDS, read_timeout: float = DEFAULT_READ_TIMEOUT_SECONDS, session_type: Union[SessionType, None] = None, + force_new: bool = False, shutdown_after_inactive_seconds: Union[int, None] = None, results_format: Union[ResultsFormat, None] = None, data_compression: Union[DataCompression, None] = None, @@ -91,7 +92,8 @@ def connect( session_type = session_type or DEFAULT_SESSION_TYPE logging.info( - "Requesting %s runtime running %s in %s from %s ...", + "Requesting %s%s runtime running %s in %s from %s ...", + "new " if force_new else "", runtime.value, version, region.value, @@ -105,7 +107,7 @@ def connect( try: resp = requests.post( url=f"{host}/sql/session", - params={"region": region.value}, + params={"region": region.value, "force_new": force_new}, json={ "runtimeId": runtime.value, "shutdownAfterInactiveSeconds": shutdown_after_inactive_seconds, diff --git a/wherobots/db/runtime.py b/wherobots/db/runtime.py index 7458666..c45d18a 100644 --- a/wherobots/db/runtime.py +++ b/wherobots/db/runtime.py @@ -19,6 +19,7 @@ class Runtime(Enum): XXXX_LARGE_HIMEM = "4x-large-himem" # GPU + MICRO_A10_GPU = "micro-a10-gpu" TINY_A10_GPU = "tiny-a10-gpu" SMALL_A10_GPU = "small-a10-gpu" MEDIUM_A10_GPU = "medium-a10-gpu"