Skip to content

Commit

Permalink
If a python virtual enviornment was defined and used during the build
Browse files Browse the repository at this point in the history
time, the Lua module file will now activate it when loaded. Removed
the TCL module file since it wasn't being used by systems.

Added a prompt name to the python venv.

Fixed an empty variable field in the Lassen gitlab code that deleted
other variables.
  • Loading branch information
bvanessen committed Aug 27, 2024
1 parent 6a62aa5 commit c47b429
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 114 deletions.
1 change: 0 additions & 1 deletion .gitlab/build-and-test-lassen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ clang-16-0-6-gcc-11-2-1-cuda-12-2-2-distconv-lassen:
.build-and-test-on-lassen:
stage: build
tags: [lassen, batch]
variables:
extends: .build-and-test
2 changes: 1 addition & 1 deletion .gitlab/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

export LBANN_PYTHON_VENV_DIR="${INSTALL_EXTERNALS_ROOT}/${SYSTEM_INSTALL_PREFIX_EXTERNALS}/venv"
if [[ ! -e "${LBANN_PYTHON_VENV_DIR}/pyvenv.cfg" ]]; then
CMD="python3 -m venv ${LBANN_PYTHON_VENV_DIR}"
CMD="python3 -m venv --prompt lbann-venv ${LBANN_PYTHON_VENV_DIR}"
echo "${CMD}"
${CMD}
fi
Expand Down
33 changes: 14 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1207,31 +1207,26 @@ if (DEFINED ENV{LBANN_PYTHON_VENV_DIR})
else ()
set(LBANN_PYTHON_VENV_DIR "" CACHE STRING "")
endif()
message("BVE I have found a variable >${LBANN_PYTHON_VENV_DIR}<")

configure_file(
"${CMAKE_SOURCE_DIR}/cmake/configure_files/lbann_module.lua.in"
"${CMAKE_BINARY_DIR}/lbann_module.lua.install"
@ONLY)
configure_file(
"${CMAKE_SOURCE_DIR}/cmake/configure_files/lbann_module.tcl.in"
"${CMAKE_BINARY_DIR}/lbann_module.tcl.install")

install(FILES "${CMAKE_BINARY_DIR}/lbann_module.lua.install"
RENAME "${LBANN_MODULEFILE_NAME}"
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/modulefiles/lbann")
install(FILES "${CMAKE_BINARY_DIR}/lbann_module.tcl.install"
RENAME "${LBANN_VERSION}"
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/modulefiles/lbann")
message("BVE ready to install with VENV variable >${LBANN_PYTHON_VENV_DIR}<")
message("BVE ready to install with VENV variable >$ENV{LBANN_PYTHON_VENV_DIR}<")
install(CODE [===[
message("\n********************************************************************************")
message("LBANN is installed into ${CMAKE_INSTALL_PREFIX} - to load the LBANN module:")
message(" module use ${CMAKE_INSTALL_PREFIX}/etc/modulefiles")
message(" module load lbann")
message(" source ${LBANN_PYTHON_VENV_DIR}/bin/activate")
message(" source $ENV{LBANN_PYTHON_VENV_DIR}/bin/activate")
message(" source \${LBANN_PYTHON_VENV_DIR}/bin/activate")
message("********************************************************************************")
]===])

if (DEFINED ENV{LBANN_PYTHON_VENV_DIR})
set(_PYTHON_VENV_INSTALL_MSG
"\nA Python virtual environment was used to build and install LBANN.
Loading the module will activate the environment in: ${LBANN_PYTHON_VENV_DIR}")
endif ()

install(CODE "
message(\"\n********************************************************************************\")
message(\"LBANN is installed into ${CMAKE_INSTALL_PREFIX} - to load the LBANN module:\")
message(\" module use ${CMAKE_INSTALL_PREFIX}/etc/modulefiles\")
message(\" module load lbann ${_PYTHON_VENV_INSTALL_MSG}\")
message(\"********************************************************************************\")
")
10 changes: 7 additions & 3 deletions cmake/configure_files/lbann_module.lua.in
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ prepend_path("LD_LIBRARY_PATH","@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@")
prepend_path("PYTHONPATH","@PYTHON_INSTALL_PREFIX@/@CMAKE_INSTALL_PYTHONDIR@")
prepend_path("LBANN_PYTHON_SITE_PACKAGES","@PYTHON_INSTALL_PREFIX@/@CMAKE_INSTALL_PYTHONDIR@")

pushenv("LBANN_PYTHON_VENV_DIR","@LBANN_PYTHON_VENV_DIR@")
pushenv("LBANN_PYTHON_VENV_SITE_PACKAGES","@LBANN_PYTHON_VENV_DIR@/@CMAKE_INSTALL_PYTHONDIR@")
prepend_path("PYTHONPATH","@LBANN_PYTHON_VENV_DIR@/@CMAKE_INSTALL_PYTHONDIR@")
if ("@LBANN_PYTHON_VENV_DIR@" ~= "") then
pushenv("LBANN_PYTHON_VENV_DIR","@LBANN_PYTHON_VENV_DIR@")
pushenv("LBANN_PYTHON_VENV_SITE_PACKAGES","@LBANN_PYTHON_VENV_DIR@/@CMAKE_INSTALL_PYTHONDIR@")
prepend_path("PYTHONPATH","@LBANN_PYTHON_VENV_DIR@/@CMAKE_INSTALL_PYTHONDIR@")
execute {cmd="source @LBANN_PYTHON_VENV_DIR@/bin/activate", modeA={"load"}}
execute {cmd="deactivate", modeA={"unload"}}
end

pushenv("LBANN_DIR","@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DIR@")

Expand Down
90 changes: 0 additions & 90 deletions cmake/configure_files/lbann_module.tcl.in

This file was deleted.

0 comments on commit c47b429

Please sign in to comment.