Skip to content

Commit

Permalink
add datalad run-procedure interface for un/repack-studyspec scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pvavra committed Dec 6, 2019
1 parent eec6114 commit 9415a89
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .datalad/config
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
[datalad "dataset"]
id = badd1ad0-1819-11ea-a1e8-a0369f7c647e

[datalad "locations"]
dataset-procedures = procedures

[datalad "procedures.unpack-studyspec"]
call-format = "bash {script} {args}"

This comment has been minimized.

Copy link
@bpoldrack

bpoldrack Dec 9, 2019

Something you might not be aware of:
By leaving out {ds} in that call-format and subsequently not using it within the procedure you might encounter unintended sideeffects. datalad run-procedure unpack-studyspec may be called with --dataset /some/path. But the datalad-run call with that procedure now doesn't know about that dataset to operate on and will rely on CWD of its process to figure the dataset to save to, look for relative paths in and possibly get missing content in. If that resolves to two different datasets the resulting behavior/failure might not be easy to grasp.

This comment has been minimized.

Copy link
@pvavra

pvavra Dec 9, 2019

Author Owner

yes, I understand that and I'll update later.

The same bug is part of the copy & move converters, see config, copy converter and move converter.

I've posted another issue over at the toolbox for them :p

help = "helper to convert studyspec.json into valid-json format"

[datalad "procedures.repack-studyspec"]
call-format = "bash {script} {args}"
help = "helper to convert valid-json into studyspec.json format"
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions procedures/repack-studyspec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# simple wrapper around helpers/repack-studyspec.py which will call datalad run

set -e -u
set -x

if [ "$#" -gt 1 ]
then
datalad run --explicit --input "$1" --output "$2" python helplers/repack-studyspec.py "$1" "$2"
else
datalad run --explicit --input "$1" --output "$1" python helplers/repack-studyspec.py "$1" "$1"
fi
12 changes: 12 additions & 0 deletions procedures/unpack-studyspec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# simple wrapper around helpers/unpack-studyspec.py which will call datalad run

set -e -u
set -x

if [ "$#" -gt 1 ]
then
datalad run --explicit --input "$1" --output "$2" python helplers/unpack-studyspec.py "$1" "$2"
else
datalad run --explicit --input "$1" --output "$1" python helplers/unpack-studyspec.py "$1" "$1"
fi

0 comments on commit 9415a89

Please sign in to comment.