Skip to content

Commit

Permalink
Merge pull request #31 from Chaste/issue30_always_fetchcontent
Browse files Browse the repository at this point in the history
  • Loading branch information
mirams authored Jul 6, 2023
2 parents 02a18db + e2d03e3 commit 2e5f956
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 35 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ubuntu-2004.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ jobs:
- name: cmake configure
run: nice -n 10 cmake -DCMAKE_BUILD_TYPE=Release ..
working-directory: Chaste/build

- name: remove cellml
run: rm -rf ApPredict/src/cellml
working-directory: Chaste/projects

- name: cmake configure again
run: nice -n 10 cmake -DCMAKE_BUILD_TYPE=Release ..
working-directory: Chaste/build

- name: build core libraries
run: nice -n 10 cmake --build . --parallel ${NPROC} --target chaste_core
Expand Down
63 changes: 34 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,41 @@
#
# Note that the order in which components are specified does not matter.

include(FetchContent)
message (STATUS "Downloading ApPredict cellml files to ${CMAKE_CURRENT_SOURCE_DIR}/src/cellml")
Set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
FetchContent_Declare(CellML_repo_appredict
GIT_REPOSITORY https://github.com/Chaste/cellml.git
GIT_TAG e394aba8a7ca50f72ee212e21431045eae8b5ca4
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/cellml)
FetchContent_MakeAvailable(CellML_repo_appredict)
set(ApPredict_CELLML_TAG e394aba8a7ca50f72ee212e21431045eae8b5ca4)
set(ApPredict_CELLML_URL "https://raw.githubusercontent.com/Chaste/cellml/${ApPredict_CELLML_TAG}/cellml")
set(ApPredict_CELLML_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/cellml")
set(ApPredict_CELLML_FILES
davies_isap_2012.cellml
decker_2009.cellml
faber_rudy_2000.cellml
grandi_pasqualini_bers_2010_ss.cellml
hund_rudy_2004.cellml
livshitz_rudy_2007.cellml
mahajan_shiferaw_2008.cellml
ohara_rudy_2011_endo.cellml
ohara_rudy_cipa_v1_2017.cellml
paci_hyttinen_aaltosetala_severi_ventricularVersion.cellml
priebe_beuckelmann_1998.cellml
shannon_wang_puglisi_weber_bers_2004.cellml
ten_tusscher_model_2006_epi.cellml
)

# remove .git folder to prevent accidentally checking in deletion of cellml files
file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/src/cellml/.git)

# remove cellml files that are not required
file(GLOB cellml_files ${CMAKE_CURRENT_SOURCE_DIR}/src/cellml/cellml/*.cellml)
foreach(cellml_file ${cellml_files})
if (NOT ${cellml_file} MATCHES davies_isap_2012.cellml
AND NOT ${cellml_file} MATCHES decker_2009.cellml
AND NOT ${cellml_file} MATCHES faber_rudy_2000.cellml
AND NOT ${cellml_file} MATCHES grandi_pasqualini_bers_2010_ss.cellml
AND NOT ${cellml_file} MATCHES hund_rudy_2004.cellml
AND NOT ${cellml_file} MATCHES livshitz_rudy_2007.cellml
AND NOT ${cellml_file} MATCHES mahajan_shiferaw_2008.cellml
AND NOT ${cellml_file} MATCHES ohara_rudy_2011_endo.cellml
AND NOT ${cellml_file} MATCHES ohara_rudy_cipa_v1_2017.cellml
AND NOT ${cellml_file} MATCHES paci_hyttinen_aaltosetala_severi_ventricularVersion.cellml
AND NOT ${cellml_file} MATCHES priebe_beuckelmann_1998.cellml
AND NOT ${cellml_file} MATCHES shannon_wang_puglisi_weber_bers_2004.cellml
AND NOT ${cellml_file} MATCHES ten_tusscher_model_2006_epi.cellml)
file(REMOVE ${cellml_file})
endif()
message (STATUS "Downloading ApPredict cellml files to ${ApPredict_CELLML_SRC}")
foreach(cellml_file ${ApPredict_CELLML_FILES})
if (NOT EXISTS "${ApPredict_CELLML_SRC}/${cellml_file}")
file(DOWNLOAD
"${ApPredict_CELLML_URL}/${cellml_file}"
"${ApPredict_CELLML_SRC}/${cellml_file}"
TIMEOUT 10
TLS_VERIFY ON
STATUS dl_status
)
list (GET dl_status 0 dl_status_code)
if (NOT dl_status_code EQUAL 0)
file(REMOVE "${ApPredict_CELLML_SRC}/${cellml_file}") # remove stub
message (WARNING "Could not download ${cellml_file}")
endif ()
endif ()
endforeach()

# Here we just depend on core components (nothing application-specific).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ so that all the file paths can be picked up correctly (replacing ```<chaste sour

This ApPredict project should be used with the current `develop` branch of [Chaste](https://github.com/Chaste/Chaste). If instead you want a version that works with a released version of Chaste, then please select the relevant Tag of this github repository.

(In the past we had a git submodule with CellML files from www.github.com/Chaste/CellML, but this is now pulled in by a cmake [fetch](https://cmake.org/cmake/help/latest/module/FetchContent.html))
(In the past we had a git submodule with CellML files from www.github.com/Chaste/CellML, but this is now pulled in by a cmake [file download](https://cmake.org/cmake/help/latest/command/file.html#download))

[Getting Started]: <https://chaste.cs.ox.ac.uk/trac/wiki/GettingStarted>
2 changes: 1 addition & 1 deletion src/extra_models/README
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Users can put additional cellml models in this directory.
Once the project is built these will be available as pre-compiled models
and can be used with --model <name of cellml file (without.cellml)>.

Please note: The additional cellml file cannot have the same name as one of the pre-included cellml files in src/cellml/cellml
Please note: The additional cellml file cannot have the same name as one of the pre-included cellml files in src/cellml
as these would generate model code with conflicting names.
In case you receive a compile error with regards to duplicate definitions,
we suggest renaming the additional cellml files to avoid conflicts.
2 changes: 1 addition & 1 deletion test/TestApPredict.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class TestApPredict : public CxxTest::TestSuite
"No model matches this index: 99999");
}
{
CommandLineArgumentsMocker wrapper("--cellml projects/ApPredict/src/cellml/cellml/ten_tusscher_model_2006_epi.cellml --plasma-concs 1 10 --pic50-herg 4.5 --plasma-conc-logscale false --output-dir ApPredict_output_long");
CommandLineArgumentsMocker wrapper("--cellml projects/ApPredict/src/cellml/ten_tusscher_model_2006_epi.cellml --plasma-concs 1 10 --pic50-herg 4.5 --plasma-conc-logscale false --output-dir ApPredict_output_long");

ApPredictMethods methods;
TS_ASSERT_EQUALS(Warnings::Instance()->GetNextWarningMessage(), "Argument --cellml <file> is deprecated: use --model <file> instead.");
Expand Down
6 changes: 3 additions & 3 deletions test/TestApPredictLong.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ class TestApPredictLong : public CxxTest::TestSuite
// loop over hardcoded and dynamically loaded.
// try both --model --cellml and --cellml and try both relative and absolute paths

FileFinder cellm_file("projects/ApPredict/src/cellml/cellml/ten_tusscher_model_2006_epi.cellml", RelativeTo::CWD);
FileFinder cellm_file("projects/ApPredict/src/cellml/ten_tusscher_model_2006_epi.cellml", RelativeTo::CWD);
std::vector<std::string> model_args = { "--model 2",
"--model ten_tusscher_model_2006_epi",
"--model projects/ApPredict/src/cellml/cellml/ten_tusscher_model_2006_epi.cellml",
"--model projects/ApPredict/src/cellml/ten_tusscher_model_2006_epi.cellml",
"--model " + cellm_file.GetAbsolutePath(),
"--cellml projects/ApPredict/src/cellml/cellml/ten_tusscher_model_2006_epi.cellml"};
"--cellml projects/ApPredict/src/cellml/ten_tusscher_model_2006_epi.cellml"};
for (unsigned i = 0; i < model_args.size(); i++)
{
CommandLineArgumentsMocker wrapper(model_args[i] + " --plasma-concs 1 10 --pic50-herg 4.5 --plasma-conc-logscale false --output-dir ApPredict_output_long");
Expand Down

0 comments on commit 2e5f956

Please sign in to comment.