Signed-off-by: srinivas_oo7 <sklinkedin0120@gmail.com> Co-authored-by: srinivas_oo7 <sklinkedin0120@gmail.com> Co-authored-by: Zhou Taichang <tzhouam@connect.ust.hk>
This commit is contained in:
11 files changed
+1421
-1
No files matched your search
@@ -119,10 +119,32 @@ class ServingRealtimeRobotOpenPI:
|
||||
def reset(self, obs: dict) -> None:
|
||||
"""Compatibility hook; per-connection state lives in RobotRealtimeConnection."""
|
||||
|
||||
def drop_session(self, session_id: str) -> None:
|
||||
"""Best-effort release of model-side session state for a closed rollout."""
|
||||
drop = getattr(self.engine_client, "drop_session", None)
|
||||
if callable(drop):
|
||||
drop(session_id)
|
||||
return
|
||||
pipeline = self._pipeline()
|
||||
for name in ("close_ar_diffusion_session", "drop_session_state"):
|
||||
close = getattr(pipeline, name, None)
|
||||
if callable(close):
|
||||
close(session_id)
|
||||
return
|
||||
|
||||
def _pipeline(self) -> Any:
|
||||
engine = self.engine_client
|
||||
for attr in ("model_runner", "runner", "diffusion_model_runner"):
|
||||
runner = getattr(engine, attr, None)
|
||||
pipeline = getattr(runner, "pipeline", None) if runner is not None else None
|
||||
if pipeline is not None:
|
||||
return pipeline
|
||||
return getattr(engine, "pipeline", None)
|
||||
|
||||
async def infer(self, obs: dict, *, session_id: str, reset: bool) -> ActionOutput:
|
||||
"""raw obs → engine → actions."""
|
||||
# Build request, run inference through AsyncOmni
|
||||
request = self._build_request(obs, session_id=session_id, reset=reset)
|
||||
request = self.build_request(obs, session_id=session_id, reset=reset)
|
||||
result = None
|
||||
# OpenPI policy serving is one request -> one action reply. AsyncOmni
|
||||
# exposes an async iterator, so consume it to completion and use the
|
||||
@@ -141,6 +163,10 @@ class ServingRealtimeRobotOpenPI:
|
||||
def _next_request_id(self, session_id: str) -> str:
|
||||
return f"robot-{session_id}-{next(self._request_counter)}"
|
||||
|
||||
def build_request(self, obs: dict, *, session_id: str, reset: bool) -> Any:
|
||||
"""Build an engine request from raw robot obs."""
|
||||
return self._build_request(obs, session_id=session_id, reset=reset)
|
||||
|
||||
def _build_request(self, obs: dict, *, session_id: str, reset: bool) -> Any:
|
||||
"""Build engine request from raw robot obs.
|
||||
|
||||
|
||||
Reference in new issue
Block a user