FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Isolate load_post steps from each other's errors by BIMvoice · Pull Request #9332 · IfcOpenShell/IfcOpenShell · GitHub

Isolate load_post steps from each other's errors - #9332

Open
BIMvoice wants to merge 1 commit into
IfcOpenShell:v0.9.0from
BIMvoice:fix-9329-load-post-resilience
Open

Isolate load_post steps from each other's errors#9332
BIMvoice wants to merge 1 commit into
IfcOpenShell:v0.9.0from
BIMvoice:fix-9329-load-post-resilience

Conversation

Copy link
Copy Markdown
Contributor

Related to #9329. This does not claim to fix that issue, see the honesty section below.

What this changes

load_post ran three independent setup steps back to back with no isolation:

_apply_save_file_invariants(scene)
_apply_user_preferences()      # <- restores the BIM workspace
_install_viewport_overlays()

An exception anywhere in the first call silently prevents the BIM workspace restore from ever running. Blender swallows handler exceptions quietly, so there is no traceback for the user and no visible failure, just a missing workspace.

Each step now runs through a helper that catches and prints a warning plus traceback, so one failing step cannot skip the others.

Why this is relevant to #9329

Opening a model calls bpy.ops.wm.read_homefile() (bim/module/project/operator.py:1124), which replaces Blender's workspace set. Bonsai relies on _apply_user_preferences() in load_post to put the BIM workspace back (bim/handler.py:471-484). If anything before it throws, the workspace stays gone, which is exactly the reported symptom, including the absence of any error output.

Honesty about what is and is not proven

I did not reproduce the reported bug, and I did not identify which exception fires in the field.

I diffed the entire read_homefile to load_post to workspace-restore chain between v0.8.0 and v0.9.0. handler.py, bim/__init__.py (registration and handler order), the relevant parts of LoadProject, tool.Parametric.on_load_post, and data/workspace.blend are all identical between the branches. So the regression is not visible in this chain, and I cannot say why it appears on 0.9 specifically.

There is no compiled v0.9.0 wrapper available in my environment, so I could not run bpy.ops.bim.load_project_elements() or drive a real v0.9.0 session. A simulation of the sequence against the real workspace.blend on Blender 5.2.0 worked correctly, meaning the append and reactivate mechanism itself is not broken in isolation.

So: this is a structural fix for a failure mode that matches the report exactly, and it is worth having on its own merits, but it is not a confirmed fix for #9329. If someone can reproduce with a console open, the new warning should name the failing step, which would identify the real trigger.

Test

src/bonsai/test/bim/test_load_post_step_isolation.py, an AST contract test in the same style as the existing test_handler_forward_compat.py, so it needs no compiled wrapper. It asserts the three steps are not called bare from load_post and that all three are still invoked. Red against current v0.9.0, green after.

Related, not changed

The same "first exception kills the rest" shape exists one level down in tool.Parametric.on_load_post (bonsai/tool/parametric.py:291-299), where heal_stale_edit_flags(), discard_pending_previews(scene) and wall_offset_gizmos.clear_caches() run unguarded in sequence. Left alone to keep this change to one thing.

black and ruff clean.

Produced with AI assistance.

An exception in _apply_save_file_invariants aborted load_post before
_apply_user_preferences ran, silently dropping the BIM workspace
re-add after wm.read_homefile (IfcOpenShell#9329).
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL