Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smoke test for FiniteVolume and Smoldyn #6

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 13 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true

- name: Log in to the Container registry
uses: docker/login-action@v3
Expand Down Expand Up @@ -60,19 +62,23 @@ jobs:
steps:
- name: checkout vcell-solvers repo
uses: actions/checkout@v4
with:
submodules: true

- name: Install Intel MacOS dependencies
if: matrix.platform == 'macos-13'
shell: bash
run: |
brew install boost
brew install hdf5
brew install libzip
brew install ninja

brew install llvm
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile
source /Users/runner/.bash_profile

ln -s $(which gfortran-14) /usr/local/bin/gfortran

gcc --version
gfortran --version
cmake --version
Expand All @@ -85,6 +91,7 @@ jobs:
run: |
brew install boost
brew install hdf5
brew install libzip
brew install ninja

brew install llvm
Expand Down Expand Up @@ -209,7 +216,7 @@ jobs:
mkdir build
cd build

PATH="/c/Program\ Files/LLVM/bin:$PATH"
export PATH="/c/Program\ Files/LLVM/bin:$PATH"

cmake \
-G Ninja \
Expand All @@ -232,6 +239,9 @@ jobs:
echo "working dir is $PWD"

cd build

export PATH="/d/a/_temp/msys64/clang64/bin:$PATH"
pacman -Sy --noconfirm diffutils

ctest -VV

Expand All @@ -245,6 +255,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y libhdf5-dev
sudo apt-get install -y libzip-dev
sudo apt-get install -y ninja-build

gcc --version
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true


- name: Get conda
uses: conda-incubator/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install Intel MacOS dependencies
if: matrix.platform == 'macos-13'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y libboost-all-dev
sudo apt-get install -y libhdf5-dev
sudo apt-get install -y libzip-dev
sudo apt-get install -y ninja-build

gcc --version
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@
tests/__pycache__/

*.whl

VCell/tests/testFiles/output/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = extern/pybind11
url = ../../pybind/pybind11
branch = stable
[submodule "libzippp"]
path = libzippp
url = https://github.com/ctabin/libzippp.git
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ elseif (MINGW)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/libzippp/cmake/")

include(GetGitRevisionDescription)
git_describe(GIT_DESCRIBE ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)

include (FindZLIB)
include (FindLIBZIP)


if (NOT OPTION_TARGET_PYTHON_BINDING)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Expand Down Expand Up @@ -189,11 +192,16 @@ find_package(HDF5 COMPONENTS HL CXX C)
set(HDF_VERSION ${HDF5_VERSION})
###### ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES}

if (OPTION_TARGET_TESTS)
enable_testing()
set(LIBZIPPP_BUILD_TESTS ON)
endif ()

add_subdirectory(VCellMessaging)

add_subdirectory(VCellZipUtils)

add_subdirectory(libzip-1.2.0)
add_subdirectory(libzippp)

add_subdirectory(ExpressionParser)

Expand Down
22 changes: 17 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
FROM ubuntu:22.04 as build
FROM ubuntu:22.04

RUN apt-get -y update && apt-get install -y apt-utils && \
apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran zlib1g-dev \
libhdf5-dev ninja-build libcurl4-openssl-dev libboost-all-dev cmake wget python3
apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran \
libhdf5-dev libzip-dev ninja-build libcurl4-openssl-dev libboost-all-dev libbz2-dev cmake python3

# Install an alternative Fortran compiler
RUN apt-get install -y gfortran-10

# Set the alternative Fortran compiler as the default
RUN update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-10 10

# Fix broken dependencies and reconfigure ca-certificates
RUN apt-get -y update && apt-get install -f && dpkg --configure -a && apt-get clean

COPY . /vcellroot

Expand All @@ -13,10 +22,13 @@ RUN cmake \
-G Ninja \
-DOPTION_TARGET_PYTHON_BINDING=OFF \
-DOPTION_TARGET_MESSAGING=ON \
-DOPTION_TARGET_SMOLDYN_SOLVER=OFF \
-DOPTION_TARGET_SMOLDYN_SOLVER=ON \
-DOPTION_TARGET_FV_SOLVER=ON \
-DOPTION_TARGET_DOCS=OFF \
.. && \
ninja

#RUN ctest
RUN ctest -VV

WORKDIR /vcellroot/build/bin
ENV PATH="/vcellroot/build/bin:${PATH}"
13 changes: 13 additions & 0 deletions VCell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,18 @@ endif()

# add google tests
if (OPTION_TARGET_TESTS)
enable_testing()
if (MINGW)
set(test_fvsolver_exe ${CMAKE_BINARY_DIR}/bin/${EXE_FILE}.exe)
set(python_cmd py)
else (MINGW)
set(test_fvsolver_exe ${CMAKE_BINARY_DIR}/bin/${EXE_FILE})
set(python_cmd python3)
endif (MINGW)
set(test_dir ${CMAKE_CURRENT_SOURCE_DIR}/tests/smoke)

# smoke test as a python script, for bash test example, see NFsim/tests/smoke
add_test(NAME ${EXE_FILE}_smoke COMMAND ${python_cmd} ${test_dir}/smoke.py ${test_fvsolver_exe} WORKING_DIRECTORY ${test_dir})

add_subdirectory(tests)
endif()
2 changes: 1 addition & 1 deletion VCell/src/PostProcessingHdf5Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void PostProcessingHdf5Writer::writeOutput(SimTool* sim_tool) {

h5PPFile->flush(H5F_SCOPE_GLOBAL);
} catch(H5::Exception error ) {
throw error.getDetailMsg();
throw std::runtime_error(error.getDetailMsg());
}
}

Expand Down
43 changes: 29 additions & 14 deletions VCell/src/SimTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,40 @@ static FILE* openFileWithRetry(const char* fileName, const char* mode) {
return fp;
}

static bool zipUnzipWithRetry(bool bZip, const filesystem::path& zipFileName, const filesystem::path& simFileName, std::string* errmsg) {
static bool unzipWithRetry(const filesystem::path& zipFileName, const filesystem::path& simFileName, std::string* errmsg) {
bool bSuccess = false;
for (int attemptNum = 0; attemptNum <= numRetries; attemptNum++) {
try {
if (bZip) {
// retcode = zip32(1, zipFileName, simFileName);
addFilesToZip(zipFileName, simFileName);
} else {
// retcode = unzip32(zipFileName, simFileName, NULL);
extractFileFromZip(zipFileName, simFileName);
}
extractFileFromZip(zipFileName, simFileName);
bSuccess = true;
break;
} catch (const char* ziperr) {
} catch (runtime_error &e) {
errmsg->clear();
errmsg->append(ziperr);
} catch (...) {
errmsg->append(e.what());
}
if (attemptNum == numRetries) continue;
retryWait(retryWaitSeconds);
cout << "SimTool::updateLog(), adding .sim to .zip failed (attempt "
<< (attemptNum + 1) << "), trying again" << endl;

}
if (!bSuccess) {
errmsg->clear();
errmsg->append("Writing zip file <").append(zipFileName.string()).append("> failed.");
}
return bSuccess;
}

static bool zipWithRetry(const filesystem::path& zipFileName, const filesystem::path& simFileName, std::string* errmsg) {
bool bSuccess = false;
for (int attemptNum = 0; attemptNum <= numRetries; attemptNum++) {
try {
addFilesToZip(zipFileName, simFileName);
bSuccess = true;
break;
} catch (runtime_error& e) {
errmsg->clear();
errmsg->append("SimTool::updateLog(), adding .sim to .zip failed.");
errmsg->append(e.what());
}
if (attemptNum == numRetries) continue;
retryWait(retryWaitSeconds);
Expand Down Expand Up @@ -358,7 +373,7 @@ void SimTool::loadFinal()
// unzip the file (without directory) into exdir, currently we
// unzip the file to the current working directory
std::string errmsg;
zipUnzipWithRetry(false, zipFileAbsoluteName.string().c_str(), dataFileName.string().c_str(), &errmsg);
unzipWithRetry(zipFileAbsoluteName.string().c_str(), dataFileName.string().c_str(), &errmsg);
}
}

Expand Down Expand Up @@ -553,7 +568,7 @@ void SimTool::updateLog(double progress, double time, int iteration)
addFilesToZip(zipFileName.c_str(), simFileName.c_str(), particleFileName.c_str());
remove(particleFileName.c_str());
} else {
bSuccess = zipUnzipWithRetry(true, zipFileName.c_str(), simFileName.c_str(), &errorMsg);
bSuccess = zipWithRetry(zipFileName.c_str(), simFileName.c_str(), &errorMsg);
}
remove(simFileName.c_str());

Expand Down
7 changes: 5 additions & 2 deletions VCell/src/SolverMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ std::string version()
int solve(const std::string& inputFilename, const std::string& vcgFilename, const std::string& outputDir) {
// Check if output directory exists, if not create it
std::filesystem::path dirPath(outputDir);
if (!exists(dirPath)) {
create_directories(dirPath);
// converty dirPath to an absolute path and check to see if dirPath exists
dirPath = std::filesystem::absolute(dirPath);
if (!std::filesystem::exists(dirPath)) {
// create the directory
std::filesystem::create_directories(dirPath);
}

// Open the input file
Expand Down
4 changes: 3 additions & 1 deletion VCell/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ target_link_libraries(vcell_test vcell GTest::gtest_main)
# RUNTIME DESTINATION bin)

include(GoogleTest)
gtest_discover_tests(vcell_test)
gtest_discover_tests(vcell_test)
# copy tests files to build directory
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testFiles DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
14 changes: 8 additions & 6 deletions VCell/tests/TestVCell.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#include <gtest/gtest.h>
#include <filesystem>


#include <VCELL/SolverMain.h>

TEST(VCellTest, BasicAssertions) {
std::string inputDir = "../../testFiles/input/";
std::string outputDir = "../../testFiles/output/";
std::filesystem::path inputDir = "testFiles/input/";
std::filesystem::path outputDir = "testFiles/output/";

std::string fvInputFile = inputDir + "SimID_11538992_0_.fvinput";
std::string vcgInputFile = inputDir + "SimID_11538992_0_.vcg";
std::string testOutputDir_1 = outputDir + "test_output_1";
std::string testOutputDir_2 = outputDir + "test_output_2";
std::filesystem::path fvInputFile = inputDir / "SimID_11538992_0_.fvinput";
std::filesystem::path vcgInputFile = inputDir / "SimID_11538992_0_.vcg";
std::string testOutputDir_1 = outputDir / "test_output_1";
std::string testOutputDir_2 = outputDir / "test_output_2";

auto retcode_1 = solve(fvInputFile, vcgInputFile, testOutputDir_1);
EXPECT_EQ(retcode_1, 0);
Expand Down
19 changes: 19 additions & 0 deletions VCell/tests/smoke/SimID_1585623750_0_.functions
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
##---------------------------------------------
## /Users/jimschaff/.vcell/simdata/temp/SimID_1585623750_0_.functions
##---------------------------------------------

subdomain1::J_flux0; (2.0 * (RanC_cyt - RanC_nuc)); ; Volume_VariableType; false
subdomain1::J_r0; ((2.0 * RanC_cyt) - (1000.0 * Ran_cyt * C_cyt)); ; Volume_VariableType; false
subdomain1::KFlux_nm_cyt; 1.0; ; Volume_Region_VariableType; false
subdomain1::KFlux_nm_nuc; 1.0; ; Volume_Region_VariableType; false
subdomain1::RanC_cyt_init_uM; (1.0 + x); ; Volume_VariableType; false
subdomain0_subdomain1_membrane::s2; 0.0; ; Membrane_Region_VariableType; false
subdomain1::Size_cyt; vcRegionVolume('subdomain1'); ; Volume_Region_VariableType; false
subdomain0::Size_EC; vcRegionVolume('subdomain0'); ; Volume_Region_VariableType; false
subdomain1::Size_nm; vcRegionVolume('subdomain1'); ; Volume_Region_VariableType; false
subdomain1::Size_nuc; vcRegionVolume('subdomain1'); ; Volume_Region_VariableType; false
subdomain0_subdomain1_membrane::Size_pm; vcRegionArea('subdomain0_subdomain1_membrane'); ; Membrane_Region_VariableType; false
subdomain0_subdomain1_membrane::sobj_subdomain11_subdomain00_size; vcRegionArea('subdomain0_subdomain1_membrane'); ; Membrane_Region_VariableType; false
subdomain0::vobj_subdomain00_size; vcRegionVolume('subdomain0'); ; Volume_Region_VariableType; false
subdomain1::vobj_subdomain11_size; vcRegionVolume('subdomain1'); ; Volume_Region_VariableType; false

Loading
Loading