refactor: have validate._extract_3mf_metadata delegate to bambox.info - #270
Merged
Conversation
_extract_3mf_metadata re-implemented the same zip + slice_info.config XML parsing as bambox.info.extract_print_info. Two parsers for one archive format will drift; a schema fix in one silently misses the other. Delegate the slice_info-derived fields (printer_model_id, prediction, weight, filament_types) to bambox.info and keep only the validate-specific M620 tool-change count parsing here. The return-dict shape and compare_3mf behavior (C001-C005) are unchanged. Closes #268 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The pre-refactor validate._extract_3mf_metadata included every <filament> element regardless of its id. info.extract_print_info dropped filaments with id <= 0, which would change compare_3mf's C001 filament comparison for archives with unindexed/zero/non-numeric ids. Remove the filter so the delegated path reproduces the original behavior exactly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Closes #268. Removes the second parser for the
.gcode.3mfarchive format.validate._extract_3mf_metadatawas re-implementing the same zip +Metadata/slice_info.configXML parsing asbambox.info.extract_print_info(added in #267). Two parsers for one format drift — a schema fix or bug fix
in one silently misses the other.
Change
printer_model_id,prediction,weight,filament_types) tobambox.info.extract_print_info.validate.compare_3mfbehavior (C001–C005) are unchanged —internal refactor only. On
BadZipFilethe function returns{}as before,preserving the C001 abort path.
No imports went stale (
ET,_safe_read_str,_safe_readare all still usedelsewhere in the module).
Verification
ruff check/ruff format --check— cleanmypy src/bambox— cleanpytest— 392 passed (e2e suite ignored; pre-existing env failures unrelated)tests/fixtures/e2e_cura_p1s/reference.gcode.3mf: metadata extractsidentically (
printer_model_id=C12, prediction=7745, weight=32.12, filament_types=['PLA','PLA'], tool_changes=53) and reference-vs-referencecompare_3mfyields zero findings — no behavioral drift.🤖 Generated with Claude Code