Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ syn = "3.0.3"

[patch.crates-io]
kittycad-unit-conversion-derive = { path = "unit-conversion-derive" }
# kcl-api = { git = "https://github.com/KittyCAD/modeling-app", branch = "main" }
# kcl-error = { git = "https://github.com/KittyCAD/modeling-app", branch = "main" }
kcl-api = { git = "https://github.com/KittyCAD/modeling-app", branch = "achalmers/kcl-193-beta1" }
kcl-error = { git = "https://github.com/KittyCAD/modeling-app", branch = "achalmers/kcl-193-beta1" }

[profile.bench]
debug = true
4 changes: 2 additions & 2 deletions modeling-cmds/openapi/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2577,11 +2577,11 @@
]
},
"KclFile": {
"description": "Region-creation algorithm version.",
"description": "A file uploaded with a KCL project.",
"type": "object",
"properties": {
"contents": {
"description": "Contents of the file, as UTF-8 encoded bytes.",
"description": "Raw file contents. KCL source is UTF-8; imported assets may be binary.",
"type": "array",
"items": {
"type": "integer",
Expand Down
28 changes: 21 additions & 7 deletions modeling-cmds/src/exec_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bon::Builder;
use indexmap::IndexMap;
#[cfg(feature = "websocket")]
use kcl_api::artifact::ArtifactGraph;
use kcl_api::{kcl_value_view::KclValueView, DefaultPlanes};
use kcl_api::{kcl_value_view::KclValueView, DefaultPlanes, Object};
use kcl_error::{CompilationIssue, KclError};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -31,7 +31,7 @@ impl KclProject {
}
}

/// Region-creation algorithm version.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oops. Copypasta.

/// A file uploaded with a KCL project.
#[derive(Clone, PartialEq, Serialize, Deserialize, JsonSchema, Default, Builder)]
#[cfg_attr(feature = "ts-rs", derive(ts_rs::TS))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand All @@ -40,7 +40,7 @@ impl KclProject {
pub struct KclFile {
/// Where is the file, relative to the project directory?
pub path: SafeFilepath,
/// Contents of the file, as UTF-8 encoded bytes.
/// Raw file contents. KCL source is UTF-8; imported assets may be binary.
#[serde(
serialize_with = "serde_bytes::serialize",
deserialize_with = "serde_bytes::deserialize"
Expand Down Expand Up @@ -83,6 +83,10 @@ pub struct ExecKclProjectOk {
pub issues: Vec<CompilationIssue>,
/// IDs of the standard planes created for this execution.
pub default_planes: Option<Box<DefaultPlanes>>,
/// All objects in all sketches.
pub scene_objects: Vec<Object>,
/// Which module ID was assigned to each KCL file in the project?
pub filenames: IndexMap<kcl_error::ModuleId, kcl_api::modules::ModulePath>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, Builder)]
Expand All @@ -106,20 +110,26 @@ pub struct ExecKclProjectErr {
pub artifact_graph: ArtifactGraph,
/// IDs of the standard planes created before execution failed.
pub default_planes: Option<Box<DefaultPlanes>>,
// TODO: Add fields to this as we make KCL data serializable.
// Should be a usable subset of `KclErrorWithOutputs`.
/// All objects in all sketches.
pub scene_objects: Vec<Object>,
/// Which module ID was assigned to each KCL file in the project?
pub filenames: IndexMap<kcl_error::ModuleId, kcl_api::modules::ModulePath>,
}

impl ExecKclProjectErr {
/// Used when the project execution had a fatal error.
pub fn fatal_error(error: KclError) -> Self {
Comment thread
adamchalmers marked this conversation as resolved.
/// Be careful using this. If you have executed a KCL program,
/// you should be building the full ExecKclProjectErr via its `build()`
/// method. This is only for errors that happen before execution.
pub fn error_before_execution(error: KclError) -> Self {
Self {
error: Some(error),
non_fatal: Default::default(),
operations: Default::default(),
variables: Default::default(),
artifact_graph: Default::default(),
default_planes: Default::default(),
filenames: Default::default(),
scene_objects: Default::default(),
}
}
}
Expand All @@ -137,6 +147,8 @@ impl<'a> arbitrary::Arbitrary<'a> for ExecKclProjectOk {
#[cfg(feature = "websocket")]
variables: Default::default(),
default_planes: Default::default(),
filenames: Default::default(),
scene_objects: Default::default(),
})
}
}
Expand All @@ -151,6 +163,8 @@ impl<'a> arbitrary::Arbitrary<'a> for ExecKclProjectErr {
variables: Default::default(),
artifact_graph: Default::default(),
default_planes: Default::default(),
scene_objects: Default::default(),
filenames: Default::default(),
})
}
}
2 changes: 1 addition & 1 deletion modeling-cmds/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub enum OkWebSocketResponseData {
#[cfg(feature = "exec-kcl")]
ExecKclProject {
/// Result after executing KCL.
result: Result<crate::exec_kcl::ExecKclProjectOk, crate::exec_kcl::ExecKclProjectErr>,
result: Box<Result<crate::exec_kcl::ExecKclProjectOk, crate::exec_kcl::ExecKclProjectErr>>,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Boxed this because we really are sending a lot of information in this response, it becomes very big. There's no need to worry about a single Box (heap pointer dereferencing) when we're sending all this data over the network.

},

/// Request that the client end this connection and establish a new session
Expand Down
Loading