quantified-uncertainty / squiggle

An estimation language
https://squiggle-language.com
MIT License
148 stars 22 forks source link

Model Build Runner #3165

Closed OAGr closed 2 months ago

OAGr commented 3 months ago

This PR does a few things:

  1. Splits up buildRecentModelRevision into a main.ts and a worker.ts. This way, when it crashes, or takes too long, we can easily cancel it, and return an error.
  2. Adds a lastRevisionWithBuild param on Model, which returns the last revision that also had a build. This is useful for getting the most recent build runSecond time or similar, for the model. (Another option here is to just get the lastBuild for the Model, if that's preferable. That could be a bit faster, as there might be one less query.)
  3. Use the lastRevisionWithBuild, with runSeconds, to help set autorunmode for the playground, in cases where it's not already set. For now, we just set it to false whenever the build took 5s+. (Note that this doesn't capture cases where the build ran out of memory - we could do this later).
  4. Use the squiggleLinker that gets squiggle models/snippets in the runSquiggle.ts query, in both GraphQL and REST API. This means that now, people can call imports directly in the runSquiggle prompts. These still have limitations though - they use caching, they don't allow for sampleCount to be set, they don't allow you to choose which modelRevision of a model you want to run.
  5. buildRecentModelRevision now runs a loop, that runs every 0.5s, to process the build queue.

Closes https://github.com/quantified-uncertainty/squiggle/issues/3162

image

I wasn't very sure about some of the thread code in the worker. I expect it's likely we'll change it later, so I'm not too worried.

On my computer, this script seemed to hit memory limits before the browser version did. I spent some time trying to improve this, but didn't get far.

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
quri-hub ✅ Ready (Inspect) Visit Preview Apr 11, 2024 8:15pm
3 Ignored Deployments | Name | Status | Preview | Updated (UTC) | | :--- | :----- | :------ | :------ | | **quri-ui** | ⬜️ Ignored ([Inspect](https://vercel.com/quantified-uncertainty/quri-ui/EwLGb56dfhoznayWsjdADRsKjC2H)) | [Visit Preview](https://quri-ui-git-build-in-worker-quantified-uncertainty.vercel.app) | Apr 11, 2024 8:15pm | | **squiggle-components** | ⬜️ Ignored ([Inspect](https://vercel.com/quantified-uncertainty/squiggle-components/6Y4kAXsxS8Wc9tzB4DjHjrrkQNvY)) | [Visit Preview](https://squiggle-components-git-build-in-worker-quantified-uncertainty.vercel.app) | Apr 11, 2024 8:15pm | | **squiggle-website** | ⬜️ Ignored ([Inspect](https://vercel.com/quantified-uncertainty/squiggle-website/Cuv8vKETR13vZF9idxPRs1MDtWG7)) | [Visit Preview](https://squiggle-website-git-build-in-worker-quantified-uncertainty.vercel.app) | Apr 11, 2024 8:15pm |
changeset-bot[bot] commented 3 months ago

⚠️ No Changeset found

Latest commit: 91cfca60347cb0be1dcebbbdfed290b92cc050d3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR