Repository navigation
Add @quri/squiggle-relative-values and use it in Hub - #4174
Merged
Merged
Conversation
Extract the relative values views (List, Grid, Plot), definition schemas
and ModelEvaluator from Squiggle Hub into a framework-agnostic package.
- ModelEvaluator evaluates the model directly and reads the variable from
its bindings (non-exported variables work), accepts a pluggable
RelativeValuesCache (in-memory by default) and an optional linker.
- relativeValuesSpecFromSqValue / findRelativeValuesExports recognize
RV-shaped Squiggle dicts ({items, fn} or {values}).
- RelativeValuesDashboard / RelativeValuesSpecDashboard render the views
with built-in tabs.
- Examples ported from the original relative-values app, with tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Server code (e.g. Next.js server actions) can import ModelEvaluator, schemas and spec helpers from @quri/squiggle-relative-values/core without pulling in React components. Component modules that use hooks or context are marked with "use client". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hub keeps its routes, server actions and Prisma-backed pair cache, and now renders the views and evaluates models via the shared package. This also fixes relative values pages that broke in 856c623 (Jul 2024), when ModelEvaluator switched from setContinues to `import "model" as model`: imports only expose exported variables, so models with a plain top-level `fn(a, b) = ...` failed with "Dict property not found". The new evaluator reads the variable from the model's bindings. Hub imports (`import "hub:owner/slug"`) are supported again via a linker that creates current SqModules. Also removes a leftover 1s sleep in the relative values layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stories run the example .squiggle files and render a dashboard for each relative values spec found (List/Grid/Plot), plus an invalid spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of four PRs (merge after the CLI PR). Extracts Squiggle Hub's relative values views into a new package and makes Hub use it.
What
@quri/squiggle-relative-valuespackage: List, Grid and Plot views, definition schemas,ModelEvaluatorwith a pluggable pair cache and optional linker, and detection of relative values specs in Squiggle code ({items, fn}or{values}dicts). A/coreentry point lets server code (Next.js server actions) import the evaluator without React. Examples, tests and Storybook stories.Fixes a Hub breakage from Jul 2024
856c623 switched
ModelEvaluatortoimport "model" as model, which only exposes exported variables, so models with a plain top-levelfn(a, b) = ...failed with "Dict property not found". The new evaluator reads the variable from the model's bindings, andhub:imports work again.Verified locally
Ran Hub dev against a fresh Postgres, created a user, a model in the legacy
fn(a, b) -> [distA, distB]form, a definition and an export, and checked the List, Grid and Plot tabs and Fill / Clear cache. Two bugs found during that check (a pair-chart error when an item's value is a plain number, andhub:imports fetched from production on local Hub) are fixed in the Studio PR, which sits on top of this.🤖 Generated with Claude Code