Commit
·
79455e7
1
Parent(s):
cfe1aa6
Add subdatasets util and auto load git-annex with datalad
Browse files- scripts/datalad.sh +14 -0
- scripts/requirements_datalad.txt +1 -0
- scripts/utils.sh +38 -0
scripts/datalad.sh
CHANGED
@@ -2,6 +2,19 @@
|
|
2 |
|
3 |
source scripts/utils.sh echo -n
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
function install_datalad {
|
6 |
init_venv --name venv --prefix .tmp/
|
7 |
exit_on_error_code "Failed to init venv"
|
@@ -10,6 +23,7 @@ function install_datalad {
|
|
10 |
exit_on_error_code "Failed to install datalad requirements: pip install"
|
11 |
}
|
12 |
|
|
|
13 |
datalad --version >/dev/null 2>&1 || install_datalad
|
14 |
exit_on_error_code "Failed to install datalad requirements: pip install"
|
15 |
datalad "$@"
|
|
|
2 |
|
3 |
source scripts/utils.sh echo -n
|
4 |
|
5 |
+
function activate_gitannex {
|
6 |
+
_conda_env=$(git config --file scripts/config/datalad_config --get datalad.conda.conda-env || echo -n)
|
7 |
+
if [[ ! -z "${_conda_env}" ]]
|
8 |
+
then
|
9 |
+
_modules=$(git config --file scripts/config/datalad_config --get datalad.conda.modules || echo -n)
|
10 |
+
if [[ -z "$(which conda)" ]] && [[ ! -z "${_modules}" ]]
|
11 |
+
then
|
12 |
+
module load ${_modules}
|
13 |
+
fi
|
14 |
+
conda activate ${_conda_env}
|
15 |
+
fi
|
16 |
+
}
|
17 |
+
|
18 |
function install_datalad {
|
19 |
init_venv --name venv --prefix .tmp/
|
20 |
exit_on_error_code "Failed to init venv"
|
|
|
23 |
exit_on_error_code "Failed to install datalad requirements: pip install"
|
24 |
}
|
25 |
|
26 |
+
which git-annex || activate_gitannex
|
27 |
datalad --version >/dev/null 2>&1 || install_datalad
|
28 |
exit_on_error_code "Failed to install datalad requirements: pip install"
|
29 |
datalad "$@"
|
scripts/requirements_datalad.txt
CHANGED
@@ -1 +1,2 @@
|
|
|
|
1 |
datalad==0.11.8
|
|
|
1 |
+
datalad[core]==0.11.8
|
2 |
datalad==0.11.8
|
scripts/utils.sh
CHANGED
@@ -207,6 +207,44 @@ function list {
|
|
207 |
fi
|
208 |
}
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
function unshare_mount {
|
211 |
if [[ ${EUID} -ne 0 ]]
|
212 |
then
|
|
|
207 |
fi
|
208 |
}
|
209 |
|
210 |
+
function subdatasets {
|
211 |
+
local _VAR=0
|
212 |
+
while [[ $# -gt 0 ]]
|
213 |
+
do
|
214 |
+
local _arg="$1"; shift
|
215 |
+
case "${_arg}" in
|
216 |
+
--var) local _VAR=1 ;;
|
217 |
+
-h | --help)
|
218 |
+
>&2 echo "Options for $(basename "$0") are:"
|
219 |
+
>&2 echo "--var also list datasets variants"
|
220 |
+
>&2 echo "then following --"
|
221 |
+
datalad subdatasets --help
|
222 |
+
exit 1
|
223 |
+
;;
|
224 |
+
--) break ;;
|
225 |
+
*) >&2 echo "Unknown option [${_arg}]"; exit 3 ;;
|
226 |
+
esac
|
227 |
+
done
|
228 |
+
|
229 |
+
if [[ ${_VAR} != 0 ]]
|
230 |
+
then
|
231 |
+
datalad subdatasets $@ | grep -o ": .* (dataset)" | grep -o " .* " | grep -o "[^ ]*" | \
|
232 |
+
while read subds
|
233 |
+
do
|
234 |
+
echo ${subds}
|
235 |
+
for _d in "${subds}.var"/*
|
236 |
+
do
|
237 |
+
if [[ -d "$_d" ]]
|
238 |
+
then
|
239 |
+
echo $_d
|
240 |
+
fi
|
241 |
+
done
|
242 |
+
done
|
243 |
+
else
|
244 |
+
datalad subdatasets $@ | grep -o ": .* (dataset)" | grep -o " .* " | grep -o "[^ ]*"
|
245 |
+
fi
|
246 |
+
}
|
247 |
+
|
248 |
function unshare_mount {
|
249 |
if [[ ${EUID} -ne 0 ]]
|
250 |
then
|