Auto-load prior DSG into Neo4j on chatdsg startup - #2
Conversation
chatdsg.py called load_dsg_to_db() with the old five-argument signature (object labelspace, room labelspace, uri, creds, graph), but heracles now takes (uri, creds, graph) and reads the labelspaces out of the graph metadata. Passing --scene-graph therefore raised TypeError, and the tmux launch components invoke ./chatdsg.py with no arguments at all, so the prior scene graph was never loaded. - Default --scene-graph to $ADT4_PRIOR_MAP/hydra/backend/dsg.json, which is the layout the launch system already forwards to the chatdsg pane. - Fix the load_dsg_to_db() call and drop the --object-labelspace and --room-labelspace flags; labelspaces now come from the graph itself. Warn via extract_labelspaces_from_dsg() when a graph carries none, rather than silently loading unlabeled objects and rooms. - Add --no-dsg-load, since loading calls initialize_db() and so clears the database on every startup. - Fall back to ADT4_NEO4J_* credentials when HERACLES_NEO4J_* is unset, for running the example outside tmuxp. - Configure logging so the startup messages print before the Textual app takes over the terminal. Fixes MIT-SPARK/Awesome-DCIST-T4#337
| logger = logging.getLogger(__name__) | ||
|
|
||
| # Location of the backend DSG inside a saved map directory (see $ADT4_PRIOR_MAP). | ||
| PRIOR_DSG_RELPATH = os.path.join("hydra", "backend", "dsg.json") |
There was a problem hiding this comment.
We should have the dcist launch config from adt4 repo pass this in via the commadn line rather than getting the path here.
There was a problem hiding this comment.
Done in 70bf92a. Removed PRIOR_DSG_RELPATH and default_scene_graph_path(); the path now comes only from --scene-graph, and nargs="?" is gone since a valueless flag was equivalent to omitting it.
The launch side is MIT-SPARK/Awesome-DCIST-T4 — launch_components/heracles_prior_dsg.yaml now runs:
./chatdsg.py --scene-graph $ADT4_PRIOR_MAP/hydra/backend/dsg.json
regenerated via scripts/generate_configs.sh. Verified with that exact invocation: 65 objects / 96 2D places / 5 rooms loaded, labels from the graph's embedded labelspace. If $ADT4_PRIOR_MAP is unset the pane passes /hydra/backend/dsg.json, which hits the missing-file guard and warns instead of failing.
Address review: the example should not know the deployment's map layout. Drop the $ADT4_PRIOR_MAP/hydra/backend/dsg.json default and let the dcist launch config pass the path in explicitly. --scene-graph also loses nargs="?", which only allowed a valueless flag that behaved identically to omitting the argument.
heracles_agents needs to run standalone; ADT4_* variables belong to the larger stack that embeds it. chatdsg read ADT4_HERACLES_IP/PORT, and the example agent config built its Neo4j URI from the same pair. - Replace --db_ip/--db_port with --neo4j-uri, defaulting to $HERACLES_NEO4J_URI, which is what heracles' own load_scene_graph.py example already uses and what docker-compose already sets. - Read credentials only from HERACLES_NEO4J_USERNAME/PASSWORD. The ADT4_NEO4J_* fallback added earlier in this branch was wrong: the agent's HeraclesDsgInterface requires the HERACLES_* names, so falling back would load the DSG and then fail on config validation. - Point the cypher tool's uri at $HERACLES_NEO4J_URI. Skip the load with a warning when no URI is configured, so a missing URI cannot produce a half-initialized startup.
Fixes MIT-SPARK/Awesome-DCIST-T4#337.
Problem
chatdsg.pycalledload_dsg_to_db()with the old five-argument signature (object_labelspace, room_labelspace, uri, creds, graph), butheracles.utils.load_dsg_to_db()takes(neo4j_uri, neo4j_creds, scene_graph)and reads labelspaces from the graph metadata. Passing--scene-graphraisedTypeError../chatdsg.pywith no arguments and the load was gated onif args.scene_graph:, so the prior scene graph was never loaded.chatdsg.pyreadADT4_HERACLES_IP/ADT4_HERACLES_PORTandagent_config.yamlbuilt its Neo4j URI from the same pair, so the example could not be configured without ADT4-specific variables.heracles/docker/docker-compose.yamlhad to set them alongside theHERACLES_*ones it already provides.Changes
load_dsg_to_db()call and removed--object-labelspace/--room-labelspace. Labelspaces come from the graph;extract_labelspaces_from_dsg()warns when one carries none rather than silently loading unlabeled objects and rooms.HERACLES_*only.--db_ip/--db_portare replaced by--neo4j-uri, defaulting to$HERACLES_NEO4J_URI— the nameheracles' ownload_scene_graph.pyuses and thatdocker-compose.yamlalready sets. Credentials come fromHERACLES_NEO4J_USERNAME/PASSWORD. The cypher tool'suriis$HERACLES_NEO4J_URI.--scene-graph; the deployment supplies it.nargs="?"is gone, since a valueless flag behaved identically to omitting the argument.--no-dsg-load, because loading callsinitialize_db(), which clears the database — so a load on every startup wipes Neo4j. There is an existingfeature/chatdsg_optional_dsg_resetbranch suggesting the same need.logging.basicConfig()so startup messages print before the Textual app takes the terminal.Companion change
MIT-SPARK/Awesome-DCIST-T4supplies the path and translates its variables into theHERACLES_*names, which is that repo's job:launch_components/heracles_prior_dsg.yamlruns./chatdsg.py --scene-graph $ADT4_PRIOR_MAP/hydra/backend/dsg.jsonbase_launch/base_launch.yamlexportsHERACLES_NEO4J_URIandHERACLES_AGENTS_PATH(it already mapped the credentials and OpenAI key)Both must land together: with the new launch config against old
chatdsg.py,--scene-graphhits theTypeError.Testing
Against a live Neo4j, with
example_dsg.jsonstaged as a prior map.ADT4_*variable unset and only theHERACLES_*values the launch env now exports: DSG loads (65 objects / 96 2D places / 5 rooms) andLlmAgentconstructs successfully.seating,storage,sign,decor; rooms tohallway,lounge.$HERACLES_NEO4J_URIexpansion inagent_config.yamlverified throughHeraclesDsgInterface(neo4j://127.0.0.1:7687).--no-dsg-loadskips.pre-commit run --all-filesclean.unit-tests.ymlhas not been run locally.Note
One ADT4 reference remains in
examples/chatdsg/agent_config.yaml:planner_topic: /${ADT4_ROBOT_NAME}/omniplanner_node/..., expanded by the shell insideos.system()inpddl_calling_tool.py. It names a topic on an omniplanner node that only exists in the larger stack, so it is arguably deployment config rather than a leak — but it can be renamed to aHERACLES_*variable for consistency if preferred.