Skip to content

refactor: have validate._extract_3mf_metadata delegate to bambox.info - #270

Merged
pzfreo merged 2 commits into
mainfrom
refactor/268-validate-delegate-info
May 28, 2026
Merged

refactor: have validate._extract_3mf_metadata delegate to bambox.info#270
pzfreo merged 2 commits into
mainfrom
refactor/268-validate-delegate-info

Conversation

@pzfreo

@pzfreo pzfreo commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #268. Removes the second parser for the .gcode.3mf archive format.

validate._extract_3mf_metadata was re-implementing the same zip +
Metadata/slice_info.config XML parsing as bambox.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

  • Delegate the slice_info-derived fields (printer_model_id, prediction,
    weight, filament_types) to bambox.info.extract_print_info.
  • Keep only the validate-specific M620 tool-change count parsing in validate.
  • Return-dict shape and compare_3mf behavior (C001–C005) are unchanged —
    internal refactor only. On BadZipFile the function returns {} as before,
    preserving the C001 abort path.

No imports went stale (ET, _safe_read_str, _safe_read are all still used
elsewhere in the module).

Verification

  • ruff check / ruff format --check — clean
  • mypy src/bambox — clean
  • pytest — 392 passed (e2e suite ignored; pre-existing env failures unrelated)
  • Against tests/fixtures/e2e_cura_p1s/reference.gcode.3mf: metadata extracts
    identically (printer_model_id=C12, prediction=7745, weight=32.12, filament_types=['PLA','PLA'], tool_changes=53) and reference-vs-reference
    compare_3mf yields zero findings — no behavioral drift.

🤖 Generated with Claude Code

pzfreo and others added 2 commits May 28, 2026 19:33
_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>
@pzfreo
pzfreo merged commit 67bbf64 into main May 28, 2026
12 checks passed
@pzfreo
pzfreo deleted the refactor/268-validate-delegate-info branch May 28, 2026 20:24
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.

Refactor: have validate._extract_3mf_metadata delegate to bambox.info

1 participant