ansys / pyacp

Python Client for Ansys Composite PrepPost
https://acp.docs.pyansys.com
MIT License
4 stars 1 forks source link

Fix EdgePropertyList construction via _from_object_info #562

Closed greschd closed 3 weeks ago

greschd commented 3 weeks ago

Fixes #561

The EdgePropertyList retains the same list instance during its lifetime for containing the edge property wrappers. This is done so that references user code might hold to its items to correctly update its contents.

In contrast to other types, it means that the state is not re-fetched from the _pb_object if it were to change outside of the EdgePropertyList's control. This led to a bug when constructing objects via _from_object_info, which first default-constructs the object (in the process creating the EdgePropertyList) and then modifies the _pb_object.

To fix this, the EdgePropertyList now stores whether its parent object was stored when this list was last accessed. If it changes from unstored to stored, the following logic is applied:

Since the edge property list can be in an inconsistent state (empty when it shouldn't be) while the parent is unstored, we disallow accessing it in this state. It is still allowed however to fully replace the contents.

This PR also fixes a bug in tree_object_from_resource_path, where the channel argument was still used instead of server_wrapper.

greschd commented 3 weeks ago

@roosre this is a fairly significant bugfix, I'd suggest we do a 0.1b2 release for it (and only drop Python 3.9 support after that).

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.91%. Comparing base (eb5056c) to head (661edaf). Report is 2 commits behind head on main.

Files Patch % Lines
...ore/_tree_objects/_grpc_helpers/property_helper.py 88.88% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #562 +/- ## ========================================== + Coverage 91.93% 92.91% +0.97% ========================================== Files 82 82 Lines 4242 4291 +49 ========================================== + Hits 3900 3987 +87 + Misses 342 304 -38 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

greschd commented 3 weeks ago

Still figuring out some edge cases when the cloned object is accessed before storing.