Skip to content

Add toppology tests in script - #137

Open
bakpaul wants to merge 4 commits into
sofa-framework:masterfrom
bakpaul:26_09_add_toppology_tests
Open

bakpaul wants to merge 4 commits into
sofa-framework:masterfrom
bakpaul:26_09_add_toppology_tests

Conversation

@bakpaul

@bakpaul bakpaul commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

This PR adds the topology-based regression test to the scripts. Only last commit was AI-generated. The CLAUDE.md file used is copy/pasted at the end of this description minus the part regarding environment handling.

This PR proposes an architecture where this specialization is at the level of the SceneData. I make sure to be as agnostic as possible ot the type of regression in every part of the script meaning that adding a new one will be pretty easy. The only remaining part that is not agnostic is in the Worker file :

## Remove data that break json. Not every regression type carries
## every one of these attributes (e.g. TopologyRegressionSceneData
## has no "meca_objs"), so remove them only if present.
for key in ("meca_objs", "root_node", "topology", "error_topology"):
    result.pop(key, None)

This cleans the structure removing object which representation mught break the json. It will need to beenriched it we add new types, but except from this it it fine (could be agnostic too if we add a static function in the data class that return the key we need to clean...)

This is the CLAUDE.ms file I used

You are a python expert.
We are working on a non-regression test suite for SOFA framework that is under "/workspace/Regression/SofaRegressionProgram", you cannot touch the other folder in writting.
The goal of this script is to run all scene found under configuration files and compare results to references.
It is python-based

## Your work

The tool must support two types of regression : STATE and TOPOLOGY.
The full STATE regression is already implemented, you'll need to implement the TOPOLOGY regression.

The job has been bootstraped for you, your work is to implement the methods on the class `TopologyRegressionSceneData`. Normally all the rest and its interaction with the core of the script has already been taken care of.

This kind of Regression test will check at every timestep the content of the topologies of the scene. It'll compare the list of edges, trizangles, quads, tetrahedra and hexaeda. compare tehm and compute a difference in size.

This has already been implemented in C++ under /workspace/Regression/Regression_test. You can take a look at it, it uses some SOFA visitors to compute the error, you can take a look at them in the source code of SOFA to understand properly how the error is computed.

Your role is to make sure this is recreated following the same structure ad the STATE one that has been already implemented

An added constraint is that you'll need to run the  vanilla scenes. In the original C++ version, because xml wasn't scripted, it required to add objects in the scene to output the topology information. Here I don't want that, access the object and data directly in the python code using the bindings.


## Environment handling
[...]
First you'll need to generate the references
python3 SofaRegressionProgram/SofaRegressionProgram.py --input /workspace/sofa -j 10 --verbose 1 --regression-type TOPOLOGY --write-references

When this command output properly the reference files and they contain the same information as the legacy ones (in Json) then you can move one to comparing them

To do this you launch
python3 SofaRegressionProgram/SofaRegressionProgram.py --input /workspace/sofa -j 10 --verbose 1 --regression-type TOPOLOGY

- first you'll need to get to the point where every test pass with both legacy and new reference files
- then it is important to check if you catch all regression type error : for this modify the regression file by hand to break them and see if you catch the errors.


- finally make sure that the error generated by this test are outputed properly in the log file when adding the option --output-logs-errors "/workspace/logs"

[..]

@bakpaul
bakpaul requested review from epernod and fredroy and removed request for epernod September 18, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant