From 6b36d3529a9f3bd4f58996c02f9044cb62214668 Mon Sep 17 00:00:00 2001 From: William Guss Date: Mon, 5 Aug 2024 16:48:42 -0700 Subject: [PATCH 1/2] removing wal files --- .gitignore | 2 ++ examples/sqlite_example/ell.db-shm | Bin 32768 -> 0 bytes examples/sqlite_example/ell.db-wal | 0 3 files changed, 2 insertions(+) delete mode 100644 examples/sqlite_example/ell.db-shm delete mode 100644 examples/sqlite_example/ell.db-wal diff --git a/.gitignore b/.gitignore index d0117102..4bcedd02 100644 --- a/.gitignore +++ b/.gitignore @@ -301,3 +301,5 @@ dist # Ignore static files static/ +*.db-shm +*.db-wal diff --git a/examples/sqlite_example/ell.db-shm b/examples/sqlite_example/ell.db-shm deleted file mode 100644 index fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeIuAr62r3 Date: Mon, 5 Aug 2024 18:44:52 -0700 Subject: [PATCH 2/2] prevent graph from reloading --- ell-studio/src/pages/Home.js | 23 +++++++++++++++++--- src/ell/studio/__main__.py | 42 ++++++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 10 deletions(-) diff --git a/ell-studio/src/pages/Home.js b/ell-studio/src/pages/Home.js index e1543b66..14fc924a 100644 --- a/ell-studio/src/pages/Home.js +++ b/ell-studio/src/pages/Home.js @@ -1,15 +1,17 @@ -import React, { useState } from 'react'; +import React, { useState, useMemo, useEffect } from 'react'; import { Link } from 'react-router-dom'; import { useTheme } from '../contexts/ThemeContext'; import { getTimeAgo } from '../utils/lmpUtils'; import { DependencyGraph } from '../components/depgraph/DependencyGraph'; import { useLatestLMPs, useTraces } from '../hooks/useBackend'; import VersionBadge from '../components/VersionBadge'; +const MemoizedDependencyGraph = React.memo(DependencyGraph); function Home() { const [expandedLMP, setExpandedLMP] = useState(null); const { darkMode } = useTheme(); const { data: lmps, isLoading: isLoadingLMPs } = useLatestLMPs(); const { data: traces, isLoading: isLoadingTraces } = useTraces(lmps); + const toggleExpand = (lmpName, event) => { if (event.target.tagName.toLowerCase() !== 'a') { @@ -21,7 +23,22 @@ function Home() { return id.length > 8 ? `${id.substring(0, 8)}...` : id; }; - if (isLoadingLMPs || isLoadingTraces) { + const [firstTraces, setFirstTraces] = useState(traces); + const [firstLMPs, setFirstLMPs] = useState(lmps); + + useEffect(() => { + if((!firstTraces || !firstLMPs) && traces && lmps) { + console.log("Setting first traces and lmps"); + setFirstTraces(traces); + setFirstLMPs(lmps); + } + }, [traces, firstTraces, lmps, firstLMPs]); + + // TODO: Make graph dynamically update. + const memoizedTraces = useMemo(() => firstTraces, [firstTraces]); + const memoizedLMPs = useMemo(() => firstLMPs, [firstLMPs]); + + if (!memoizedLMPs || !memoizedTraces) { return

Loading...

; @@ -31,7 +48,7 @@ function Home() {

Language Model Programs

- {lmps && traces && } +
{lmps.map((lmp) => (
time_threshold + size_changed = current_stat.st_size != last_stat.st_size + inode_changed = current_stat.st_ino != last_stat.st_ino + if time_changed or size_changed or inode_changed: + print(f"Database changed: mtime {time.ctime(last_stat.st_mtime)} -> {time.ctime(current_stat.st_mtime)}, " + f"size {last_stat.st_size} -> {current_stat.st_size}, " + f"inode {last_stat.st_ino} -> {current_stat.st_ino}") + await app.notify_clients("database_updated") + + last_stat = current_stat + except FileNotFoundError: + if last_stat is not None: + print(f"Database file deleted: {db_path}") + await app.notify_clients("database_updated") + last_stat = None + await asyncio.sleep(1) # Wait a bit longer if the file is missing + except Exception as e: + print(f"Error checking database file: {e}") + await asyncio.sleep(1) # Wait a bit longer on errors + # Start the database watcher loop = asyncio.new_event_loop() config = uvicorn.Config(app=app, port=args.port, loop=loop) server = uvicorn.Server(config) loop.create_task(server.serve()) - loop.create_task(db_watcher()) + loop.create_task(db_watcher(db_path, app)) loop.run_forever() if __name__ == "__main__":