Skip to content

fix(python): a saved mesh that decodes in part warns, the decode releases the GIL, the stub lists every field kind, a failed extension load is an ImportError, and an unread stream's name is quoted (#1884) - #1901

Merged
DrunkOnJava merged 4 commits into
mainfrom
fix/1884-python-bindings
Nov 13, 2026

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

The five findings of #1884 (batch 5's audit of the Python surface), one change each:

  1. A saved mesh that decodes only in part warns. export_run raised a RuntimeWarning for a step that did not run and for none that ran in part; the docs, the stub and the module doc all promised one. It now warns on ExportNote::SavedMeshes { partial > 0 }, with the note's own text (N kept their box, their saved graphics not decoding whole).
  2. The decode releases the GIL. write_ifc, rvt_to_ifc, rvt_to_ifc_diagnostics, schedule_csv, export_diagnostics_json, export_diagnostics, decoded_elements, element_counts and opening a file (RevitFile(path)) ran with it held. The Rust work (the decode, the STEP writer, the diagnostics JSON, the CSV) now runs inside py.detach; the Python objects and the warnings are built after. A handle is used by one thread at a time: a second call on the same RevitFile from another thread while one runs raises RuntimeError (pyo3's borrow check), where it used to wait for the GIL and then run. Nothing else is shared across threads that was not.
  3. The stub lists what the binding returns: TypedField names the eleven kinds (float, guid, string were missing, with integer, bool and vector) and float in its value union.
  4. A broken extension is an ImportError. rvt/__init__.py caught it and surfaced module 'rvt' has no attribute 'RevitFile'; the layout it fell back to is not one pyproject.toml builds.
  5. An unread stream's name is quoted in the sentence that reports it, built in one place (UnreadStream's Display), so rvt-ifc, rvt-gltf, rvt-rs-mcp, the diagnostics' warnings and Python all print it as {:?}: a stream named with a newline cannot forge a log line.

No export moves.

Motivation

#1884. Registered rows: comment 6850068534.

Changes

  • rvt-py/src/lib.rs (1, 2), python/rvt/__init__.py and __init__.pyi (3, 4), src/reader.rs (5, with tests/resource_limits_cli.rs and docs/user-guide.md following the quoted name), docs/python.md (the warning, a "Threads" section), changelog.d/fixed/1884-python-bindings.md.
  • tests/python/test_package_import.py (a stand-in for the extension that is missing, raises ImportError, or loads) and tests/python/test_gil_released.py (a thread that ticks each millisecond must wait less than a quarter of an export's time; Core Interior, skipped where it is absent).

Testing

Unit tests are banned in this repository; the checks are end to end, on the installed wheel:

  • Rows 1 and 2 of the registered rows: the unfiltered Measure 43407666326 (ab93cc57 against 8accf4f6) leaves all 146 export hashes and all 121 diagnostics.json equal to main's: the quoted stream name moves no diagnostics of any Measure model (none has an unread stream), and no scorer output moves.
  • Row 3: the same-project gates check run on ab93cc57 is success (15 samples held to their earlier saves, and the Areas on 4 saves and on the 2021 save). The commit after it changes documents only.
  • Row 4: CI's Python job passes test_package_import.py and test_gil_released.py on the wheel it builds. I cannot build locally (rule of this repository), so CI is the first compile of this change, including py.detach's Ungil bounds.
  • tests/resource_limits_cli.rs passes with the quoted name (CI).

Not measured: the warning for a partial saved mesh on a real file (no sample in the corpus decodes in part); the GIL release of decoded_elements, element_counts and schedule_csv (the test covers write_ifc and export_diagnostics_json: a call that returns many dicts holds the GIL to build them).

Audit-honesty checklist

  • README / docs reflect the current state after this PR
  • A user-visible change has its entry as a fragment under changelog.d/
  • If a limitation was resolved, the docs are updated (docs/python.md, the stub)
  • Commit messages describe WHAT changed and WHY
  • No emojis in code, docs, or commit messages
  • No private paths, personal email addresses, or internal jargon in committed files
  • Reverse-engineering finding: not one

Legal and contribution hygiene

  • I agree this work is licensable under Apache-2.0
  • This PR contains no Autodesk proprietary source, decompiled internals, or NDA'd SDK content
  • No new test fixtures

Breaking changes

A handle shared between threads. A program that called one RevitFile from two threads used to have the second call wait for the GIL; it now gets RuntimeError while the first runs. It needs a handle for each thread, or a lock (docs/python.md, "Threads"; the fragment says so).

The text of the unread-stream sentence now quotes the stream's name (stream "Partitions/189" (...)), in the CLIs, the diagnostics' warnings, the MCP server and Python. A script that matches the old text needs the quotes.

Related issues

Closes #1884.

…ases the GIL, the stub lists every field kind, a failed extension load is an ImportError, and an unread stream's name is quoted (#1884)

The unread-stream sentence is built in one place (UnreadStream's Display), so
rvt-ifc, rvt-gltf, rvt-rs-mcp, the diagnostics and Python all quote the name
the file gives it. The GIL is released around the decode, the STEP writer, the
diagnostics serialisation and opening a file; a second call on one handle from
another thread still raises RuntimeError. No export moves.
…call on it now raises where it used to wait for the GIL (#1884)
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 13, 2026 10:41
…name quoted, as the reader now writes it (#1884)

The browser test read 'Not read whole: stream BasicFileInfo ' from the
diagnostics panel; the name is now quoted (text from the file), and the panel's
JSON escapes the quotes. Found in the full CI run of #1901.
@DrunkOnJava

Copy link
Copy Markdown
Owner Author

Approved at 2257546 by the review bot as a self-approval, under Griffin's answer of 2026-11-12 ("You are allowed to self-approve"): rvtDevelop's session has not read the head sent to it at about 11:40 UTC. I re-read the whole diff (each py.detach call and what it borrows, the warning for a partial saved mesh, the package import, the quoted stream name and the tests that pin it) as if another session had written it.

@DrunkOnJava
DrunkOnJava merged commit 7109aad into main Nov 13, 2026
36 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/1884-python-bindings branch November 13, 2026 13:06
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.

python: a partial saved mesh raises no RuntimeWarning, exports hold the GIL, and the stub forbids kinds the binding returns

1 participant