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

Return modeling commands from KCL execution #4912

Merged
merged 34 commits into from
Jan 9, 2025
Merged

Conversation

jtran
Copy link
Collaborator

@jtran jtran commented Jan 4, 2025

Part of #4860. Resolves #2821. Cherry-picks the Rust side and some TS wiring of #4834.
Depends on KittyCAD/modeling-api#708.

Rust Artifact Graph Episode I: A New Hope

Currently, the artifact graph is built in TS code that intercepts modeling commands sent from Rust in WASM. This branch makes it so that commands are accumulated in Rust and returned from KCL execution.

The goal is to be able to build the entire artifact graph in Rust, without touching the engine. This is a step towards that.

OrderedCommands are being replaced with ArtifactCommands. They're basically the same, but they're a flat list. Ordered commands had nesting due to engine command batches.

This branch should result in zero actual changes to the artifact graph data structure. The input only comes from a different place.

Before:

flowchart LR
  ts[TS]
  rs[Rust in WASM]
  ws[WebSocket API Wrapper in TS]
  engine[Engine API]
  ag[Artifact Graph]@{ shape: doc }
  oc[Ordered Commands]@{ shape: doc }
  resp[Engine Responses]@{ shape: doc }
  ts -->|KCL| rs --> ws --> engine
  engine --> resp --> ag
  ws --> oc --> ag
Loading

After:

flowchart LR
  ts[TS]
  rs[Rust in WASM]
  ws[WebSocket API Wrapper in TS]
  engine[Engine API]
  ag[Artifact Graph]@{ shape: doc }
  ac[Artifact Commands]@{ shape: doc }
  resp[Engine Responses]@{ shape: doc }
  ts -->|KCL| rs --> ws --> engine
  engine --> resp --> ag
  rs --> ac --> ag
Loading

Since #4834 got reverted (since it's part of multi-profile), I cherry-picked all the Rust parts of that and the wiring part of the TS of it. I didn't include the actual artifact graph change since my goal for this PR was to not change the artifact graph at all.

Copy link

qa-wolf bot commented Jan 4, 2025

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 Jan 4, 2025

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

Name Status Preview Updated (UTC)
modeling-app ✅ Ready (Inspect) Visit Preview Jan 9, 2025 0:38am

@jessfraz
Copy link
Contributor

jessfraz commented Jan 4, 2025

dude you are fast as fuck

@jtran jtran force-pushed the jtran/rust-artifact-graph branch from e00f132 to e3bea2f Compare January 7, 2025 04:33
@jtran jtran force-pushed the jtran/rust-artifact-graph branch from e3bea2f to 6150a59 Compare January 7, 2025 16:06
@jtran jtran force-pushed the jtran/rust-artifact-graph branch 2 times, most recently from 810f860 to ebc9a04 Compare January 7, 2025 17:59
@jtran jtran requested a review from jessfraz January 8, 2025 01:29
@jessfraz
Copy link
Contributor

jessfraz commented Jan 8, 2025

I think you're going to want to add a "clear artifact commands" here: https://github.com/KittyCAD/modeling-app/blob/main/src/wasm-lib/kcl/src/engine/mod.rs#L115

so that they don't build up across different runs, unless you do that elsewhere, but here is likely safest

@jtran
Copy link
Collaborator Author

jtran commented Jan 8, 2025

I think you're going to want to add a "clear artifact commands" here: https://github.com/KittyCAD/modeling-app/blob/main/src/wasm-lib/kcl/src/engine/mod.rs#L115

so that they don't build up across different runs, unless you do that elsewhere, but here is likely safest

I take them all at the end of each run in wasm.rs here.

In the CLI or elsewhere, do we reuse the EngineManager across runs?

Update: It's possible for the LSP to reuse it. So we decided to clear them on clear scene.

@jtran jtran enabled auto-merge (squash) January 8, 2025 02:44
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 94.49541% with 12 lines in your changes missing coverage. Please review.

Project coverage is 85.84%. Comparing base (eb0850f) to head (24a6fbc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/wasm-lib/kcl/src/execution/artifact.rs 52.63% 9 Missing ⚠️
src/wasm-lib/kcl/src/execution/mod.rs 95.74% 2 Missing ⚠️
src/wasm-lib/kcl/src/engine/conn.rs 96.77% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4912      +/-   ##
==========================================
+ Coverage   85.80%   85.84%   +0.04%     
==========================================
  Files          87       88       +1     
  Lines       31255    31429     +174     
==========================================
+ Hits        26817    26981     +164     
- Misses       4438     4448      +10     
Flag Coverage Δ
wasm-lib 85.84% <94.49%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jtran jtran merged commit 73a7e2b into main Jan 9, 2025
33 checks passed
@jtran jtran deleted the jtran/rust-artifact-graph branch January 9, 2025 01:02
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.

Sending modeling commands via reference, not owned
3 participants