Skip to content

Commit 81e9df6

Browse files
authored
Merge pull request #6 from virtualcell/unit-test
smoke test for FiniteVolume and Smoldyn
2 parents 32ac753 + 89b6ff1 commit 81e9df6

File tree

656 files changed

+1096
-94174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

656 files changed

+1096
-94174
lines changed

.github/workflows/cd.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: CD
22

3-
on:
3+
on:
4+
workflow_dispatch:
45
pull_request:
56
push:
67
branches:
@@ -24,6 +25,8 @@ jobs:
2425
steps:
2526
- name: Checkout repository
2627
uses: actions/checkout@v4
28+
with:
29+
submodules: true
2730

2831
- name: Log in to the Container registry
2932
uses: docker/login-action@v3
@@ -60,19 +63,24 @@ jobs:
6063
steps:
6164
- name: checkout vcell-solvers repo
6265
uses: actions/checkout@v4
66+
with:
67+
submodules: true
6368

6469
- name: Install Intel MacOS dependencies
6570
if: matrix.platform == 'macos-13'
6671
shell: bash
6772
run: |
6873
brew install boost
6974
brew install hdf5
75+
brew install libzip
7076
brew install ninja
77+
brew install libaec
7178
7279
brew install llvm
7380
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile
7481
source /Users/runner/.bash_profile
75-
82+
ln -s $(which gfortran-14) /usr/local/bin/gfortran
83+
7684
gcc --version
7785
gfortran --version
7886
cmake --version
@@ -85,7 +93,9 @@ jobs:
8593
run: |
8694
brew install boost
8795
brew install hdf5
96+
brew install libzip
8897
brew install ninja
98+
brew install libaec
8999
90100
brew install llvm
91101
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile
@@ -209,7 +219,7 @@ jobs:
209219
mkdir build
210220
cd build
211221
212-
PATH="/c/Program\ Files/LLVM/bin:$PATH"
222+
export PATH="/c/Program\ Files/LLVM/bin:$PATH"
213223
214224
cmake \
215225
-G Ninja \
@@ -232,6 +242,9 @@ jobs:
232242
echo "working dir is $PWD"
233243
234244
cd build
245+
246+
export PATH="/d/a/_temp/msys64/clang64/bin:$PATH"
247+
pacman -Sy --noconfirm diffutils
235248
236249
ctest -VV
237250
@@ -243,9 +256,7 @@ jobs:
243256
if: matrix.platform == 'ubuntu-latest'
244257
run: |
245258
sudo apt-get update
246-
sudo apt-get install -y libboost-all-dev
247-
sudo apt-get install -y libhdf5-dev
248-
sudo apt-get install -y ninja-build
259+
sudo apt-get install -y libboost-all-dev libhdf5-dev libzip-dev libbz2-dev ninja-build
249260
250261
gcc --version
251262
gfortran --version

.github/workflows/conda.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424

2525
steps:
2626
- uses: actions/checkout@v4
27+
with:
28+
submodules: true
29+
2730

2831
- name: Get conda
2932
uses: conda-incubator/setup-miniconda@v3.0.4

.github/workflows/pip.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,23 @@ jobs:
2828

2929
steps:
3030
- uses: actions/checkout@v4
31+
with:
32+
submodules: true
3133

3234
- name: Install Intel MacOS dependencies
3335
if: matrix.platform == 'macos-13'
3436
shell: bash
3537
run: |
3638
brew install boost
3739
brew install hdf5
40+
brew install libzip
3841
brew install ninja
42+
brew install libaec
3943
4044
brew install llvm
4145
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile
4246
source /Users/runner/.bash_profile
47+
ln -s $(which gfortran-14) /usr/local/bin/gfortran
4348
4449
gcc --version
4550
gfortran --version
@@ -54,7 +59,9 @@ jobs:
5459
run: |
5560
brew install boost
5661
brew install hdf5
62+
brew install libzip
5763
brew install ninja
64+
brew install libaec
5865
5966
brew install llvm
6067
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile
@@ -130,9 +137,9 @@ jobs:
130137

131138
- name: Build and install manylinux for python 3.9
132139
run: |
133-
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 \
140+
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux_2_34_x86_64 \
134141
/bin/bash -c \
135-
"yum install -y boost-devel hdf5-devel ninja-build && \
142+
"yum install -y boost-devel hdf5-devel libzip-devel bzip2-devel ninja-build openssl-devel xz-devel && \
136143
/opt/python/cp39-cp39/bin/pip wheel /io/ -w /io/dist && \
137144
auditwheel repair /io/dist/*.whl -w /io/dist/"
138145
echo "keeping only the manylinux wheels, remove those with -linux_x86_64.whl in the name"
@@ -142,9 +149,9 @@ jobs:
142149

143150
- name: Build and install manylinux for python 3.10
144151
run: |
145-
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 \
152+
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux_2_34_x86_64 \
146153
/bin/bash -c \
147-
"yum install -y boost-devel hdf5-devel ninja-build && \
154+
"yum install -y boost-devel hdf5-devel libzip-devel bzip2-devel ninja-build openssl-devel xz-devel && \
148155
/opt/python/cp310-cp310/bin/pip wheel /io/ -w /io/dist && \
149156
auditwheel repair /io/dist/*.whl -w /io/dist/"
150157
echo "keeping only the manylinux wheels, remove those with -linux_x86_64.whl in the name"
@@ -154,9 +161,9 @@ jobs:
154161

155162
- name: Build and install manylinux for python 3.11
156163
run: |
157-
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 \
164+
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux_2_34_x86_64 \
158165
/bin/bash -c \
159-
"yum install -y boost-devel hdf5-devel ninja-build && \
166+
"yum install -y boost-devel hdf5-devel libzip-devel bzip2-devel ninja-build openssl-devel xz-devel && \
160167
/opt/python/cp311-cp311/bin/pip wheel /io/ -w /io/dist && \
161168
auditwheel repair /io/dist/*.whl -w /io/dist/"
162169
echo "keeping only the manylinux wheels, remove those with -linux_x86_64.whl in the name"
@@ -166,9 +173,9 @@ jobs:
166173

167174
- name: Build and install manylinux for python 3.12
168175
run: |
169-
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux2014_x86_64 \
176+
docker run --rm -v $(pwd):/io quay.io/pypa/manylinux_2_34_x86_64 \
170177
/bin/bash -c \
171-
"yum install -y boost-devel hdf5-devel ninja-build && \
178+
"yum install -y boost-devel hdf5-devel libzip-devel bzip2-devel ninja-build openssl-devel xz-devel && \
172179
/opt/python/cp312-cp312/bin/pip wheel /io/ -w /io/dist && \
173180
auditwheel repair /io/dist/*.whl -w /io/dist/"
174181
echo "keeping only the manylinux wheels, remove those with -linux_x86_64.whl in the name"
@@ -260,4 +267,5 @@ jobs:
260267
if: ${{ failure() }}
261268
with:
262269
github-token: ${{ secrets.GITHUB_TOKEN }}
270+
limit-access-to-actor: false
263271

.github/workflows/wheels.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ jobs:
115115
sudo apt-get update
116116
sudo apt-get install -y libboost-all-dev
117117
sudo apt-get install -y libhdf5-dev
118+
sudo apt-get install -y libzip-dev
118119
sudo apt-get install -y ninja-build
119120
120121
gcc --version

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@
2626
tests/__pycache__/
2727

2828
*.whl
29+
30+
VCell/tests/testFiles/output/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
path = extern/pybind11
33
url = ../../pybind/pybind11
44
branch = stable
5+
[submodule "libzippp"]
6+
path = libzippp
7+
url = https://github.com/ctabin/libzippp.git

CMakeLists.txt

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ option(OPTION_USE_ZLIB "Build with Zlib support" ON)
1111
option(OPTION_USE_LIBTIFF "Build with LibTiff support" OFF)
1212
option(OPTION_USE_ICONV "Build with Libiconv support" OFF)
1313

14+
# need to statically link everything for the python bindings and standalone solvers
15+
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
16+
set(BUILD_SHARED_LIBS OFF)
1417

1518
if (OPTION_TARGET_PYTHON_BINDING)
1619
project(
@@ -123,11 +126,21 @@ elseif (MINGW)
123126
endif()
124127

125128
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
129+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/libzippp/cmake/")
126130

127131
include(GetGitRevisionDescription)
128132
git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
129133

130134
include (FindZLIB)
135+
include (FindLIBZIP)
136+
137+
# help CMake find libzip
138+
if (APPLE)
139+
execute_process(COMMAND brew --prefix libzip OUTPUT_VARIABLE LIBZIP_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
140+
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${LIBZIP_PREFIX})
141+
endif()
142+
find_package(LIBZIP 1.10 REQUIRED)
143+
131144

132145
if (NOT OPTION_TARGET_PYTHON_BINDING)
133146
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@@ -185,15 +198,59 @@ if (LINUX AND OPTION_TARGET_PYTHON_BINDING)
185198
endif()
186199

187200
#CMakeList.txt that comes with hdf5 switches library name if compiled with debug
201+
if (APPLE)
202+
execute_process(COMMAND brew --prefix libaec OUTPUT_VARIABLE LIBAEC_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
203+
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${LIBAEC_PREFIX})
204+
find_package(libaec REQUIRED)
205+
endif()
188206
find_package(HDF5 COMPONENTS HL CXX C)
189207
set(HDF_VERSION ${HDF5_VERSION})
190208
###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES}
191209

210+
if (OPTION_TARGET_TESTS)
211+
enable_testing()
212+
set(LIBZIPPP_BUILD_TESTS ON)
213+
endif ()
214+
192215
add_subdirectory(VCellMessaging)
193216

194217
add_subdirectory(VCellZipUtils)
195218

196-
add_subdirectory(libzip-1.2.0)
219+
220+
221+
222+
add_subdirectory(libzippp)
223+
# Path to the patch file
224+
set(PATCH_FILE "${CMAKE_SOURCE_DIR}/patches/libzippp_patch.diff")
225+
# Path to the file to be patched
226+
set(FILE_TO_PATCH "${CMAKE_SOURCE_DIR}/libzippp/src/libzippp.cpp")
227+
# Apply the patch
228+
if (WIN32)
229+
add_custom_command(
230+
OUTPUT ${FILE_TO_PATCH}
231+
COMMAND ${CMAKE_COMMAND} -E echo "Applying patch to libzippp"
232+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE_TO_PATCH} ${FILE_TO_PATCH}.bak
233+
COMMAND ${CMAKE_COMMAND} -E touch ${FILE_TO_PATCH}
234+
COMMAND git apply ${PATCH_FILE}
235+
DEPENDS ${PATCH_FILE}
236+
COMMENT "Patching libzippp"
237+
)
238+
else()
239+
add_custom_command(
240+
OUTPUT ${FILE_TO_PATCH}
241+
COMMAND ${CMAKE_COMMAND} -E echo "Applying patch to libzippp"
242+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FILE_TO_PATCH} ${FILE_TO_PATCH}.bak
243+
COMMAND ${CMAKE_COMMAND} -E touch ${FILE_TO_PATCH}
244+
COMMAND patch --forward ${FILE_TO_PATCH} < ${PATCH_FILE} | true
245+
DEPENDS ${PATCH_FILE}
246+
COMMENT "Patching libzippp"
247+
)
248+
endif()
249+
# Ensure the patch is applied before building the submodule
250+
add_custom_target(apply_patch ALL DEPENDS ${FILE_TO_PATCH})
251+
add_dependencies(libzippp apply_patch)
252+
253+
197254

198255
add_subdirectory(ExpressionParser)
199256

Dockerfile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
FROM ubuntu:22.04 as build
1+
FROM ubuntu:22.04
22

33
RUN apt-get -y update && apt-get install -y apt-utils && \
4-
apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran zlib1g-dev \
5-
libhdf5-dev ninja-build libcurl4-openssl-dev libboost-all-dev cmake wget python3
4+
apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran \
5+
libhdf5-dev libzip-dev ninja-build libcurl4-openssl-dev libboost-all-dev libbz2-dev cmake python3
6+
7+
# Install an alternative Fortran compiler
8+
RUN apt-get install -y gfortran-10
9+
10+
# Set the alternative Fortran compiler as the default
11+
RUN update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-10 10
12+
13+
# Fix broken dependencies and reconfigure ca-certificates
14+
RUN apt-get -y update && apt-get install -f && dpkg --configure -a && apt-get clean
615

716
COPY . /vcellroot
817

@@ -13,10 +22,13 @@ RUN cmake \
1322
-G Ninja \
1423
-DOPTION_TARGET_PYTHON_BINDING=OFF \
1524
-DOPTION_TARGET_MESSAGING=ON \
16-
-DOPTION_TARGET_SMOLDYN_SOLVER=OFF \
25+
-DOPTION_TARGET_SMOLDYN_SOLVER=ON \
1726
-DOPTION_TARGET_FV_SOLVER=ON \
1827
-DOPTION_TARGET_DOCS=OFF \
1928
.. && \
2029
ninja
2130

22-
#RUN ctest
31+
RUN ctest -VV
32+
33+
WORKDIR /vcellroot/build/bin
34+
ENV PATH="/vcellroot/build/bin:${PATH}"

VCell/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,18 @@ endif()
243243

244244
# add google tests
245245
if (OPTION_TARGET_TESTS)
246+
enable_testing()
247+
if (MINGW)
248+
set(test_fvsolver_exe ${CMAKE_BINARY_DIR}/bin/${EXE_FILE}.exe)
249+
set(python_cmd py)
250+
else (MINGW)
251+
set(test_fvsolver_exe ${CMAKE_BINARY_DIR}/bin/${EXE_FILE})
252+
set(python_cmd python3)
253+
endif (MINGW)
254+
set(test_dir ${CMAKE_CURRENT_SOURCE_DIR}/tests/smoke)
255+
256+
# smoke test as a python script, for bash test example, see NFsim/tests/smoke
257+
add_test(NAME ${EXE_FILE}_smoke COMMAND ${python_cmd} ${test_dir}/smoke.py ${test_fvsolver_exe} WORKING_DIRECTORY ${test_dir})
258+
246259
add_subdirectory(tests)
247260
endif()

VCell/src/PostProcessingHdf5Writer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void PostProcessingHdf5Writer::writeOutput(SimTool* sim_tool) {
208208

209209
h5PPFile->flush(H5F_SCOPE_GLOBAL);
210210
} catch(H5::Exception error ) {
211-
throw error.getDetailMsg();
211+
throw std::runtime_error(error.getDetailMsg());
212212
}
213213
}
214214

0 commit comments

Comments
 (0)