Skip to content

Commit 60170a9

Browse files
Apply previous suggestion of @yebai
1 parent 8bc454e commit 60170a9

File tree

6 files changed

+52
-29
lines changed

6 files changed

+52
-29
lines changed
196 KB
Loading
94.9 KB
Loading
110 KB
Loading

news/posts/2025-09-01- GSoC-Report-DoodleBUGS/index.qmd renamed to news/posts/2025-09-01-GSoC-Report-DoodleBUGS/index.qmd

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "GSoC Report for DoodleBUGS: a Browser-Based Graphical Interface for Drawing Probabilistic Graphical Models"
33
description: "Shravan Goswami's GSoC 2025 final report: goals, architecture, progress vs proposal, and how to try it."
4+
toc: true
45
categories:
56
- GSoC
67
- Blog
@@ -9,7 +10,7 @@ author:
910
url: https://shravangoswami.com/
1011
date: 2025-09-01
1112
aliases:
12-
- /GSoC-2025-Report-DoodleBUGS # submitted this to GSoC
13+
- /GSoC-2025-Report-DoodleBUGS # submitted this to GSoC so please remember to update incase moving this page somewhere else
1314
bibliography: references.bib
1415
csl: university-of-york-ieee.csl
1516
link-citations: true
@@ -19,15 +20,14 @@ nocite: |
1920

2021
## TL;DR
2122

22-
- DoodleBUGS is a browser-based graphical editor for Bayesian models that utilize JuliaBUGS for BUGS model compilation and connect to Julia inference backends (e.g., AdvancedHMC via AbstractMCMC).
23+
- BUGS (Bayesian Inference Using Gibbs Sampling) is a probabilistic programming language for Bayesian models, and JuliaBUGS is its modern implementation in Julia. DoodleBUGS is a browser-based graphical interface for JuliaBUGS, allowing users to draw probabilistic graphical models and generate BUGS code.
2324
- Implemented: visual editor (nodes, edges, nested plates), legacy BUGS code generation that compiles with [JuliaBUGS](https://github.com/TuringLang/JuliaBUGS.jl) [@JuliaBUGS; @bugs-book], local execution via a Julia backend, unified standalone script generation (frontend), timeouts, multiple layouts, and extensive cleanup/typing.
2425
- Changed from proposal: frontend implemented in Vue 3 (instead of React); backend simplified (frontend is the single source of truth for standalone scripts).
25-
- Status: Working application. Live demo (static UI) available; for running inference locally, use the backend server.
26+
- Status: Working application. Try it here (static UI): [https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/](https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/). For local inference, run the backend server.
2627

27-
## Project Links
28+
## DoodleBUGS UI
2829

29-
- Repo: [https://github.com/TuringLang/JuliaBUGS.jl](https://github.com/TuringLang/JuliaBUGS.jl)
30-
- Live demo: [https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/](https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/)
30+
![DoodleBUGS UI](DoodleBUGS.png)
3131

3232
## DoodleBUGS Project Structure
3333

@@ -59,7 +59,7 @@ DoodleBUGS/ # Vite + Vue 3 app (UI editor)
5959

6060
## Motivation
6161

62-
[JuliaBUGS](https://github.com/TuringLang/JuliaBUGS.jl) is a modern Julia implementation of the BUGS language [@bugs-rjournal; @bugs-book; @bugs-project]. DoodleBUGS revives the original visual modeling concept with a modern stack so users can:
62+
[JuliaBUGS](https://github.com/TuringLang/JuliaBUGS.jl) is a modern Julia implementation of the BUGS language [@bugs-rjournal; @bugs-book; @bugs-project]. DoodleBUGS revives the original visual modelling concept with a modern browser-based stack so users can:
6363

6464
- Construct probabilistic graphical models visually (nodes, edges, plates).
6565
- Export readable legacy BUGS code that compiles with JuliaBUGS [@JuliaBUGS; @bugs-rjournal; @bugs-book].
@@ -70,20 +70,20 @@ DoodleBUGS/ # Vite + Vue 3 app (UI editor)
7070
- Visual editor
7171
- Node types: stochastic, observed, deterministic
7272
- Plates with arbitrary nesting; robust drag-in/out and creation inside plates
73-
- Graph layouts: [WebCola](https://ialab.it.monash.edu/webcola/) and [ELK/KLay](https://www.eclipse.org/elk/); stable drag interactions
73+
- Graph layouts: Dagre (default), fCoSE (Force-Directed), Cola (Physics Simulation), KLay (Layered); stable interactions
7474
- Legacy BUGS code generation [@bugs-rjournal; @bugs-book]
7575
- Topological ordering and plate-aware traversal
7676
- Parameter formatting and safe index expansion
7777
- Implemented in `DoodleBUGS/src/composables/useBugsCodeGenerator.ts`
7878
- Execution flow
79-
- Frontend sends `model_code`, `data`, `inits`, `settings` to backend
80-
- Backend compiles/samples and returns summaries and quantiles
81-
- Frontend unifies standalone script generation; backend no longer attaches duplicates
79+
- Frontend POSTs to `/api/run` with body: `model_code` (BUGS), `data` and `inits` (JSON), `data_string` and `inits_string` (Julia NamedTuple literals), and `settings` `{ n_samples, n_adapts, n_chains, seed, timeout_s }`. If `/api/run` returns 404, it falls back to `/api/run_model`.
80+
- Backend creates a temp dir, writes `model.bugs` and `payload.json`, generates an ephemeral `run_script.jl`, compiles with `JuliaBUGS.@bugs`, wraps with `ADgradient(:ReverseDiff)`, and samples via `AdvancedHMC.NUTS` through `AbstractMCMC` (Threads or Serial). It writes summaries (incl. ESS, R-hat) and quantiles to JSON and returns `{ success, summary, quantiles, logs, files[] }`, where `files` includes `model.bugs`, `payload.json`, `run_script.jl`, and `results.json`.
81+
- Frontend also generates a `standalone.jl` script locally (mirrors backend execution) and shows it alongside the backend files; the backend does not attach a standalone script.
8282
- Timeouts/resilience
8383
- Configurable timeout (frontend); enforced in backend worker
8484
- Safe temp directory cleanup on Windows with retries
8585
- Cleanup/typing
86-
- TypeScript fixes in `DoodleBUGS/src/components/right-sidebar/ExecutionPanel.vue`
86+
- Strong, project-wide TypeScript typing across stores, components, and composables
8787
- Removal of unused backend code; consistent naming and logs
8888

8989
## Architecture Overview
@@ -121,10 +121,10 @@ DoodleBUGS/ # Vite + Vue 3 app (UI editor)
121121
- Builds `NamedTuple`s from JSON or string-literal data/inits
122122
- Compiles via `JuliaBUGS.@bugs`, wraps with `ADgradient(:ReverseDiff)` [@ReverseDiff]
123123
- Samples with `AdvancedHMC.NUTS` through `AbstractMCMC` (Threads or Serial) [@AdvancedHMC; @AbstractMCMC; @HoffmanGelman2014]
124-
- Emits summaries (`MCMCChains`, `DataFrames`) and quantiles to JSON
124+
- Emits summaries (incl. ESS and R-hat) via `MCMCChains`/`DataFrames` and quantiles to JSON
125125
[@MCMCChains; @DataFrames]
126-
- Timeout: worker process is killed if exceeding `timeout_s`.
127-
- Cleanup: `safe_rmdir()` retries with GC to avoid EBUSY on Windows.
126+
- Timeout: worker process is killed if exceeding `timeout_s`.
127+
- Cleanup: `safe_rmdir()` retries with GC to avoid EBUSY on Windows.
128128

129129
## Why Vue (not React)?
130130

@@ -134,7 +134,7 @@ The proposal planned React; we chose Vue 3 after evaluating the graph layer and
134134
- Tried D3 force/layouts: flexible, but compound nodes (plates), nesting, and drag constraints became a significant amount of custom code to maintain.
135135
- [Cytoscape.js](https://js.cytoscape.org/) offered:
136136
- Native graph model with compound nodes (great for plates)
137-
- Integrated layouts (WebCola, KLay) and rich interaction APIs [@webcola; @elk]
137+
- Integrated layouts (Dagre, fCoSE, Cola, KLay) and rich interaction APIs [@webcola; @elk]
138138
- Mature ecosystem and performance characteristics for medium-sized graphs
139139
- [Vue 3](https://vuejs.org/) (vs React) for this project:
140140
- Composition API made integrating an imperative graph library (Cytoscape) straightforward via composables and lifecycle hooks
@@ -146,17 +146,23 @@ The proposal planned React; we chose Vue 3 after evaluating the graph layer and
146146

147147
## Comparison to Legacy DoodleBUGS
148148

149-
The legacy tool was a desktop application driving WinBUGS [@winbugs]; the new DoodleBUGS is a browser-based editor targeting JuliaBUGS [@JuliaBUGS]. Key differences:
149+
The legacy tool was a windows desktop application driving WinBUGS [@winbugs]; the new DoodleBUGS is a browser-based editor targeting JuliaBUGS [@JuliaBUGS].
150+
151+
![Legacy DoodleBUGS](Legacy-DoodleBUGS.png)
152+
153+
![New DoodleBUGS](New-DoodleBUGS.png)
154+
155+
Key differences:
150156

151157
- Platform and backend
152158
- Legacy: Desktop UI, WinBUGS execution pipeline
153159
- New: Web UI, Julia backend via `JuliaBUGS.@bugs`, sampling with `AdvancedHMC.NUTS` through `AbstractMCMC`
154160
- Graph engine and plates
155161
- Legacy: Bespoke graph handling with limited nesting semantics
156-
- New: [Cytoscape.js](https://js.cytoscape.org/) with compound nodes for robust nested plates; custom DnD for drag-in/out and creating inside plates
162+
- New: [Cytoscape.js](https://js.cytoscape.org/) with compound nodes for robust nested plates; custom drag-and-drop for drag-in/out and creating inside plates
157163
- Layouts and interactions
158164
- Legacy: Limited auto-layout support
159-
- New: Multiple layout engines (Cola, Klay) and stable interactions; positions updated after `layoutstop` [@webcola; @elk]
165+
- New: Multiple layout engines (Dagre, fCoSE, Cola, KLay) and stable interactions; positions updated after `layoutstop` [@webcola; @elk]
160166
- Code generation
161167
- Legacy: Export to BUGS without strong ordering guarantees
162168
- New: Deterministic topological + plate-aware traversal; parameter canonicalization and safe index expansion
@@ -169,21 +175,21 @@ The legacy tool was a desktop application driving WinBUGS [@winbugs]; the new Do
169175
## Progress vs Proposal
170176

171177
- Implemented
172-
- Visual editor with nested plates and robust DnD
178+
- Visual editor with nested plates and robust drag-and-drop
173179
- BUGS code generator (topological + plate-aware)
174180
- Local execution + summaries/quantiles
175181
- Unified standalone script generation (frontend)
176182
- Timeouts/resilience
177183
- Multiple layouts and interactions
178184
- Extensive cleanup/typing
179185
- Execution timeout (end-to-end)
180-
- Layout options (Dagre (Hierarchical), fCoSE (Force-Directed), Cola (Physics Simulation), KLay (Layered)) and interactions
186+
- Layout options (Dagre (default, layered), fCoSE (force-directed), Cola (physics simulation), KLay (layered)) and interactions
181187
- Cleanup and stronger typing
182188
- Changed
183189
- Vue 3 instead of React
184190
- Backend responses smaller; no standalone script attachment
185191
- Deferred/Partial
186-
- Rich diagnostics (R-hat, ESS, PPC, trace/density plots)
192+
- Visualizations: integrate with MCMCChains.jl for plots (trace, density, PPC, diagnostics). ESS and R-hat already included in summary statistics.
187193
- WebKit/Safari support
188194
- UX polish for large graphs
189195

@@ -209,29 +215,30 @@ julia --project=DoodleBUGS/runtime DoodleBUGS/runtime/server.jl
209215
Notes:
210216

211217
- CORS is enabled in the backend so the dev UI can call `http://localhost:8081`.
212-
- Live demo (static UI): https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/
218+
- Try it here (static UI): [https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/](https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/)
213219

214-
## API Summary
220+
## API Summary for Backend Server
215221

216222
- GET `/api/health``{ "status": "ok" }`
217223
- POST `/api/run` (alias: `/api/run_model`)
218-
- Body: `model_code`, `data`/`data_string`, `inits`/`inits_string`, `settings` `{ n_samples, n_adapts, n_chains, seed, timeout_s }`
219-
- Response: `{ success, summary, quantiles, logs, files[] }`
224+
- Body: `model_code`, `data` (JSON), `inits` (JSON), `data_string` (Julia literal), `inits_string` (Julia literal), `settings` `{ n_samples, n_adapts, n_chains, seed, timeout_s }`
225+
- Response: `{ success, summary, quantiles, logs, files[] }` where `files[]` contains `model.bugs`, `payload.json`, `run_script.jl`, `results.json`
226+
- Note: Frontend falls back to `/api/run_model` if `/api/run` is unavailable (404)
220227

221228
See `DoodleBUGS/runtime/server.jl`.
222229

223230
## Current Limitations
224231

225232
- WebKit/Safari/iOS: unsupported at this time (see `DoodleBUGS/README.md`).
226233
- Limited visualization beyond summary/quantiles.
227-
- No persisted projects; session-based.
234+
- Overlapped plates (nodes with multiple parent plates) are currently not supported; see [#362](https://github.com/TuringLang/JuliaBUGS.jl/issues/362).
228235

229236
## Future Work
230237

231238
- Backend: Add Pluto.jl as a backend for supporting compound documents and QuartoNotebookRunner.jl for running notebooks.
232-
- Diagnostics/visualization: R-hat, ESS, trace plots, PPC, posterior densities
239+
- Diagnostics/visualization: integrate with MCMCChains.jl for plots (trace, density, PPC, diagnostics). ESS and R-hat already available in summary stats.
233240
- UX: richer node templates, validation, distribution hints
234-
- Persistence/sharing: save/load and shareable links
241+
- Sharing: shareable links/cloud sync (projects already persisted locally)
235242
- Browser compatibility: WebKit/Safari and iOS/iPadOS
236243
- Performance: virtualization for large graphs
237244

@@ -241,3 +248,19 @@ Much appreciation goes to my mentors Xianda Sun and Hong Ge. The work is impossi
241248

242249
- Mentors: Xianda Sun ([\@sunxd3](https://github.com/sunxd3)) and Hong Ge ([\@yebai](https://github.com/yebai))
243250
- TuringLang/JuliaBUGS community and contributors
251+
252+
## Appendix: Project Links
253+
254+
- Repo: [https://github.com/TuringLang/JuliaBUGS.jl](https://github.com/TuringLang/JuliaBUGS.jl)
255+
- Try it here: [https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/](https://turinglang.org/JuliaBUGS.jl/DoodleBUGS/)
256+
257+
## PRs during GSoC:
258+
259+
- [#321 - Add ISSUE template for DoodleBUGS](https://github.com/TuringLang/JuliaBUGS.jl/pull/321)
260+
- [#339 - DoodleBUGS Project: Phase 1](https://github.com/TuringLang/JuliaBUGS.jl/pull/339)
261+
- [#340 - DoodleBUGS: update all workflows to run on relevent project only](https://github.com/TuringLang/JuliaBUGS.jl/pull/340)
262+
- [#341 - Exclude navigation bar from DoodleBUGS project](https://github.com/TuringLang/JuliaBUGS.jl/pull/341)
263+
- [#347 - DoodleBUGS: Basic Code Generation, Advanced Exports, and State Persistence](https://github.com/TuringLang/JuliaBUGS.jl/pull/347)
264+
- [#357 - DoodleBUGS: Allow Nested Plates, add new layouts and fix lot of linting issues](https://github.com/TuringLang/JuliaBUGS.jl/pull/357)
265+
- [#368 - New Folder Structure](https://github.com/TuringLang/JuliaBUGS.jl/pull/368)
266+
- [#388 - DoodleBUGS Project: Phase 2 (Backend) ](https://github.com/TuringLang/JuliaBUGS.jl/pull/388)

0 commit comments

Comments
 (0)