Archived issue #0033562
BRepTools::Write makes the kernel of jupyter died
Description
The kernel of jupyter is crashed when a Python method binding to "BRepTools::Write" is called.
The phenomenon only happens on Linux OS.
The phenomenon only happens on Linux OS.
Steps to reproduce
You can use any Python package binding to OpenCascade to test, For example: pyocct.
For me, I'm using the topologicpy package which is a python package bindings to the Topologic (github repo: https://github.com/wassimj/Topologic)
The steps to reproduce are shown below
1. Create the conda environment. Below is content of "conda_env_topologic_py310.yml" file
~~~~
name: topologic_py310
channels:
- conda-forge
dependencies:
- python=3.10
- pip
# opencascade
- occt=7.7.1
# build tools
- cxx-compiler
- cmake
- ninja
- pip:
- auditwheel ; platform_system == "Linux"
- patchelf ; platform_system == "Linux"
- delocate
- numpy
- ipykernel
- topologicpy
- machomachomangler ; platform_system == "Windows"
- pefile ; platform_system == "Windows"
~~~~
-> Then build the conda environment with command "conda env create -f conda_env_topologic_py310.yml"
2. Activate the Conda environment with command "conda activate topologic_py310"
3. Build and install the Topologic into the conda environment
~~~~{.bash}
$ git clone [email removed]:wassimj/Topologic.git
$ cd Topologic/TopologicPythonBinding
$ python build_linux.py
$ pip install wheelhouse/topologic-5.0.0-cp310-cp310-linux_x86_64.whl
~~~~
4. Create a kernel for the conda environment with command "python -m ipykernel install --user --name=topologic_py310"
5. Run the below code on jupyter notebook or using an extension on vscode
~~~~{.python}
from topologicpy.Vertex import Vertex
from topologicpy.Topology import Topology
v = Vertex.ByCoordinates(0,0,0)
s = Topology.BREPString(v)
print(s)
~~~~
And then you choose the above kernel, say "topologic_py310", for jupyter.
Click "Run" button, you will see the message "The Kernel crashed while executing code in the current cell ..." on vscode or somethings like that on the web interface of the jupyter noebook.
I have already troubleshooted and saw that jupyter was crashed when "Topology.BREPString(v)" method is called. This method is binding to the method C++
https://github.com/wassimj/Topologic/blob/main/TopologicCore/src/Topology.cpp#L1277-L1298
~~~~{.C++}
std::string Topology::String(const int kVersion = 3) const
{
std::ostringstream oss(std::ios_base::out);
if (kVersion == 1)
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_VERSION_1);
}
else if (kVersion == 2)
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_VERSION_2);
}
else if (kVersion == 3)
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_VERSION_3);
}
else
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_CURRENT);
}
return oss.str();
}
~~~~
Please get the attached file for more details
For me, I'm using the topologicpy package which is a python package bindings to the Topologic (github repo: https://github.com/wassimj/Topologic)
The steps to reproduce are shown below
1. Create the conda environment. Below is content of "conda_env_topologic_py310.yml" file
~~~~
name: topologic_py310
channels:
- conda-forge
dependencies:
- python=3.10
- pip
# opencascade
- occt=7.7.1
# build tools
- cxx-compiler
- cmake
- ninja
- pip:
- auditwheel ; platform_system == "Linux"
- patchelf ; platform_system == "Linux"
- delocate
- numpy
- ipykernel
- topologicpy
- machomachomangler ; platform_system == "Windows"
- pefile ; platform_system == "Windows"
~~~~
-> Then build the conda environment with command "conda env create -f conda_env_topologic_py310.yml"
2. Activate the Conda environment with command "conda activate topologic_py310"
3. Build and install the Topologic into the conda environment
~~~~{.bash}
$ git clone [email removed]:wassimj/Topologic.git
$ cd Topologic/TopologicPythonBinding
$ python build_linux.py
$ pip install wheelhouse/topologic-5.0.0-cp310-cp310-linux_x86_64.whl
~~~~
4. Create a kernel for the conda environment with command "python -m ipykernel install --user --name=topologic_py310"
5. Run the below code on jupyter notebook or using an extension on vscode
~~~~{.python}
from topologicpy.Vertex import Vertex
from topologicpy.Topology import Topology
v = Vertex.ByCoordinates(0,0,0)
s = Topology.BREPString(v)
print(s)
~~~~
And then you choose the above kernel, say "topologic_py310", for jupyter.
Click "Run" button, you will see the message "The Kernel crashed while executing code in the current cell ..." on vscode or somethings like that on the web interface of the jupyter noebook.
I have already troubleshooted and saw that jupyter was crashed when "Topology.BREPString(v)" method is called. This method is binding to the method C++
https://github.com/wassimj/Topologic/blob/main/TopologicCore/src/Topology.cpp#L1277-L1298
~~~~{.C++}
std::string Topology::String(const int kVersion = 3) const
{
std::ostringstream oss(std::ios_base::out);
if (kVersion == 1)
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_VERSION_1);
}
else if (kVersion == 2)
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_VERSION_2);
}
else if (kVersion == 3)
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_VERSION_3);
}
else
{
BRepTools::Write(GetOcctShape(), oss, false, true, TopTools_FormatVersion_CURRENT);
}
return oss.str();
}
~~~~
Please get the attached file for more details
Public activity
No public notes
Participants are labeled by their role within this record.