Skip to content

Refactor shaker API and move BioShake to shaking module#905

Merged
rickwierenga merged 3 commits intoPyLabRobot:mainfrom
j0nch:bioshake_update
Feb 24, 2026
Merged

Refactor shaker API and move BioShake to shaking module#905
rickwierenga merged 3 commits intoPyLabRobot:mainfrom
j0nch:bioshake_update

Conversation

@j0nch
Copy link
Contributor

@j0nch j0nch commented Feb 23, 2026

Summary

This PR does two related refactors:

  1. Moves BioShake from heating_shaking to shaking, since BioShake is shaker-only.
  2. Clarifies shaker API semantics by introducing start_shaking(...) at the backend layer, while keeping frontend shake(..., duration=...) as the orchestration method.

Motivation

  • ShakerBackend.shake() was semantically “start shaking”, which was easy-to-confuse with frontend Shaker.shake(..., duration=...) behavior.
  • Naming backend start/stop methods as start_shaking / stop_shaking is clearer and consistent.
  • BioShake does not provide heating functionality, so it belongs under pylabrobot.shaking.

Changes

BioShake module placement

  • Added new backend:
    • pylabrobot/shaking/bioshake_backend.py
  • Exported from:
    • pylabrobot/shaking/__init__.py
  • Kept compatibility shim:
    • pylabrobot/heating_shaking/bioshake_backend.py
    • old import path still works but emits a deprecation warning

Shaker backend API rename

  • ShakerBackend now defines abstract:
    • start_shaking(speed: float)
  • Kept deprecated alias:
    • ShakerBackend.shake(...) forwards to start_shaking(...) with warning

Frontend updates

  • Shaker.shake(..., duration=...) now calls backend.start_shaking(...)

Backend implementations updated

  • pylabrobot/shaking/chatterbox.py: implements start_shaking(...), keeps deprecated shake(...)
  • pylabrobot/shaking/bioshake_backend.py: implements start_shaking(...), keeps deprecated shake(...)
  • pylabrobot/heating_shaking/hamilton_backend.py: implements start_shaking(...), keeps deprecated shake(...)
  • pylabrobot/heating_shaking/inheco/thermoshake_backend.py: implements start_shaking(...), keeps deprecated shake(...)

Backward compatibility

  • Existing backend calls to .shake(...) still work for now via deprecation aliases.
  • Legacy import path for BioShake in heating_shaking still works via shim.
  • New canonical paths:
    • from pylabrobot.shaking import BioShake
    • backend API: start_shaking(...) / stop_shaking(...)

Testing / validation

  • Performed syntax compilation checks on edited files.
  • Ran heater_shaker_tests.py successfully

Follow-up (optional)

  • Add/adjust unit tests to assert Shaker.shake(..., duration=...) uses start_shaking(...) then stop_shaking(...).
  • After deprecation window, remove backend shake(...) aliases and the heating_shaking BioShake shim.

Comment on lines 3 to 4
from pylabrobot.heating_shaking.backend import HeaterShakerBackend
from pylabrobot.heating_shaking.bioshake_backend import BioShake
from pylabrobot.heating_shaking.chatterbox import HeaterShakerChatterboxBackend
Copy link
Member

Choose a reason for hiding this comment

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

breaking

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-added

Comment on lines 18 to 30
async def shake(self, speed: float):
"""Deprecated alias for ``start_shaking``.

Backends should implement ``start_shaking``. This method exists for backwards compatibility.
"""

warnings.warn(
"ShakerBackend.shake() is deprecated. Use start_shaking() instead.",
DeprecationWarning,
stacklevel=2,
)
await self.start_shaking(speed=speed)

Copy link
Member

Choose a reason for hiding this comment

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

this is not needed since this method is just abstract and never called

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

print("Stopping shaker")

async def shake(self, speed: float):
async def start_shaking(self, speed: float):
Copy link
Member

Choose a reason for hiding this comment

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

needs deprecation warning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Comment on lines 56 to 61
async def start_shaking(self, speed: float, **backend_kwargs):
"""Start shaking indefinitely at the given speed."""
if self.backend.supports_locking:
await self.backend.lock_plate()
await self.backend.start_shaking(speed=speed, **backend_kwargs)

Copy link
Member

Choose a reason for hiding this comment

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

what is the point of this method when we already have shake? shake has duration, but also supports start_shaking. this makes the api ambiguous: which method should be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, removed start_shaking from the frontend. "shake" with duration None is the correct way to shake indefinitely.

@rickwierenga rickwierenga merged commit 8adab4d into PyLabRobot:main Feb 24, 2026
10 checks passed
@j0nch j0nch deleted the bioshake_update branch February 24, 2026 01:10
rickwierenga added a commit that referenced this pull request Feb 24, 2026
rickwierenga added a commit that referenced this pull request Feb 24, 2026
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