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

Add scripts to compile, and recompile and fire a config (intro of ldmx compile and ldmx recompFire) #1282

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
- **Note**: You need to [setup an SSH-key with your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh) on the computer you are using.
- Setup the environment (in bash): `source ldmx-sw/scripts/ldmx-env.sh`
- **Note**: If you are working with ldmx-sw at SLAC's SDF, you will need to set the `TMPDIR` environment variable so that program running the container has more than ~5GB of space to write intermediate files. The default temporary space (`/tmp`) is often full of other files already. A decent replacement is `TMPDIR=${SCRATCH}` which gives the program plenty of room for the files it needs to manipulate.
- Make a build directory: `cd ldmx-sw; mkdir build; cd build;`
- Configure the build: `ldmx cmake ..`
- Build and Install: `ldmx make install -j2`
- Configure and compile: `ldmx compile`
- Now you can run any processor in _ldmx-sw_ through `ldmx fire myconfig.py`
- If you are developing and need to recompile and run `ldmx fire`, you can use `ldmx recompFire myconfig.py`

## Documentation
The full documentation for **ldmx-sw** is available on [github pages](https://ldmx-software.github.io/).
Expand All @@ -40,7 +39,9 @@ Command | Purpose
`ldmx cmake ..` | Configure the ldmx-sw build
`ldmx make` | Compile/build ldmx-sw
`ldmx make install` | Install ldmx-sw
`ldmx compile` | Configure and compile ldmx-sw
`ldmx fire config.py` | Use ldmx-sw application and processors with input python configuration
`ldmx recompFire config.py` | Recompile and run fire on a config file
`ldmx python3 analysis.py` | Run python-based analysis
`ldmx ./bin/mg5_aMC` | Run MadGraph5 inside (ubuntu-based) container

Expand Down
23 changes: 23 additions & 0 deletions scripts/ldmx-compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

############################# Usage #############################
# ldmx ./scripts/ldmx-compile.sh
# for changing the defaults
# ldmx setenv LDMX_COMPILE_CORES=<num cores to be used>, i.e.
# ldmx setenv LDMX_COMPILE_CORES=16
# or
# ldmx setenv LDMX_COMPILE_BUILD=<build location>

if [ -z "$LDMX_COMPILE_CORES" ]; then
LDMX_COMPILE_CORES=$(nproc)
tomeichlersmith marked this conversation as resolved.
Show resolved Hide resolved
fi

if [ -z "$LDMX_COMPILE_BUILD" ]; then
LDMX_COMPILE_BUILD=${LDMX_BASE}/ldmx-sw/
fi

echo "-- Compiling ldmx-sw in ${LDMX_COMPILE_BUILD} with ${LDMX_COMPILE_CORES} cores"

# Compile ldmx-sw
cmake -B ${LDMX_COMPILE_BUILD}/build -S ${LDMX_COMPILE_BUILD}
tvami marked this conversation as resolved.
Show resolved Hide resolved
cmake --build ${LDMX_COMPILE_BUILD}/build --target install -j=${LDMX_COMPILE_CORES}
33 changes: 28 additions & 5 deletions scripts/ldmx-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ __ldmx_clean() {
return ${rc}
}



###############################################################################
# __ldmx_source
# Run all the sub-commands in the provided file from the directory it is in.
Expand Down Expand Up @@ -537,6 +539,24 @@ __ldmx_checkout() {
return 0
}

###############################################################################
# __ldmx_compile
# Compile ldmx-sw
###############################################################################

__ldmx_compile() {
ldmx . ${LDMX_BASE}/ldmx-sw/scripts/ldmx-compile.sh
}

###############################################################################
# __ldmx_recompFire
# Recompile ldmx-sw and run fire on the first argument
###############################################################################

__ldmx_recompFire() {
ldmx . ${LDMX_BASE}/ldmx-sw/scripts/ldmx-recompileAndFire.sh $1
tvami marked this conversation as resolved.
Show resolved Hide resolved
}

###############################################################################
# __ldmx_help
# Print some helpful message to the terminal
Expand All @@ -550,6 +570,8 @@ __ldmx_help() {
COMMANDS:
help : print this help message and exit
ldmx help
compile : Compile ldmx-sw
ldmx compile
list : List the tag options for the input container repository
ldmx list (dev | pro | local)
clean : Reset ldmx computing environment
Expand Down Expand Up @@ -579,6 +601,7 @@ __ldmx_help() {
ldmx cmake ..
ldmx make install
ldmx fire config.py
ldmx recompFire config.py
ldmx python3 ana.py

HELP
Expand All @@ -599,7 +622,7 @@ ldmx() {
[[ "$#" == "0" ]] && { __ldmx_help; return $?; }
# divide commands by number of arguments
case $1 in
help|config)
help|config|compile)
if [[ "$#" != "1" ]]; then
__ldmx_${1}
echo "ERROR: 'ldmx ${1}' takes no arguments."
Expand Down Expand Up @@ -635,7 +658,7 @@ ldmx() {
__ldmx_use "$2" "$3"
return $?
;;
run|checkout)
run|checkout|recompFire)
__ldmx_${1} ${@:2}
return $?
;;
Expand Down Expand Up @@ -775,12 +798,12 @@ __ldmx_complete() {

if [[ "$COMP_CWORD" = "1" ]]; then
# tab completing a main argument
__ldmx_complete_command "list clean config checkout pull use run mount setenv base source"
__ldmx_complete_command "list clean config checkout pull use run mount setenv base source compile recompFire"
elif [[ "$COMP_CWORD" = "2" ]]; then
# tab complete a sub-argument,
# depends on the main argument
case "${COMP_WORDS[1]}" in
config|setenv)
config|setenv|compile)
# no more arguments
__ldmx_dont_complete
;;
Expand Down Expand Up @@ -809,7 +832,7 @@ __ldmx_complete() {
# check base argument to see if we should continue
case "${COMP_WORDS[1]}" in
list|base|clean|config|pull|use|mount|setenv|source)
# these commands shouldn't have tab complete for the third argument
# these commands shouldn't have tab complete for the third argument
# (or shouldn't have the third argument at all)
__ldmx_dont_complete
;;
Expand Down
27 changes: 27 additions & 0 deletions scripts/ldmx-recompileAndFire.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

############################# Usage #############################
# ldmx ./scripts/ldmx-recompileAndFire.sh
# for changing the defaults
# ldmx setenv LDMX_COMPILE_CORES=<num cores to be used>, i.e.
# ldmx setenv LDMX_COMPILE_CORES=16
# or
# ldmx setenv LDMX_COMPILE_BUILD=<build location>

FIREINPUT=$1
tvami marked this conversation as resolved.
Show resolved Hide resolved

if [ -z "$LDMX_COMPILE_CORES" ]; then
LDMX_COMPILE_CORES=$(nproc)
fi

if [ -z "$LDMX_COMPILE_BUILD" ]; then
LDMX_COMPILE_BUILD=${LDMX_BASE}/ldmx-sw/
fi

echo "-- Compiling ldmx-sw in ${LDMX_COMPILE_BUILD} with ${LDMX_COMPILE_CORES} cores, and running "

# Compile ldmx-sw
cmake -B ${LDMX_COMPILE_BUILD}/build -S ${LDMX_COMPILE_BUILD}
cmake --build ${LDMX_COMPILE_BUILD}/build --target install -j=${LDMX_COMPILE_CORES}
# Run fire on the input config
fire $FIREINPUT
tvami marked this conversation as resolved.
Show resolved Hide resolved