Skip to content

Commit cad0cae

Browse files
committed
Updated the hed validation to only load schemas once
1 parent 587842a commit cad0cae

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/validators/hed.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ function sidecarValueHasHed(sidecarValue: unknown) {
2525
let hedSchemas: object | undefined | null = undefined
2626

2727
async function setHedSchemas(datasetDescriptionJson = {}) {
28+
if (hedSchemas !== undefined) {
29+
return [] as HedIssue[]
30+
}
2831
const datasetDescriptionData = new hedValidator.bids.BidsJsonFile(
2932
'/dataset_description.json',
3033
datasetDescriptionJson,
@@ -59,14 +62,14 @@ export async function hedValidate(
5962
let hedValidationIssues = [] as HedIssue[]
6063

6164
try {
62-
if (context.extension == '.tsv' && context.columns) {
65+
if (context.extension === '.tsv' && context.columns) {
6366
if (!('HED' in context.columns) && !sidecarHasHed(context.sidecar)) {
6467
return
6568
}
6669
hedValidationIssues = await setHedSchemas(context.dataset.dataset_description)
6770

6871
file = await buildHedTsvFile(context)
69-
} else if (context.extension == '.json' && sidecarHasHed(context.json)) {
72+
} else if (context.extension === '.json' && sidecarHasHed(context.json)) {
7073
hedValidationIssues = hedValidationIssues = await setHedSchemas(
7174
context.dataset.dataset_description,
7275
)

0 commit comments

Comments
 (0)