Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change artifact IDs to be stable across KCL executions #4101

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

jtran
Copy link
Contributor

@jtran jtran commented Oct 5, 2024

Related: #868, #3836, #4045

Stable IDs are useful because the face ID selected, for example, can be meaningful through user code edits and AST modifications.

This adds a debug view of the artifact graph at the bottom of the Debug Pane in order to prove that segment IDs don't change after editing KCL code.

Note: Some IDs, like plane IDs, do change. We'll address this in a future PR.

Screenshot 2024-10-05 at 2 01 02 AM

Implementation

We create an IdGenerator that's part of the executor's ExecState. ExecState is threaded through execution of all KCL code #3877. Whenever we would have generated a UUID, we instead ask the IdGenerator. It accumulates IDs generated and only generates a new UUID if needed. The executor returns the IdGenerator as part of its return value. The web app stores this and provides it to the next run. Now the executor has all the UUIDs it generated last time and reuses them in the same order.

In the future, we may be able to optimize by reducing the amount of data that must cross the WASM boundary by only storing a random seed, rather than all IDs. But IDs do need to be unique. So it didn't seem worth the effort for now.

Copy link

qa-wolf bot commented Oct 5, 2024

QA Wolf here! As you write new code it's important that your test coverage is keeping up.
Click here to request test coverage for this PR!

Copy link

vercel bot commented Oct 5, 2024

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

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Oct 5, 2024 5:58pm

@max-mrgrsk
Copy link
Collaborator

whooooh
Screenshot 2024-10-05 at 08 32 32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants