Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change BlenderObject lookup #687

Merged
merged 30 commits into from
Dec 17, 2024
Merged

Change BlenderObject lookup #687

merged 30 commits into from
Dec 17, 2024

Conversation

BradyAJohnston
Copy link
Owner

@BradyAJohnston BradyAJohnston commented Dec 14, 2024

BlenderObject and thus MolecularEntity references to blender's objects are tweaker to just use a name (and potentialy .uuid backup reference) instead of reference to the actual bpy.data.objects['oject'] data block.

The Problem

Previously the BlenderObject/MolecularEntity had the property bob.object which returned the object in Blender's database that was linked to this entity. This was previously stored as the actual reference to the object itself. This was bad because sometimes that object would change in Blender's database and we would lose connection. This could be re-established with the object.uuid custom property defined. If the connection was lost we would just loop through all objects in the database for something with that uuid and re-establish the connection.

This didn't work well with pickling though, as bpy.data.Object couldn't be pickled.

The Solution

References to objects, collections, and other components of Blender's database are instead stored as a string of their name. This way every time we want to access the object it queries the database for the object. This fails if objects are renamed, because there is no deeper reference to the objects inside of Blender that we have access to, so with the bpy.types.Object.uuid property, we can do the same as previously and just iterate through the database looking for our match.

Copy link

codecov bot commented Dec 14, 2024

Codecov Report

Attention: Patch coverage is 81.45161% with 23 lines in your changes missing coverage. Please review.

Project coverage is 72.20%. Comparing base (bd0ed8c) to head (f1c533c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
molecularnodes/bpyd/object.py 68.08% 15 Missing ⚠️
molecularnodes/session.py 58.33% 5 Missing ⚠️
molecularnodes/ui/panel.py 0.00% 2 Missing ⚠️
molecularnodes/entities/molecule/molecule.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #687      +/-   ##
==========================================
+ Coverage   71.85%   72.20%   +0.35%     
==========================================
  Files          65       65              
  Lines        4661     4731      +70     
==========================================
+ Hits         3349     3416      +67     
- Misses       1312     1315       +3     

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

only when run with all other tests, I fucking hate it here
@BradyAJohnston
Copy link
Owner Author

The tests are all passing on GHA but the final tests related to trajectories fail on my local machines.

When running the individual tests with -k traj they pass fine, it's only when running all tests and they are last they fail. But running all tests and they are last on the GHA runners they pass. I am going insane.

@BradyAJohnston
Copy link
Owner Author

The tests pass on local machine if running tests in a uv environment instead of inside of Blender, but I can't run the tests involving density that way as the bpy python module doesn't ship with pyopenvdb.

uv venv python=3.11
source .venv/scripts/activate
uv pip install -r pyproject.toml --all-extras
uv pip install -e .
uv run -m pytest

@BradyAJohnston
Copy link
Owner Author

I just nuked all installed & development add-ons, now the tests pass locally. Also did some tweaking. Will come back to this after I've had some time away, what a waste of 1.5 days.

@BradyAJohnston BradyAJohnston merged commit 9f15b90 into main Dec 17, 2024
7 of 8 checks passed
@BradyAJohnston BradyAJohnston deleted the blender-object branch December 17, 2024 08:09
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