Skip to content

Commit

Permalink
Shim for old APi
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Jan 4, 2025
1 parent a1fbff4 commit c3404e1
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/viser/_viser.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,38 @@ def sleep_forever(self) -> None:
while True:
time.sleep(3600)

def _start_scene_recording(self) -> None:
def _start_scene_recording(self) -> Any:
"""**Old API.**"""
assert False, "_start_scene_recording() has been removed. See notes in https://github.com/nerfstudio-project/viser/pull/357 for the new API."
warnings.warn(
"_start_scene_recording() has been renamed. See notes in https://github.com/nerfstudio-project/viser/pull/357 for the new API.",
stacklevel=2,
)

serializer = self.get_scene_serializer()

# We'll add a shim for the old API for now. We can remove this later.
class _SceneRecordCompatibilityShim:
def set_loop_start(self):
warnings.warn(
"_start_scene_recording() has been renamed. See notes in https://github.com/nerfstudio-project/viser/pull/357 for the new API.",
stacklevel=2,
)

def insert_sleep(self, duration: float):
warnings.warn(
"_start_scene_recording() has been renamed. See notes in https://github.com/nerfstudio-project/viser/pull/357 for the new API.",
stacklevel=2,
)
serializer.insert_sleep(duration)

def end_and_serialize(self) -> bytes:
warnings.warn(
"_start_scene_recording() has been renamed. See notes in https://github.com/nerfstudio-project/viser/pull/357 for the new API.",
stacklevel=2,
)
return serializer.serialize()

return _SceneRecordCompatibilityShim()

def get_scene_serializer(self) -> StateSerializer:
"""Get handle for serializing the scene state.
Expand Down

0 comments on commit c3404e1

Please sign in to comment.