## Defensive Coding Improvements: batch_processor.py & feature_extractor.p#36
Open
agentksimha wants to merge 2 commits into
Open
## Defensive Coding Improvements: batch_processor.py & feature_extractor.p#36agentksimha wants to merge 2 commits into
agentksimha wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds input validation, output safety guards, and fixes silent failure points across the PLY processing pipeline.
batch_processor.py
[High] Path & permission validation (
_validate_path)Introduces a
_validate_pathhelper called at the top ofvalidate_ply_file. Checks that the file exists, is a regular file, carries a.plyextension, and is readable before Open3D is ever invoked — replacing opaque internal errors with clear, early messages.[High] File size validation (
_check_file_size)Rejects files under 80 bytes (corrupt/empty) as a hard error and warns on files exceeding 500 MB before any processing begins.
[Medium] Output path safety (
preprocess_file)Aborts if the resolved output path matches the input (preventing silent data loss) and verifies the output directory is writable before any mesh work is done.
[Medium] Zero-extent guard (
normalize_mesh_scale)Prevents a division-by-zero crash on degenerate meshes with zero bounding-box extent. Also validates that
target_sizeis a positive number.feature_extractor.py
[Refactor] PCA swap in
compute_geometric_momentsReplaces manual
np.cov+np.linalg.eighwithsklearn.decomposition.PCA, consistent withcompute_surface_normalwhich already used PCA. No behaviour change.[Medium] No in-place mutation (
compute_surface_curvature)Deep-copies the input point cloud before calling
estimate_normals(), preventing silent permanent modification of the caller's object.[Medium] JSON-serialisable boundary points (
compute_boundary_features)Converts
boundary_pointsfrom a raw numpy array to a plain Python list, consistent with all other fields returned by this class and safe forjson.dumps(). Tightens bareexcepttoexcept Exception as eand surfaces the error string.[Medium] KeyError-safe visualisation (
visualize_surface_features)Extends the existing surface guard to also check that features have been extracted before accessing
fragment['features'][color][surface_idx], with a distinct message for each failure case. Adds anp.array()cast forboundary_pointsat the plot site since it is now stored as a list.