feat: accept str|enum for region/runtime and make them optional#67
Conversation
`connect()` now accepts a plain string for `runtime` and `region` in addition to the `Runtime`/`Region` enums; strings are passed to the API untouched, so new or BYOC regions (e.g. "byoc-acme-us-east-1") work without an SDK release. When either is omitted, the SDK no longer injects the hardcoded `aws-us-west-2` / `tiny` defaults — the field is dropped from the request (`requests` omits None query params; `runtimeId` is sent null) so the API applies the organization's configured default. Enum values are normalized to their string form. Adds a docstring documenting the new behavior. Requires the studio-backend API change that makes region/runtime optional on POST /sql/session.
There was a problem hiding this comment.
Reviewed by Salty Hambot 🤖🧂
Clean implementation — one legit catch: the old WARNING block in the README now contradicts the new org-default behavior and should be cleaned up before merge.
1 finding(s) posted · 1 filtered as false positives.
💬 To request a re-review, comment @salty-hambot review
| ``` | ||
|
|
||
| `runtime` and `region` are optional and accept either the provided enums (handy | ||
| for autocomplete) or a plain string — strings are passed to the API as-is, so |
There was a problem hiding this comment.
note: The new paragraph is correctly placed, but the existing README still has a > [!WARNING] block (in the "Runtime and region selection" section) that warns users the region parameter will become mandatory in a future SDK version. With this PR, the behavior is now the opposite — omitting region is intentional and org-default-driven. That stale warning will confuse anyone who reads past the basic usage section. Consider removing or updating it in the same PR.
Summary
connect()now acceptsstr | Region | Noneandstr | Runtime | Noneforregion/runtime:region="byoc-acme-us-east-1") work without an SDK release. Enum values are normalized to their string form.aws-us-west-2/tiny. The field is dropped from the request (requestsomitsNonequery params;runtimeIdis sentnull) so the API applies the organization's configured default.connect()docstring documenting the override-vs-default semantics, plus a README note.Why: part of the BYOC region rollout — lets users rely on their org's default region/runtime and use arbitrary region strings. This is the reference implementation of the Python pattern (also used by the Airflow provider and MCP server).
Depends on: wherobots/studio-backend#2208 (makes region/runtime optional on
POST /sql/session). Must be deployed before this is released.Related Issues
Requester Checklist
Visual Proof
```
tests/test_driver.py::TestConnectRegionRuntime::test_omitted_region_runtime_not_sent PASSED
tests/test_driver.py::TestConnectRegionRuntime::test_enum_region_runtime_serialized PASSED
tests/test_driver.py::TestConnectRegionRuntime::test_string_region_runtime_passthrough PASSED
12 passed in 13.14s (9 existing + 3 new)
pre-commit: ruff / ruff-format / codespell all Passed
```