Skip to content

graph node missing workaround - #475

Merged
chenkasirer merged 3 commits into
mainfrom
graph_node
Jul 9, 2025
Merged

graph node missing workaround#475
chenkasirer merged 3 commits into
mainfrom
graph_node

Conversation

@chenkasirer

Copy link
Copy Markdown
Contributor

solves #438

Fixed graph_node goes missing after deserialization of TimberModel. This is a temporary workaround as this issue has been fixed in later versions of Model.

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas_timber.datastructures.Beam.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a temporary workaround to restore missing graph_node references after deserializing a TimberModel, and verifies it with new tests while updating the changelog.

  • Injects a loop in TimberModel.__from_data__ to reassign graph_node on each element post-deserialization.
  • Adds two tests to ensure beam.graph_node survives both JSON serialization and deepcopy.
  • Updates CHANGELOG.md with the new bug‐fix entry.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/compas_timber/test_model.py Added tests verifying graph_node is preserved after (de)serialization
src/compas_timber/model/model.py Inserted a workaround in __from_data__ to restore missing graph nodes
CHANGELOG.md Documented the fix for graph_node being None after deserialization
Comments suppressed due to low confidence (2)

src/compas_timber/model/model.py:55

  • [nitpick] The loop variable graphnode is inconsistent with attribute naming; consider renaming it to graph_node to match element.graph_node.
        for graphnode in model._graph.nodes():

tests/compas_timber/test_model.py:273

  • Point and Vector are used here but not imported; add from compas.geometry import Point, Vector at the top of this test file to avoid NameError.
    frame = Frame(Point(0, 0, 0), Vector(1, 0, 0), Vector(0, 1, 0))

Comment thread tests/compas_timber/test_model.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@obucklin obucklin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how but if you can link this to another PR, but @papachap's TimberModel rework should probably remove this.

LGTM

@chenkasirer
chenkasirer merged commit 63b6292 into main Jul 9, 2025
@chenkasirer
chenkasirer deleted the graph_node branch July 9, 2025 09:46
@codecov

codecov Bot commented Jul 9, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.79%. Comparing base (b8237eb) to head (80fceb7).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #475   +/-   ##
=======================================
  Coverage   63.78%   63.79%           
=======================================
  Files          76       76           
  Lines       10868    10871    +3     
=======================================
+ Hits         6932     6935    +3     
  Misses       3936     3936           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants