From fb8652d13230ba4556d4f53138bb36309cf6397d Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Wed, 11 Dec 2024 16:36:55 -0800 Subject: [PATCH] feat: Env/Goal pickling --- pantograph/server.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pantograph/server.py b/pantograph/server.py index 703b9c1..284694e 100644 --- a/pantograph/server.py +++ b/pantograph/server.py @@ -294,6 +294,36 @@ class Server: raise ServerError(result["desc"]) return result + def env_save(self, path: str): + result = self.run('env.save', { + "path": path, + }) + if "error" in result: + raise ServerError(result["desc"]) + def env_load(self, path: str): + result = self.run('env.load', { + "path": path, + }) + if "error" in result: + raise ServerError(result["desc"]) + + def goal_save(self, goal_state: GoalState, path: str): + result = self.run('goal.save', { + "id": goal_state.state_id, + "path": path, + }) + if "error" in result: + raise ServerError(result["desc"]) + def goal_load(self, path: str) -> int: + # FIXME: Load the entire state + result = self.run('goal.load', { + "path": path, + }) + if "error" in result: + raise ServerError(result["desc"]) + state_id = result['id'] + return state_id + def get_version(): import subprocess