Describe the bug
When test_scenarioDataToViz is run alongside other tests that use Viz, the test fails, and causes other tests to fail. It is also not a test ordering dependency, but rather a test collection dependency: just being in the same test instance as other tests that use viz, causes those other tests to fail, even if those tests run first.
A typical error is usually in the form of
> del viz.settings.instrumentGuiSettingsList[:] # clear settings list to replace it with updated list
E TypeError: 'SwigPyObject' object does not support item deletion
It seems like the offending line is line 75 in the scenario itself. Just importing dataFileToViz causes problems for other Viz usage. If the line is commented out, tests other than test_scenarioDataToViz will all pass.
from Basilisk.simulation import dataFileToViz
It seems like importing dataFileToViz messes with the SWIG proxy stuff? Adding a breakpoint and looking at when dataFileToViz was or was not imported, we can observe
# BAD case PDB output
-> del viz.settings.instrumentGuiSettingsList[:] # clear settings list to replace it with updated list
(Pdb) viz.settings.instrumentGuiSettingsList
<Swig Object of type 'std::vector< InstrumentGuiSettings,std::allocator< InstrumentGuiSettings > > *' at 0x146f08540>
# continuing to try to interact with viz.settings.instrumentGuiSettingsList will show weird behavior, like not having the std vector functions like size()
(Pdb) viz.settings.instrumentGuiSettingsList.empty()
*** AttributeError: 'SwigPyObject' object has no attribute 'empty'
(Pdb) viz.settings.instrumentGuiSettingsList.size()
*** AttributeError: 'SwigPyObject' object has no attribute 'size'
# GOOD case PDB output
-> del viz.settings.instrumentGuiSettingsList[:] # clear settings list to replace it with updated list
(Pdb) viz.settings.instrumentGuiSettingsList
<Basilisk.simulation.vizInterface.InstrumentGuiSettingsConfig; proxy of <Swig Object of type 'std::vector< InstrumentGuiSettings > *' at 0x148c78b10> >
(Pdb) viz.settings.instrumentGuiSettingsList.empty()
True
(Pdb) viz.settings.instrumentGuiSettingsList.size()
0
To reproduce
pytest -vv src/tests # many tests fail
find src/tests -name \*.py | sort | grep -v DataToViz | xargs pytest -vv # all tests pass
Expected behavior
All tests to pass when run together
Screenshots
N/A
Desktop (please complete the following information):
Platform 1 (bug present):
- OS: macOS
- Version: 0c1bdcc
- Python version: 3.11.6
- SWIG version: 4.2.1
Platform 2 (bug present):
- OS: Linux
- Version: 0c1bdcc
- Python version: 3.10.12
- SWIG version: 4.2.1
Platform 3 (bug present):
- OS: Linux
- Version: 0c1bdcc
- Python version: 3.10.12
- SWIG version: 4.2.0
Platform 4 (behaves as expected):
- OS: Linux
- Version: 0c1bdcc
- Python version: 3.10.12
- SWIG version: 4.0.1
Platform 5 (behaves as expected):
- OS: macOS
- Version: 0c1bdcc
- Python version: 3.11.6
- SWIG version: 4.1.1
Additional context
The bug was tested for existence on all the listed platforms, however all other debugging/troubleshooting happened on macOS Platform 1.
No detailed analysis of what SWIG, Basilisk, or Python versions have the bug was done, but based on the testing done, I suspect it is specific to SWIG 4.2.0+.
This seems related to #579
Describe the bug
When test_scenarioDataToViz is run alongside other tests that use Viz, the test fails, and causes other tests to fail. It is also not a test ordering dependency, but rather a test collection dependency: just being in the same test instance as other tests that use viz, causes those other tests to fail, even if those tests run first.
A typical error is usually in the form of
It seems like the offending line is line 75 in the scenario itself. Just importing dataFileToViz causes problems for other Viz usage. If the line is commented out, tests other than test_scenarioDataToViz will all pass.
It seems like importing dataFileToViz messes with the SWIG proxy stuff? Adding a breakpoint and looking at when dataFileToViz was or was not imported, we can observe
To reproduce
Expected behavior
All tests to pass when run together
Screenshots
N/A
Desktop (please complete the following information):
Platform 1 (bug present):
Platform 2 (bug present):
Platform 3 (bug present):
Platform 4 (behaves as expected):
Platform 5 (behaves as expected):
Additional context
The bug was tested for existence on all the listed platforms, however all other debugging/troubleshooting happened on macOS Platform 1.
No detailed analysis of what SWIG, Basilisk, or Python versions have the bug was done, but based on the testing done, I suspect it is specific to SWIG 4.2.0+.
This seems related to #579