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

Per-file units (use per-file settings for conversion functions) #5064

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

nrc
Copy link
Contributor

@nrc nrc commented Jan 14, 2025

cc #3960

Copy link

qa-wolf bot commented Jan 14, 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 14, 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 15, 2025 11:50pm

@nrc nrc force-pushed the nrc-units-settings branch from f3a7a9b to 94ce0df Compare January 14, 2025 22:37
@@ -198,6 +198,14 @@ impl ExecState {

Ok(id)
}

pub fn length_unit(&self) -> UnitLen {
self.mod_local.settings.default_length_units
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make a new type for these, basically, I think we don't want people to put all the settings that exist today in the file header, it would be a subset (which is units only today) but could grow, of things people would want checked into git. So we seperate out appearance shit, from the shit that matters if that makes sense. For backwards compat we can keep the old struct w units for now, as long as there is a path forward with a new one and we can nuke the field in the old after, if that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still use the old per-project settings as the default if there are no per-file settings (I think the final step in the migration is deciding what to do here, whether we want to keep this behaviour or remove the per-project settings, but that requires a lot of UI changes so I haven't done it here).

There is a separate settings struct for the per-file stuff called MetaSettings which is in the ExecState (c.f., settings in the ExecContext for stuff specified outside the file).

Copy link
Contributor

Choose a reason for hiding this comment

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

gotcha gotcha okay yeah i was just mentioning to frank youll likely need some help w the front-end bits here since i think it touches a lot

Copy link
Contributor

Choose a reason for hiding this comment

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

MetaSettings is great, sorry i was looking for whatever that was but likely it was in another pr

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 72.58065% with 34 lines in your changes missing coverage. Please review.

Project coverage is 86.08%. Comparing base (38513a1) to head (58f55b9).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/wasm-lib/kcl/src/std/units.rs 53.33% 28 Missing ⚠️
src/wasm-lib/kcl/src/execution/mod.rs 93.02% 3 Missing ⚠️
src/wasm-lib/kcl/src/errors.rs 66.66% 2 Missing ⚠️
src/wasm-lib/kcl-test-server/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5064      +/-   ##
==========================================
+ Coverage   86.00%   86.08%   +0.07%     
==========================================
  Files          88       88              
  Lines       31493    31458      -35     
==========================================
- Hits        27085    27080       -5     
+ Misses       4408     4378      -30     
Flag Coverage Δ
wasm-lib 86.08% <72.58%> (+0.07%) ⬆️

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.

}

#[tokio::test(flavor = "multi_thread")]
async fn test_units_inner_ft() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may have lost some tests. I only saw new tests for mm and inch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I figured the tests were really annoying to reproduce and weren't that important since these functions are going to get removed or changed significantly soon.

@nrc nrc merged commit 412e956 into main Jan 16, 2025
33 of 34 checks passed
@nrc nrc deleted the nrc-units-settings branch January 16, 2025 18:55
TomPridham pushed a commit to TomPridham/modeling-app that referenced this pull request Feb 13, 2025
…yCAD#5064)

* Use the project default units for the per-file unit default values

Signed-off-by: Nick Cameron <[email protected]>

* Use per-file units in conversion functions

Signed-off-by: Nick Cameron <[email protected]>

---------

Signed-off-by: Nick Cameron <[email protected]>
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.

3 participants