Skip to content

Change artifact IDs to be stable across KCL executions #4101

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

Merged
merged 40 commits into from
Oct 9, 2024

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 (only the top level planes) 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 9, 2024 5:33pm

@jtran jtran force-pushed the jtran/stable-artifact-ids branch from ffd5aae to 2cf04f4 Compare October 5, 2024 06:27
@jtran jtran requested a review from max-mrgrsk October 5, 2024 06:30
@max-mrgrsk
Copy link
Contributor

whooooh
Screenshot 2024-10-05 at 08 32 32

@jtran jtran force-pushed the jtran/stable-artifact-ids branch from ea2f0c0 to ef14d47 Compare October 8, 2024 15:58
@jtran jtran force-pushed the jtran/stable-artifact-ids branch from ffae1cd to b29f2dd Compare October 8, 2024 16:15
Copy link
Contributor

@franknoirot franknoirot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G2G after the removal of the test.only for me

@jtran jtran merged commit 0fb5ff7 into main Oct 9, 2024
30 checks passed
@jtran jtran deleted the jtran/stable-artifact-ids branch October 9, 2024 23:38
@pierremtb pierremtb mentioned this pull request Oct 17, 2024
@Irev-Dev
Copy link
Contributor

Dope!!

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.

4 participants