Skip to content

Commit

Permalink
[T,CMake] Fix generateInvalidMediaForHT.py call order.
Browse files Browse the repository at this point in the history
The script requries ogs6py which is installed at the end of the cmake
configure run. Moved the call after the venv creation.
  • Loading branch information
bilke authored and endJunction committed May 21, 2024
1 parent e978e72 commit 8b98bf4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 28 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ include(UnityBuildSettings)

if(OGS_USE_PIP)
setup_venv()
setup_venv_dependent_ctests()
endif()

message(STATUS "${_benchmark_run_commands}")
Expand Down
18 changes: 1 addition & 17 deletions ProcessLib/HT/Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -357,23 +357,7 @@ AddTest(
ThermalConvection_ts_1_t_0.000000_expected.vtu ThermalConvection_ts_1_t_0.000000.vtu darcy_velocity darcy_velocity 1e-8 1e-13
)

if(NOT OGS_USE_MPI AND OGS_BUILD_TESTING AND OGS_USE_PIP)
execute_process(COMMAND ${Python_EXECUTABLE}
${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles/generateInvalidMediaForHT.py
WORKING_DIRECTORY ${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles)
file(GLOB HT_INVALID_PRJ_FILES ${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles/*.prj)
foreach(ht_invalid_prj_file ${HT_INVALID_PRJ_FILES})
string(REPLACE ${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles/HT "invalid" ht_invalid_prj_file_short ${ht_invalid_prj_file})
AddTest(
NAME HT_${ht_invalid_prj_file_short}
PATH Parabolic/HT/InvalidProjectFiles
EXECUTABLE ogs
EXECUTABLE_ARGS ${ht_invalid_prj_file}
RUNTIME 1
)
set_tests_properties(ogs-HT_${ht_invalid_prj_file_short} PROPERTIES WILL_FAIL TRUE)
endforeach()
endif()
# generateInvalidMediaForHT.py logic moved to PythonSetup.cmake

if (NOT (OGS_USE_MPI))
OgsTest(PROJECTFILE Parabolic/HT/SimpleSynthetics/deactivated_subdomain/HT_DeactivatedSubdomain.prj)
Expand Down
56 changes: 45 additions & 11 deletions scripts/cmake/PythonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ if(OGS_USE_PIP)
execute_process(
COMMAND
${CMAKE_COMMAND} -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
-Dpython_version=${ogs.minimum_version.python}
-P
-Dpython_version=${ogs.minimum_version.python} -P
${PROJECT_SOURCE_DIR}/scripts/cmake/PythonCreateVirtualEnv.cmake
WORKING_DIRECTORY ${PROJECT_BINARY_DIR} COMMAND_ECHO STDOUT
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
Expand Down Expand Up @@ -65,8 +64,8 @@ if(NOT OGS_BUILD_WHEEL)
endif()

find_package(
Python ${ogs.minimum_version.python}
COMPONENTS ${_python_componets} REQUIRED
Python ${ogs.minimum_version.python} COMPONENTS ${_python_componets}
REQUIRED
)

if(OGS_USE_PIP)
Expand All @@ -93,10 +92,12 @@ if(OGS_USE_PIP)
file(STRINGS Tests/Data/requirements-dev.txt _requirements_dev)
list(APPEND OGS_PYTHON_PACKAGES ${_requirements} ${_requirements_dev})

list(APPEND OGS_PYTHON_PACKAGES
"snakemake==${ogs.minimum_version.snakemake}"
"pulp==2.7.0" # https://github.com/snakemake/snakemake/issues/2607
"setuptools" # https://github.com/glenfant/stopit/issues/32
list(
APPEND
OGS_PYTHON_PACKAGES
"snakemake==${ogs.minimum_version.snakemake}"
"pulp==2.7.0" # https://github.com/snakemake/snakemake/issues/2607
"setuptools" # https://github.com/glenfant/stopit/issues/32
)
set(SNAKEMAKE ${LOCAL_VIRTUALENV_BIN_DIR}/snakemake CACHE FILEPATH ""
FORCE
Expand Down Expand Up @@ -147,9 +148,10 @@ function(setup_venv)
)
if(DEFINED ENV{CI} AND UNIX AND NOT APPLE)
execute_process(
COMMAND ${_apple_env} ${LOCAL_VIRTUALENV_BIN_DIR}/pip install
--force-reinstall
-r ${PROJECT_SOURCE_DIR}/Tests/Data/requirements-gmsh-nox.txt
COMMAND
${_apple_env} ${LOCAL_VIRTUALENV_BIN_DIR}/pip install
--force-reinstall -r
${PROJECT_SOURCE_DIR}/Tests/Data/requirements-gmsh-nox.txt
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
RESULT_VARIABLE _return_code
OUTPUT_VARIABLE _out
Expand All @@ -170,3 +172,35 @@ function(setup_venv)
endif()
endif()
endfunction()

function(setup_venv_dependent_ctests)
if(NOT OGS_USE_MPI AND OGS_BUILD_TESTING AND OGS_BUILD_PROCESS_HT)
execute_process(
COMMAND
${Python_EXECUTABLE}
${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles/generateInvalidMediaForHT.py
WORKING_DIRECTORY
${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles
)
file(GLOB HT_INVALID_PRJ_FILES
${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles/*.prj
)
foreach(ht_invalid_prj_file ${HT_INVALID_PRJ_FILES})
string(
REPLACE ${Data_SOURCE_DIR}/Parabolic/HT/InvalidProjectFiles/HT
"invalid" ht_invalid_prj_file_short
${ht_invalid_prj_file}
)
AddTest(
NAME HT_${ht_invalid_prj_file_short}
PATH Parabolic/HT/InvalidProjectFiles
EXECUTABLE ogs
EXECUTABLE_ARGS ${ht_invalid_prj_file}
RUNTIME 1
)
set_tests_properties(
ogs-HT_${ht_invalid_prj_file_short} PROPERTIES WILL_FAIL TRUE
)
endforeach()
endif()
endfunction()

0 comments on commit 8b98bf4

Please sign in to comment.