Skip to content

Commit c2d62b0

Browse files
committed
fix(demo): stable DEMO_TAG in embedded mode and portable temp dir
- 00_seed_data.ipynb DEMO_TAG: use a stable "seed_data" tag in embedded mode so reseeds cleanly replace prior data via the existing DETACH DELETE cleanup. Server mode keeps the UUID-suffixed tag so parallel runs sharing a DB remain isolated. - All 4 notebooks: replace hard-coded "/tmp/coordinode-demo.db" fallback with `os.path.join(tempfile.gettempdir(), "coordinode-demo.db")` so the default path works on native Windows where /tmp does not exist.
1 parent 15e6a20 commit c2d62b0

4 files changed

Lines changed: 33 additions & 17 deletions

File tree

demo/notebooks/00_seed_data.ipynb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,16 @@
156156
"metadata": {},
157157
"outputs": [],
158158
"source": [
159-
"import os\n",
159+
"import os, tempfile\n",
160160
"\n",
161161
"# Persistent embedded DB path. Colab has /content which persists across cell\n",
162-
"# reruns within a runtime session; locally fall back to /tmp. Override via\n",
163-
"# COORDINODE_EMBEDDED_PATH if you need a different location.\n",
162+
"# reruns within a runtime session; locally fall back to the OS temp dir\n",
163+
"# (portable across Linux/macOS/Windows). Override via COORDINODE_EMBEDDED_PATH.\n",
164164
"COORDINODE_EMBEDDED_PATH = os.environ.get(\n",
165165
" \"COORDINODE_EMBEDDED_PATH\",\n",
166-
" \"/content/coordinode-demo.db\" if os.path.isdir(\"/content\") else \"/tmp/coordinode-demo.db\",\n",
166+
" \"/content/coordinode-demo.db\"\n",
167+
" if os.path.isdir(\"/content\")\n",
168+
" else os.path.join(tempfile.gettempdir(), \"coordinode-demo.db\"),\n",
167169
")\n",
168170
"\n",
169171
"if os.environ.get(\"COORDINODE_ADDR\"):\n",
@@ -208,7 +210,15 @@
208210
"source": [
209211
"import uuid\n",
210212
"\n",
211-
"DEMO_TAG = os.environ.get(\"COORDINODE_DEMO_TAG\") or f\"seed_data_{uuid.uuid4().hex[:8]}\"\n",
213+
"# In server mode (COORDINODE_ADDR) parallel runs may share a DB, so a unique\n",
214+
"# UUID tag prevents collisions. In embedded mode each LocalClient has its own\n",
215+
"# file-backed DB, so a stable tag lets reseeds cleanly replace prior data\n",
216+
"# (the DETACH DELETE below is scoped to this tag).\n",
217+
"DEMO_TAG = os.environ.get(\"COORDINODE_DEMO_TAG\") or (\n",
218+
" f\"seed_data_{uuid.uuid4().hex[:8]}\"\n",
219+
" if os.environ.get(\"COORDINODE_ADDR\")\n",
220+
" else \"seed_data\"\n",
221+
")\n",
212222
"print(\"Using DEMO_TAG:\", DEMO_TAG)\n",
213223
"# Remove prior demo nodes and any attached relationships in one step to avoid\n",
214224
"# duplicate relationship matches during cleanup (undirected MATCH -[r]-() returns\n",

demo/notebooks/01_llama_index_property_graph.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,16 @@
189189
"metadata": {},
190190
"outputs": [],
191191
"source": [
192-
"import os\n",
192+
"import os, tempfile\n",
193193
"\n",
194194
"# Persistent embedded DB path. Colab has /content which persists across cell\n",
195-
"# reruns within a runtime session; locally fall back to /tmp. Override via\n",
196-
"# COORDINODE_EMBEDDED_PATH if you need a different location.\n",
195+
"# reruns within a runtime session; locally fall back to the OS temp dir\n",
196+
"# (portable across Linux/macOS/Windows). Override via COORDINODE_EMBEDDED_PATH.\n",
197197
"COORDINODE_EMBEDDED_PATH = os.environ.get(\n",
198198
" \"COORDINODE_EMBEDDED_PATH\",\n",
199-
" \"/content/coordinode-demo.db\" if os.path.isdir(\"/content\") else \"/tmp/coordinode-demo.db\",\n",
199+
" \"/content/coordinode-demo.db\"\n",
200+
" if os.path.isdir(\"/content\")\n",
201+
" else os.path.join(tempfile.gettempdir(), \"coordinode-demo.db\"),\n",
200202
")\n",
201203
"\n",
202204
"if os.environ.get(\"COORDINODE_ADDR\"):\n",

demo/notebooks/02_langchain_graph_chain.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,16 @@
190190
"metadata": {},
191191
"outputs": [],
192192
"source": [
193-
"import os\n",
193+
"import os, tempfile\n",
194194
"\n",
195195
"# Persistent embedded DB path. Colab has /content which persists across cell\n",
196-
"# reruns within a runtime session; locally fall back to /tmp. Override via\n",
197-
"# COORDINODE_EMBEDDED_PATH if you need a different location.\n",
196+
"# reruns within a runtime session; locally fall back to the OS temp dir\n",
197+
"# (portable across Linux/macOS/Windows). Override via COORDINODE_EMBEDDED_PATH.\n",
198198
"COORDINODE_EMBEDDED_PATH = os.environ.get(\n",
199199
" \"COORDINODE_EMBEDDED_PATH\",\n",
200-
" \"/content/coordinode-demo.db\" if os.path.isdir(\"/content\") else \"/tmp/coordinode-demo.db\",\n",
200+
" \"/content/coordinode-demo.db\"\n",
201+
" if os.path.isdir(\"/content\")\n",
202+
" else os.path.join(tempfile.gettempdir(), \"coordinode-demo.db\"),\n",
201203
")\n",
202204
"\n",
203205
"if os.environ.get(\"COORDINODE_ADDR\"):\n",

demo/notebooks/03_langgraph_agent.ipynb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,16 @@
144144
"metadata": {},
145145
"outputs": [],
146146
"source": [
147-
"import os\n",
147+
"import os, tempfile\n",
148148
"\n",
149149
"# Persistent embedded DB path. Colab has /content which persists across cell\n",
150-
"# reruns within a runtime session; locally fall back to /tmp. Override via\n",
151-
"# COORDINODE_EMBEDDED_PATH if you need a different location.\n",
150+
"# reruns within a runtime session; locally fall back to the OS temp dir\n",
151+
"# (portable across Linux/macOS/Windows). Override via COORDINODE_EMBEDDED_PATH.\n",
152152
"COORDINODE_EMBEDDED_PATH = os.environ.get(\n",
153153
" \"COORDINODE_EMBEDDED_PATH\",\n",
154-
" \"/content/coordinode-demo.db\" if os.path.isdir(\"/content\") else \"/tmp/coordinode-demo.db\",\n",
154+
" \"/content/coordinode-demo.db\"\n",
155+
" if os.path.isdir(\"/content\")\n",
156+
" else os.path.join(tempfile.gettempdir(), \"coordinode-demo.db\"),\n",
155157
")\n",
156158
"\n",
157159
"if os.environ.get(\"COORDINODE_ADDR\"):\n",

0 commit comments

Comments
 (0)