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 run on a built bids-validator.js: Attempted to load JSON module without specifying "type" #1943

Open
yarikoptic opened this issue Apr 19, 2024 · 2 comments

Comments

@yarikoptic
Copy link
Contributor

Trying to run out of deno-build branch using wrapper proposed in

but getting

+ bids-validator 7t_trt --ignoreNiftiHeaders
TypeError: Attempted to load JSON module without specifying "type": "json" attribute in the import statement.
    at async loadSchema (file:///tmp/bids-validator/bids-validator.js:8513:26)
    at async validate (file:///tmp/bids-validator/bids-validator.js:9254:18)
    at async main (file:///tmp/bids-validator/bids-validator.js:9458:24)
    at async file:///tmp/bids-validator/bids-validator.js:9479:1 {
  code: "ERR_MODULE_NOT_FOUND"
}
Warning, could not load schema from https://bids-specification.readthedocs.io/en/latest/schema.json, falling back to internal version
	[WARNING] The 'Authors' field of 'dataset_description.json' should contain an array of values -
with one author per value.
This was triggered based on the presence of only one author field.
Please ignore if all contributors are already properly listed.
 (TOO_FEW_AUTHORS)

		./dataset_description.json
			Evidence: schema.rules.checks.hints.TooFewAuthors

		1 more files with the same issue

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

	[ERROR] Empty files not allowed. (EMPTY_FILE)

		./sub-01/ses-1/anat/sub-01_ses-1_T1map.nii.gz
		./sub-01/ses-1/anat/sub-01_ses-1_T1w.nii.gz
		./sub-01/ses-1/fmap/sub-01_ses-1_run-1_magnitude1.nii.gz

that is with

❯ bids-validator -V
v1.14.6-dev.0-9-gdc61d0f3.deno

❯ cat `which bids-validator`
#!/usr/bin/env bash

deno run --allow-read --allow-write --allow-env --allow-net --allow-run "$(dirname "$0")"/bids-validator.js "$@"

so there is --allow-net if that is of importance.

So it seems to do use some internal copy of schema but not clear why it fails to get/use that one from a URL if it wants so (should it download it every time? sounds a bit too much)

@nellh nellh added the bug label Apr 19, 2024
@nellh
Copy link
Member

nellh commented Apr 19, 2024

Here's the relevant code:

const schemaModule = await import(/* @vite-ignore */ schemaUrl, {
assert: { type: 'json' },
})

This is an issue with how the module is transpiled, it might be configuration or a bug in esbuild or the Deno module plugin.

import { denoPlugins } from "jsr:@luca/[email protected]"

So it seems to do use some internal copy of schema but not clear why it fails to get/use that one from a URL if it wants so (should it download it every time? sounds a bit too much)

Imports are always cached in deno. You can refresh the cache with deno run --reload .... The idea here is to load both ways, as a static import that can be bundled and a dynamic import that can be modified at runtime by the tool.

@yarikoptic
Copy link
Contributor Author

FWIW, adding --reload didn't help

❯ deno run --reload --allow-read --allow-write --allow-env --allow-net --allow-run /tmp/bids-validator/bids-validator.js 7t_trt --ignoreNiftiHeaders
TypeError: Attempted to load JSON module without specifying "type": "json" attribute in the import statement.
    at async loadSchema (file:///tmp/bids-validator/bids-validator.js:8513:26)
    at async validate (file:///tmp/bids-validator/bids-validator.js:9254:18)
    at async main (file:///tmp/bids-validator/bids-validator.js:9458:24)
    at async file:///tmp/bids-validator/bids-validator.js:9479:1 {
  code: "ERR_MODULE_NOT_FOUND"
}
Warning, could not load schema from https://bids-specification.readthedocs.io/en/latest/schema.json, falling back to internal version
...

note that this is on "compiled" (deno-build) version of bids-validator.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants