Skip to content

feat: accept str|enum region/runtime, omit when unset for org default - #57

Merged
ClayMav merged 3 commits into
mainfrom
clay/byoc-optional-region-runtime
May 28, 2026
Merged

feat: accept str|enum region/runtime, omit when unset for org default#57
ClayMav merged 3 commits into
mainfrom
clay/byoc-optional-region-runtime

Conversation

@ClayMav

@ClayMav ClayMav commented May 28, 2026

Copy link
Copy Markdown
Member

Summary

Widens region / runtime to Optional[Union[str, Region/Runtime]] across WherobotsRunOperator, WherobotsSqlOperator, WherobotsSqlHook, and WherobotsRestAPIHook.create_run.

  • Strings are passed to the API untouched (BYOC regions work without a release); enum values are normalized to their .value.
  • When region/runtime are omitted they're dropped from the request (region from the /runs query string, runtime from the run payload, and both from the SQL connect() call), so the API applies the organization's configured default.
  • warn_for_default_region no longer injects DEFAULT_REGION — it normalizes the value and returns None when unset.

Why: part of the BYOC region rollout.

Dependencies / release notes

  • The run-operator path (create_run) omits region directly, so it gets org-default behavior as soon as the studio-backend API change ships (wherobots/studio-backend#2208).
  • The SQL path omits runtime/region via wherobots.db.connect(), so the "omit → org default" behavior there also needs the wherobots-python-dbapi release that makes connect() region/runtime optional (feat: accept str|enum for region/runtime and make them optional wherobots-python-dbapi#67). The dependency constraint (currently >=0.26.1) should be bumped to that release at release time — left unbumped here so this PR's CI can resolve dependencies against the currently published dbapi.

Test plan

```
uv run pytest tests/unit_tests/ -> 41 passed
```
New tests: test_create_run_omits_region_when_none, test_create_run_passes_string_region, and TestWarnForDefaultRegion (None→None, enum→value, string passthrough).

ClayMav added 2 commits May 27, 2026 17:13
Widen the region/runtime parameters on WherobotsRunOperator,
WherobotsSqlOperator, WherobotsSqlHook, and WherobotsRestAPIHook.create_run to
`Optional[Union[str, Region/Runtime]]`. Strings are passed to the API untouched
(BYOC regions work without a release); enums are normalized to their value.

When region/runtime are omitted they are dropped from the request (region from
the /runs query string, runtime from the run payload, and both from the SQL
connect() call) so the API applies the organization's configured default.
`warn_for_default_region` no longer injects DEFAULT_REGION — it normalizes and
returns None when unset.

Adds tests for create_run (region omitted / string passthrough) and
warn_for_default_region.

Note: the SQL path's "omit -> org default" behavior also requires the
wherobots-python-dbapi release that makes connect() region/runtime optional;
bump the dependency constraint to that version at release time. The run-operator
path depends only on the studio-backend API change.
…ntime in prod smoke tests

CI integration tests (which hit prod with the released dbapi) failed:

- test_sql crashed with "'str' object has no attribute 'value'": warn_for_default_region
  returned a normalized string, and the released enum-only connect() calls
  region.value on it. Normalization belongs at the request boundary
  (create_run / connect), so warn now returns the value unchanged
  (Optional[Union[str, Region]]); the enum keeps working with the current dbapi
  and the new dbapi normalizes internally.
- test_run got a 422 ("runtime field required") because the operator now omits
  runtime by default and the (not-yet-deployed) prod API still requires it. The
  prod smoke tests are meant to verify a run submits successfully, not the
  org-default mechanism (covered by unit tests), so they now pin
  runtime=Runtime.TINY for deterministic, transition-robust behavior.
@ClayMav
ClayMav marked this pull request as ready for review May 28, 2026 00:55

@salty-hambot salty-hambot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed by Salty Hambot 🤖🧂

Two real bugs hiding behind if not region / if region_value — empty strings get silently swallowed instead of reaching the API. Quick is None fix in both spots and you're good.

3 finding(s) posted · 1 filtered as false positives.
💬 To request a re-review, comment @salty-hambot review

Comment thread airflow_providers_wherobots/hooks/rest_api.py
Comment thread airflow_providers_wherobots/operators/__init__.py
Comment thread airflow_providers_wherobots/operators/run.py
The prod API returns a TIMED_OUT run status that the provider's RunStatus enum
didn't include, so polling a timed-out run raised a Pydantic ValidationError
(surfaced by the timeout smoke test once it reaches the real run path). Add
TIMED_OUT to RunStatus, treat it as a timeout in Run.is_timeout, and raise the
"failed due to timeout" RuntimeError for it in WherobotsRunOperator.execute.
Adds a TIMED_OUT case to the execute-state unit test.
@ClayMav
ClayMav merged commit f0365da into main May 28, 2026
2 checks passed
@ClayMav
ClayMav deleted the clay/byoc-optional-region-runtime branch May 28, 2026 15:38
ClayMav added a commit that referenced this pull request May 28, 2026
….0 (#59)

PR #57 made region/runtime optional and accept str|enum on the operator
side, but the dbapi floor was intentionally left at >=0.26.1 so the PR's
CI could resolve before dbapi v0.28.0 was published. v0.28.0 is now on
PyPI (released today) and includes the matching client-side change:
strings (BYOC regions included) pass through, and an omitted value lets
the API apply the org's configured default.

This commit raises the floor so we actually depend on the new behavior,
refreshes the lock to resolve to 0.28.0, and bumps the package version
to 1.7.0 (minor — additive: existing callers passing Region enums still
work; existing callers omitting region/runtime now follow the org
default instead of the previous hardcoded aws-us-west-2/tiny).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants