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

deno (and legacy): Define and validate config file against target schema #2182

Open
yarikoptic opened this issue Oct 30, 2024 · 0 comments
Open

Comments

@yarikoptic
Copy link
Contributor

yarikoptic commented Oct 30, 2024

Could take all the error codes from the schema etc. But more so -- validate overall structure!

ATM neither legacy nor deno validators seems to care about config file being misspecified, e.g. with

❯ cat .bids-validator-config--totallywrong.json
["mess"]
there is neither complaint from legacy validator
❯ podman run -it --rm -v "${PWD}:${PWD}:ro" -w "${PWD}" bids/validator --config $PWD/.bids-validator-config--totallywrong.json asl001
[email protected]
	1: [ERR] This file is too small to contain the minimal NIfTI header. (code: 36 - NIFTI_TOO_SMALL)
		./sub-Sub103/anat/sub-Sub103_T1w.nii.gz
		./sub-Sub103/perf/sub-Sub103_asl.nii.gz

	Please visit https://neurostars.org/search?q=NIFTI_TOO_SMALL for existing conversations about this issue.

        Summary:                Available Tasks:        Available Modalities: 
        8 Files, 94.63KB                                MRI                   
        1 - Subject                                                           
        1 - Session                                                           


	If you have any questions, please post on https://neurostars.org/tags/bids.
 
nor from deno one
❯ deno run --allow-read --allow-env --reload -A https://github.com/bids-standard/bids-validator/raw/deno-build/bids-validator.js --config .bids-validator-config--totallywrong.json asl001
	[WARNING] JSON_KEY_RECOMMENDED A JSON file is missing a key listed as recommended.
		GeneratedBy
		/dataset_description.json

		SourceDatasets
		/dataset_description.json

	Please visit https://neurostars.org/search?q=JSON_KEY_RECOMMENDED for existing conversations about this issue.

	[WARNING] SIDECAR_KEY_RECOMMENDED A data file's JSON sidecar is missing a key listed as recommended.
		DeviceSerialNumber
		/sub-Sub103/anat/sub-Sub103_T1w.nii.gz
		/sub-Sub103/perf/sub-Sub103_asl.nii.gz

....

edit 1: relates to the fact that schema seems has changed for deno - I found

### Configuration file
and legacy syntax doesn't work.

Resting on the fact that there is no validation it seems to be possible to "encode" both old legacy and new deno validation configs

here is an example
❯ cp .bids-validator-config--conflicting2.json .bids-validator-config--conflicting2-deno.json
❯ cat .bids-validator-config--conflicting2-deno.json
{
  "ignore": [
     "NIFTI_TOO_SMALL",
     "SIDECAR_KEY_RECOMMENDED",
     "NIFTI_HEADER_UNREADABLE",
     "TOTAL_ACQUIRED_VOLUMES_NOT_CONSISTENT",
     "JSON_KEY_RECOMMENDED"
    ]
}
❯ sed -i -e 's|\("[A-Z][^"]*"\)|\1, { "code": \1 }|g' .bids-validator-config--conflicting2-deno.json
❯ cat .bids-validator-config--conflicting2-deno.json
{
  "ignore": [
     "NIFTI_TOO_SMALL", { "code": "NIFTI_TOO_SMALL" },
     "SIDECAR_KEY_RECOMMENDED", { "code": "SIDECAR_KEY_RECOMMENDED" },
     "NIFTI_HEADER_UNREADABLE", { "code": "NIFTI_HEADER_UNREADABLE" },
     "TOTAL_ACQUIRED_VOLUMES_NOT_CONSISTENT", { "code": "TOTAL_ACQUIRED_VOLUMES_NOT_CONSISTENT" },
     "JSON_KEY_RECOMMENDED", { "code": "JSON_KEY_RECOMMENDED" }
    ]
}

# old validator works
❯ podman run -it --rm -v "${PWD}:${PWD}:ro" -w "${PWD}" bids/validator --config $PWD/.bids-validator-config--conflicting2-deno.json asl001
[email protected]
This dataset appears to be BIDS compatible.
        Summary:                Available Tasks:        Available Modalities: 
        8 Files, 94.63KB                                MRI                   
        1 - Subject                                                           
        1 - Session                                                           


	If you have any questions, please post on https://neurostars.org/tags/bids.

# and deno too

❯ deno run --allow-read --allow-env --reload -A https://github.com/bids-standard/bids-validator/raw/deno-build/bids-validator.js --config .bids-validator-config--conflicting2-deno.json asl001

          Summary:                         Available Tasks:        Available Modalities:
          8 Files, 96.9 kB                                         MRI                  
          1 - Subjects 1 - Sessions                                                     

	If you have any questions, please post on https://neurostars.org/tags/bids.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant