Skip to content

Commit

Permalink
Merge pull request #90 from fusion-energy/catching_failed_in_memory
Browse files Browse the repository at this point in the history
added try execpt for failed in memory
  • Loading branch information
shimwell authored Oct 14, 2024
2 parents 5cd38e4 + c286acd commit 417f236
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 126 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci_with_benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:

jobs:
testing:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -37,9 +37,9 @@ jobs:
sudo apt-get upgrade -y
sudo apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev libpangocairo-1.0-0
mamba activate
mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" moab>=5.3.0 gmsh python-gmsh
python -m pip install --upgrade pip
python -m pip install .
mamba install -y -c conda-forge "openmc=0.15.0=dagmc*nompi*" trimesh networkx cadquery gmsh python-gmsh
python -m ensurepip --upgrade
python -m pip install . --no-deps
python -m pip install openmc_data_downloader
openmc_data_downloader -l ENDFB-7.1-NNDC -i Fe56 Be9
git clone --single-branch -b main --depth 1 https://github.com/fusion-energy/model_benchmark_zoo.git
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# This CI does includes particle transport tests as openmc is installed

name: CI with install
name: CI with Conda install

on:
pull_request:
Expand All @@ -20,7 +20,7 @@ on:

jobs:
testing:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
Expand All @@ -42,11 +42,12 @@ jobs:
mamba activate
mamba create -y --name cad_to_dagmc python=${{ matrix.python-version }}
mamba activate cad_to_dagmc
mamba install -y -c conda-forge "openmc=0.14.0=dagmc*nompi*" gmsh python-gmsh
python -m pip install --upgrade pip
python -m pip install .
mamba install -y -c conda-forge "openmc=0.15.0=dagmc*nompi*" trimesh networkx cadquery gmsh python-gmsh
python -m ensurepip --upgrade
python -m pip install . --no-deps
python -c "import cad_to_dagmc"
python -m pip install .[tests]
mamba install -y -c conda-forge pytest vtk
python -m pip install .[tests] --no-deps
pytest -v tests
python examples/surface_mesh/cadquery_assembly.py
python examples/surface_mesh/cadquery_compound.py
Expand Down
25 changes: 9 additions & 16 deletions .github/workflows/ci_with_pip_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:

jobs:
testing:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
container:
image: openmc/openmc:develop-dagmc
steps:
Expand All @@ -33,26 +33,19 @@ jobs:
apt-get --allow-releaseinfo-change update
apt-get update -y
apt-get upgrade -y
apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev libpangocairo-1.0-0 libxcursor-dev libxft2 libxinerama-dev
apt-get install -y make cmake
apt-get install -y libhdf5-dev libblas-dev liblapack-dev libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev libarchive-dev libpangocairo-1.0-0 libxcursor-dev libxft2 libxinerama-dev make cmake libeigen3-dev
apt install python3
apt install python3-pip
python -m pip install --upgrade pip
mkdir MOAB
cd MOAB
git clone --single-branch -b 5.5.1 --depth 1 https://bitbucket.org/fathomteam/moab/
mkdir build
cd build
apt-get install -y libeigen3-dev
cmake ../moab -DENABLE_PYMOAB=ON -DENABLE_HDF5=ON -DENABLE_BLASLAPACK=OFF -DENABLE_FORTRAN=OFF
make -j2
make install
cd ../..
python -m pip install .
python -c "import cad_to_dagmc"
git clone --single-branch -b master --depth 1 https://bitbucket.org/fathomteam/moab/
cd moab
git checkout faf7e989c0fd0be4a19f61c1d4713afc5397c8a7
python -m pip install . --config-settings=cmake.args=-DENABLE_HDF5=ON
cd ..
python -c "import pymoab"
python -m pip install .[tests]
python -c "import cad_to_dagmc"
pytest -v tests
cd examples
python examples/surface_mesh/cadquery_assembly.py
python examples/surface_mesh/cadquery_compound.py
python examples/surface_mesh/cadquery_object_and_stp_file.py
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ dmypy.json
*.stp
src/_version.py
*.msh
*.step
69 changes: 13 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Also checkout these other software projects that also create DAGMC geometry [CAD

- Install using Mamba
- Install using Conda
- Install using Mamba and pip
- Install using Conda and pip
- Install using pip and source compilations

## Install using Mamba
Expand Down Expand Up @@ -84,73 +82,32 @@ Then you can install the cad_to_dagmc package
conda install -y -c conda-forge cad_to_dagmc
```

## Install using Mamba and pip
## Install using pip and source compilations

In principle, installing any Conda/Mamba distribution will work. A few Conda/Mamba options are:
- [Miniforge](https://github.com/conda-forge/miniforge) (recommended as it includes mamba)
- [Anaconda](https://www.anaconda.com/download)
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
It is also possible to avoid the use of conda/mamba and installing using pip.

This example assumes you have installed the Miniforge option or separately have installed Mamba with ```conda install -c conda-forge mamba -y```
First ensure hdf5 is installed as this is needed by MOAB pip install command

Create a new environment, I've chosen Python 3.10 here but newer versions are
also supported.
```bash
mamba create --name new_env python=3.10 -y
```

Activate the environment
```bash
mamba activate new_env
sudo apt-get install libhdf5-dev
```

Install the dependencies
```bash
mamba install -y -c conda-forge "moab>=5.3.0" gmsh python-gmsh
```
Then clone the latest version of MOAB and cd into the moab directory.

Then you can install the cad_to_dagmc package
```bash
pip install cad_to_dagmc
```


## Install using Conda and pip

In principle, installing any Conda/Mamba distribution will work. A few Conda/Mamba options are:
- [Miniforge](https://github.com/conda-forge/miniforge) (recommended as it includes mamba)
- [Anaconda](https://www.anaconda.com/download)
- [Miniconda](https://docs.conda.io/en/latest/miniconda.html)

This example uses Conda to install some dependencies that are not available via PyPi.

Create a new environment
```bash
conda create --name new_env python=3.10 -y
git clone master https://bitbucket.org/fathomteam/moab/
cd moab
```

Activate the environment
```bash
conda activate new_env
Ensure pip is up to date as a new version is needed
```

Install the dependencies
```bash
conda install -y -c conda-forge "moab>=5.3.0" gmsh python-gmsh
python -m pip install --upgrade pip
```

Then you can install the cad_to_dagmc package
```bash
pip install cad_to_dagmc
Run the pip install command with cmake arguments.
```
pip install . --config-settings=cmake.args=-DENABLE_HDF5=ON
```

## Install using pip and source compilations

It should possible to avoid the use of conda and installing using pip and compiling from source.

First compile MOAB (and install Pymoab) from source

Then install gmsh from source (installing from pip appears to cause conflicts with the open cascade used in ocp and cadquery)

Then you can install the cad_to_dagmc package with ```pip```

Expand Down Expand Up @@ -178,7 +135,7 @@ The package requires newer versions of Linux. For example the package does not w

The package requires newer versions of pip. It is recommended to ensure that your version of pip is up to date. This can be done with ```python -m pip install --upgrade pip```

Installing one of the package dependancies (gmsh) with pip appears to result in occational errors when passing cad objects between cadquery / ocp and gmsh. The conda install gmsh appears to work fine.
Installing one of the package dependancies (gmsh) with pip appears to result in errors when passing cad objects in memory between cadquery / ocp and gmsh. The default method of passing cad objects is via file so this should not impact most users. The conda install gmsh appears to work fine with in memory passing of cad objects as the version of OCP matches between Gmsh and CadQuery.


# Usage - creation of DAGMC h5m files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def gear(t, r1=4, r2=1):

my_model = CadToDagmc()

my_model.add_cadquery_object(result)
my_model.add_cadquery_object(result2)
my_model.add_cadquery_object(result, material_tags=["mat1"])
my_model.add_cadquery_object(result2, material_tags=["mat2"])

my_model.export_unstructured_mesh_file(filename="umesh.h5m", max_mesh_size=1, min_mesh_size=0.1)
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ dependencies = [
"trimesh",
"networkx",
"cadquery>=2.4.0",
"numpy<=1.23.5",
"gmsh"
]
dynamic = ["version"]

Expand Down
Loading

0 comments on commit 417f236

Please sign in to comment.