Skip to content

Add hybrid device type and mutable_variable_regex field#63

Merged
FabianoEger merged 4 commits into
mainfrom
feat/hybrid-device-type
Jul 8, 2026
Merged

Add hybrid device type and mutable_variable_regex field#63
FabianoEger merged 4 commits into
mainfrom
feat/hybrid-device-type

Conversation

@FabianoEger

@FabianoEger FabianoEger commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Adds the hybrid device storage type and its mutable_variable_regex field to the device create/edit/info types (and the DataStorageType literal), matching backend tago-io/server#1644. Hybrid combines immutable telemetry (chunked, with retention) and editable mutable variables in one device, routed per-variable by the regex. Also corrects a long-standing typo in the immutable device type.

Changes

  • DeviceCreateInfoBasicHybrid / DeviceCreateInfoHybrid added; extended the DeviceCreateInfo alias.
  • mutable_variable_regex added to DeviceEditInfo and DeviceInfo; "hybrid" added to DataStorageType.
  • emptyDeviceData(deviceID, params=None) accepts {"route": "mutable" | "immutable"} (new DeviceEmptyParams TypedDict) on hybrid devices to empty a single side; omitting it keeps the whole-device behavior for every type. Covered by a request-body test.
  • Documented that mutable_variable_regex rejects match-everything / match-nothing patterns (the server rejects .*, ^$, etc.; use a mutable or immutable device for those cases).
  • Fixed the misspelled immutable type: type: Literal["imutable"] -> Literal["immutable"], and renamed the class DeviceCreateInfoBasicImutable -> DeviceCreateInfoBasicImmutable (with its alias reference and the Sphinx docs). The literal was wrong against the API (which uses immutable), so this corrects broken typing rather than changing working behavior. The class is not part of the package __all__; the public alias DeviceCreateInfoImmutable is unchanged.

Test plan

  • uv run ruff check src clean
  • uv run ruff format clean (changed files)
  • uv run pytest tests/ green (200 passed, incl. the new route-body test)

Risk (CIA)

Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low
Additive type definitions plus a typo correction to a non-exported class; no runtime behavior change.

Related

  • Backend: tago-io/server#1644
  • Docs: tago-io/docs#108

@FabianoEger FabianoEger requested review from felipefdl and mateuscardosodeveloper and removed request for felipefdl July 8, 2026 19:33

@mateuscardosodeveloper mateuscardosodeveloper left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve
Additive type definitions plus a safe request-body change; the tests and the description hold up against the diff.

In this PR

Improvements

  • docs/source/Resources/Devices/Devices_Type.rst:343: the DeviceCreateInfo alias line still reads DeviceCreateInfoMutable or DeviceCreateInfoImmutable and there is no DeviceCreateInfoBasicHybrid section, so the Sphinx docs now lag the aliases this PR adds. Worth updating in the same pass that fixed the Immutable typo.
  • src/tagoio_sdk/modules/Resources/Device_Type.py:61: str or None evaluates to plain str at runtime; the same field uses Optional[str] in DeviceEditInfo (line 487). Prefer Optional[str] here for a correct annotation and consistency within the PR.
  • src/tagoio_sdk/modules/Resources/Device_Type.py:403: the chunk_period and chunk_retention docstrings inside DeviceCreateInfoBasicHybrid still say "Required for Immutable devices" (also line 411). Saying they apply to the immutable side of a Hybrid device would avoid confusion.
  • src/tagoio_sdk/modules/Resources/Device_Type.py:429: since this line was already touched, consider Union[DeviceCreateInfoMutable, DeviceCreateInfoImmutable, DeviceCreateInfoHybrid]; the or chain evaluates to just DeviceCreateInfoMutable at runtime.

Praise

  • The Immutable typo fix keeps the public alias DeviceCreateInfoImmutable stable and the PR body explains why the literal change is a correction rather than a break.
  • testEmptyDeviceDataWithRoute asserts the actual request body, and the omitted-params path stays safe: api_request.py drops a null body before sending, so existing callers of emptyDeviceData are unaffected.

Risk (CIA)

Likelihood: 🟢 Low | Impact: 🟢 Low | Exposure: 🟢 Low.
Confirmed. Type additions plus an optional request body whose None case is handled in api_request.py.


Outside this PR

Pre-existing

  • src/tagoio_sdk/modules/Resources/Device_Type.py:247: the X or Y annotation idiom appears throughout the file (description: str or None, Optional[str or None] at line 194) and produces wrong runtime types everywhere it is used. A file-wide sweep to Optional/Union would fix typing for every consumer; worth a separate issue.

@mateuscardosodeveloper

mateuscardosodeveloper commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@FabianoEger

Release reminder: to cut the release that ships this change, bump version in pyproject.toml and run uv lock in the terminal. The uv.lock file will pick up the matching change and must be committed together with the version bump.

@FabianoEger FabianoEger merged commit 70a232e into main Jul 8, 2026
6 checks passed
@FabianoEger FabianoEger deleted the feat/hybrid-device-type branch July 8, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants