Skip to content

Commit

Permalink
Merge pull request #464 from effigies/fix/deno-validator
Browse files Browse the repository at this point in the history
Simplify run tests to improve variant detection, set configurations
  • Loading branch information
effigies authored Aug 27, 2024
2 parents d90c132 + 4b71633 commit fe6f06a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 27 deletions.
3 changes: 0 additions & 3 deletions genetics_ukbb/.bids-validator-config.json

This file was deleted.

File renamed without changes.
31 changes: 7 additions & 24 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
failed=

which bids-validator
if bids-validator --help | grep -q -e '--config'; then
VALIDATOR_SUPPORTS_CONFIG=yes

if bids-validator --help | grep -q Description; then
VARIANT="schema"
else
VALIDATOR_SUPPORTS_CONFIG=
VARIANT="legacy"
fi

for i in $(ls -d */ | grep -v node_modules); do
Expand All @@ -22,13 +23,8 @@ for i in $(ls -d */ | grep -v node_modules); do
CMD="bids-validator ${i%%/} $VALIDATOR_ARGS"

# Use default configuration unless overridden
if [ -n "$VALIDATOR_SUPPORTS_CONFIG" ]; then
if [ ! -f ${i%%/}/.bids-validator-config.json ]; then
CMD="$CMD -c $PWD/bidsconfig.json"
fi
else
# with new one we do not have config so let's get --json and exclude some using jq
CMD="$CMD --json"
if [[ ! ( -f ${i%%/}/.bids-validator-config.json || $CMD =~ /--config/ ) ]]; then
CMD="$CMD --config $PWD/${VARIANT}config.json"
fi

# Ignore NIfTI headers except for synthetic dataset
Expand All @@ -40,20 +36,7 @@ for i in $(ls -d */ | grep -v node_modules); do

echo "Running " $CMD

if [ -n "$VALIDATOR_SUPPORTS_CONFIG" ]; then
$CMD || failed+=" $i"
else
# exit code is not returned correctly anyways and for the best since we need to ignore
# ref: https://github.com/bids-standard/bids-validator/issues/1909
# NOTE: limit to 1 file per error to not flood screen!
errors=$($CMD 2>/dev/null \
| jq '(.issues | map(select(.severity == "error" and .key != "EMPTY_FILE"))) | map(.files_1 = (.files | if length > 0 then .[0:1] else empty end) | del(.files)) | if length > 0 then . else empty end' \
)
if [ -n "$errors" ]; then
echo -e "$errors" | sed -e 's,^, ,g'
failed+=" $i"
fi
fi
$CMD || failed+=" $i"
done
if [ -n "$failed" ]; then
echo "Datasets failed validation: $failed"
Expand Down
5 changes: 5 additions & 0 deletions schemaconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore": [
{ "code": "EMPTY_FILE" }
]
}

0 comments on commit fe6f06a

Please sign in to comment.