-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from ReproNim/enh-pidlock
ENH: make pass_git_config to allow to have no default + pass annex.pidlock if defined
- Loading branch information
Showing
3 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
Submodule artwork
updated
3 files
+ − | repronim-containers-yoda-filesystem.png | |
+1,372 −0 | repronim-containers-yoda-filesystem.svg | |
+ − | repronim-containers-yoda-principles.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
# - cleansed environment variables | ||
# while bind mounting (and starting from) current directory. | ||
# | ||
# COPYRIGHT: Yaroslav Halchenko 2019 | ||
# COPYRIGHT: Yaroslav Halchenko 2019-2023 | ||
# | ||
# LICENSE: MIT | ||
# | ||
|
@@ -31,8 +31,6 @@ | |
# THE SOFTWARE. | ||
# | ||
|
||
set -eu | ||
|
||
function info() { | ||
: # echo -e "I: " "$@" >&2 | ||
} | ||
|
@@ -43,11 +41,21 @@ function info() { | |
# | ||
function pass_git_config() { | ||
var="$1" | ||
default="$2" | ||
|
||
# git config reads without locking, but could lock for writing | ||
# so we might need to try multiple times setting the value | ||
value=$(git config "$var" || echo "$default") | ||
set +e | ||
value=$(git config "$var") | ||
ret=$? | ||
set -e | ||
|
||
# if variable is not defined at all | ||
if [ "$ret" = 1 ] ; then | ||
# and default was not provided - nothing for us to do | ||
[ "$#" -ge 2 ] || return 0 | ||
# otherwise, use that default | ||
value="$2" | ||
fi | ||
# shellcheck disable=SC2034 | ||
for attempt in {1..5}; do | ||
git config -f "$BHOME/.gitconfig" "$var" >/dev/null \ | ||
|
@@ -62,6 +70,13 @@ function readlink_f() { | |
readlink -f "$1" 2> /dev/null || python -c 'import sys, os ; print(os.path.realpath(sys.argv[1]))' "$1" | ||
} | ||
|
||
if [ "$#" = 0 ]; then | ||
echo "Using as a library. Run with 'exec' or 'run' command and options." | ||
exit 0 | ||
fi | ||
|
||
set -eu | ||
|
||
info "PWD=$PWD" | ||
|
||
thisfile=$(readlink_f "$0") | ||
|
@@ -78,7 +93,7 @@ if [ -n "${DATALAD_CONTAINER_NAME:-}" ]; then | |
export APPTAINERENV_DATALAD_CONTAINER_NAME="$DATALAD_CONTAINER_NAME" | ||
fi | ||
|
||
# fix non-writable matplotlib cache dir in apptainer https://github.com/ReproNim/containers/issues/97 | ||
# fix non-writable matplotlib cache dir in apptainer https://github.com/ReproNim/containers/issues/97 | ||
export SINGULARITYENV_MPLCONFIGDIR=/tmp/mpl-config | ||
export APPTAINERENV_MPLCONFIGDIR=/tmp/mpl-config | ||
|
||
|
@@ -89,9 +104,9 @@ export APPTAINERENV_MPLCONFIGDIR=/tmp/mpl-config | |
# (double-bound) directory. Shortening the name of the directory is one way | ||
# to fix the problem. See https://github.com/ReproNim/containers/issues/57 | ||
if [ "$(uname -s)" = Darwin ]; then | ||
tmpdir=$(mktemp -d -t s) | ||
tmpdir=$(mktemp -d -t s) | ||
else | ||
tmpdir=$(mktemp -d -t singtmp.XXXXXX) | ||
tmpdir=$(mktemp -d -t singtmp.XXXXXX) | ||
fi | ||
|
||
# To know what base would need to be mounted within docker | ||
|
@@ -103,6 +118,8 @@ trap 'rm -fr "$tmpdir" && info "removed temp dir $tmpdir"' exit | |
|
||
pass_git_config "user.name" "ReproNim User" | ||
pass_git_config "user.email" "[email protected]" | ||
# only if set - pass pidlock so we could operate on NFS mounts, like on rolando | ||
pass_git_config "annex.pidlock" | ||
|
||
# Common arguments for the singularity run | ||
SARGS=( -e -B "$PWD" -H "$BHOME" --pwd "$PWD" "$@" ) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters