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

Bep031 review updates #7

Merged
merged 13 commits into from
Jan 12, 2022

Conversation

rwblair
Copy link

@rwblair rwblair commented Jan 7, 2022

Few proposed changes to the bep031 PR.

For the error generated from missing the chunk matrix, I use the data file in the error instead of the json file returned by generateMergedSidecarDictWithPath. generateMergedSidecarDictWithPath only returned the last json file validated, where the value could be and could go in any inherited json file for the data file.

I tried to rewrite without using the new readBuffer function and only using readFile. Its possible, we can decode the string returned by readFile back into a buffer, but this makes our potential memory issues worse by making a new copy of the files contents.

@nellh what do you think about adding a flag on readFile to return a buffer? or would leaving readBuffer as is in place be better?

Leaving as WIP until @nellh gets a chance to review.

Let me know what yall think @etiennebergeron and @konantian.

@nellh
Copy link

nellh commented Jan 7, 2022

@nellh what do you think about adding a flag on readFile to return a buffer? or would leaving readBuffer as is in place be better?

I think keeping it as readBuffer is better for now, this kind of readFile call I think is something we'll replace soon but with one use of it here - keeping them separate makes it clear which behavior is expected when refactoring it later.

Copy link

@nellh nellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran through this, tried breaking some of tests and that worked as expected. 👍

@rwblair rwblair changed the title [WIP] Bep031 review updates Bep031 review updates Jan 7, 2022
@konantian
Copy link
Collaborator

I do have concerns about the memory usage if the dataset is too large, but currently have no good ideas on how to optimize this yet. I suggest leaving readBuffer as it is, if the performance will be a big issue in the future, we can do more optimization on it then.

@mariehbourget
Copy link

mariehbourget commented Jan 10, 2022

Hi @rwblair and @nellh, thank you for making corrections and reviewing this PR!

I tried testing it but I get an ENOBUF error with both our examples datasets (micr_spim and micr_sem) on this branch (that I don't have on bep031).
I tried installing a fresh clone but have the same error.

(base) C:\Users\bourg\bids-validator_np>node bids-validator/bin/bids-validator --config.ignore=44 --config.ignore=99 C:\Users\bourg\bids-examples\micr_sem
<ref *1> Error: spawnSync C:\Users\bourg\bids-validator_np\node_modules\esbuild\esbuild.exe ENOBUFS
    at Object.spawnSync (node:internal/child_process:1083:20)
    at spawnSync (node:child_process:812:24)
    at Object.execFileSync (node:child_process:858:15)
    at runServiceSync (C:\Users\bourg\bids-validator_np\node_modules\esbuild\lib\main.js:1802:30)
    at buildSync (C:\Users\bourg\bids-validator_np\node_modules\esbuild\lib\main.js:1628:3)
    at _bundle (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\esbuild.ts:92:19)
    at transpile (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\esbuild.ts:120:12)
    at Module.mod._compile (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\hook.ts:53:40)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.Module._extensions.<computed> [as .js] (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\hook.ts:56:7) {
  errno: -4060,
  code: 'ENOBUFS',
  syscall: 'spawnSync C:\\Users\\bourg\\bids-validator_np\\node_modules\\esbuild\\esbuild.exe',
  path: 'C:\\Users\\bourg\\bids-validator_np\\node_modules\\esbuild\\esbuild.exe',
  spawnargs: [ '--service=0.11.23' ],
  error: [Circular *1],
  status: null,
  signal: 'SIGTERM',
  output: [
    null,
    <Buffer 07 00 00 00 30 2e 31 31 2e 32 33 f9 9e 08 01 01 00 00 00 06 03 00 00 00 06 00 00 00 65 72 72 6f 72 73 05 00 00 00 00 0b 00 00 00 6f 75 74 70 75 74 46 ... 16842702 more bytes>,
    <Buffer >
  ],
  pid: 13732,
  stdout: <Buffer 07 00 00 00 30 2e 31 31 2e 32 33 f9 9e 08 01 01 00 00 00 06 03 00 00 00 06 00 00 00 65 72 72 6f 72 73 05 00 00 00 00 0b 00 00 00 6f 75 74 70 75 74 46 ... 16842702 more bytes>,
  stderr: <Buffer >
}

@nellh
Copy link

nellh commented Jan 11, 2022

Hi @rwblair and @nellh, thank you for making corrections and reviewing this PR!

I tried testing it but I get an ENOBUF error with both our examples datasets (micr_spim and micr_sem) on this branch (that I don't have on bep031). I tried installing a fresh clone but have the same error.

(base) C:\Users\bourg\bids-validator_np>node bids-validator/bin/bids-validator --config.ignore=44 --config.ignore=99 C:\Users\bourg\bids-examples\micr_sem
<ref *1> Error: spawnSync C:\Users\bourg\bids-validator_np\node_modules\esbuild\esbuild.exe ENOBUFS
    at Object.spawnSync (node:internal/child_process:1083:20)
    at spawnSync (node:child_process:812:24)
    at Object.execFileSync (node:child_process:858:15)
    at runServiceSync (C:\Users\bourg\bids-validator_np\node_modules\esbuild\lib\main.js:1802:30)
    at buildSync (C:\Users\bourg\bids-validator_np\node_modules\esbuild\lib\main.js:1628:3)
    at _bundle (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\esbuild.ts:92:19)
    at transpile (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\esbuild.ts:120:12)
    at Module.mod._compile (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\hook.ts:53:40)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.Module._extensions.<computed> [as .js] (C:\Users\bourg\bids-validator_np\node_modules\esbuild-runner\src\hook.ts:56:7) {
  errno: -4060,
  code: 'ENOBUFS',
  syscall: 'spawnSync C:\\Users\\bourg\\bids-validator_np\\node_modules\\esbuild\\esbuild.exe',
  path: 'C:\\Users\\bourg\\bids-validator_np\\node_modules\\esbuild\\esbuild.exe',
  spawnargs: [ '--service=0.11.23' ],
  error: [Circular *1],
  status: null,
  signal: 'SIGTERM',
  output: [
    null,
    <Buffer 07 00 00 00 30 2e 31 31 2e 32 33 f9 9e 08 01 01 00 00 00 06 03 00 00 00 06 00 00 00 65 72 72 6f 72 73 05 00 00 00 00 0b 00 00 00 6f 75 74 70 75 74 46 ... 16842702 more bytes>,
    <Buffer >
  ],
  pid: 13732,
  stdout: <Buffer 07 00 00 00 30 2e 31 31 2e 32 33 f9 9e 08 01 01 00 00 00 06 03 00 00 00 06 00 00 00 65 72 72 6f 72 73 05 00 00 00 00 0b 00 00 00 6f 75 74 70 75 74 46 ... 16842702 more bytes>,
  stderr: <Buffer >
}

This is the issue discussed in https://github.com/bids-standard/bids-validator/issues/1399 does the ESBUILD_MAX_BUFFER=33554432 workaround solve it for you?

@konantian
Copy link
Collaborator

Based on my test, if we put relocate two dependencies exifreader and xml2js from bids-validator/bids-validator/package.json to bids-validator/package.json, there will be no ENOBUF error anymore. However, when I run our validator against micr_SEM I got this error, but everything was fine with micr_SPIM

Screen Shot 2022-01-10 at 23 08 20
`
Also, I am not able to run our validator from the browsers as well.

Copy link

@mariehbourget mariehbourget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @nellh and @konantian.
I was able to run the validator without the ENOBUF error using either of your suggestions.

  1. set ESBUILD_MAX_BUFFER=33554432
    or
  2. moving exifreader and xml2js from bids-validator/bids-validator/package.json to bids-validator/package.json

So I tested the branch, everything is working great with the micr_SPIM dataset, except the filename embedded in the ChunkTransformationMatrix warning.
Similarly, the error we get with the micr_SEM dataset seems also related to this error, but I don't understand why and why only for PNG files.

I have no experience in Javascript (only python) so I hope my comments make sense. Thank you for your help!

file: {
path: file,
},
code: 223,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, if "chunkTransformationMatrix" is missing, the path of the "file" does not appear, I get ".undefined" instead.
I don't understand why because if the JSON file is missing altogether (error 225 above), the path in the error is correct.
Ex:
chunkmatrix_no_path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also seems to be related to the issue with the micr_SEM dataset. This function returns the issues [ undefined, undefined ] causing the "Unhandled rejection". (but only for PNG files?)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I forgot that the result of the json check function was being directly concatenated to the issues list. If there were no problems it returned undefined by default. I added a base return with an empty list to handle this.

@rwblair
Copy link
Author

rwblair commented Jan 11, 2022

The ENOBUF is related to esbuild-runner some how. If the exifreader and xml dependencies are in bids-validator/bids-validator/package.json, and the validator is called with bids-validator/bids-validator/ being the current working directory I don't get the error.

If while in bids-validator/bids-validator/ I call npm run build and then edit bids-validator/bids-validator/bin/bids-validator to only call the code in its catch statement, by passing esbuild-runner import, I can call the validator from any directory with no error.

So at least thats only an error for development, not sure how best to resolve that issue though. Would be nice to keep the dependency in just the validators package.json and be able to call the cli without having to rebuild every time (though esbuild is so fast maybe the call to the cli could just kick off the build process if it detects its in a dev environment?)

I'm not able to build the website currently with npm run web-build:

ModuleNotFoundError: Module not found: Error: Can't resolve '/home/rwblair/projects/bids-validator/bids-validator-web/node_modules/@babel/runtime/helpers/esm/classCallCheck' in '/home/rwblair/projects/bids-validator/bids-validator-web/components'


> Build error occurred
Error: > Build failed because of webpack errors
    at /home/rwblair/projects/bids-validator/node_modules/next/dist/build/index.js:397:19
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Span.traceAsyncFn (/home/rwblair/projects/bids-validator/node_modules/next/dist/telemetry/trace/trace.js:60:20)
    at async Object.build [as default] (/home/rwblair/projects/bids-validator/node_modules/next/dist/build/index.js:77:25)

I'll update here when I find a fix for this as well.

@nellh
Copy link

nellh commented Jan 11, 2022

Putting the dependencies in the root package will incidentally work since they exist in node_modules but it will fail when bundled (esbuild or webpack) because they are not included in the output and not present at runtime. The ENOBUFS error is caused when esbuild's output buffer for the full bundle (bids-validator and all deps) is exceeding the buffer size.

These dependencies aren't terribly large (about 150kB minified together), I think we can temporarily raise the buffer limit and try to solve this separately.

@konantian
Copy link
Collaborator

@rwblair and @nellh Thanks for your solutions and explanations, it works for me as well. I am able to run bids-validator without any errors on micr_SEM and micr_SPIM now.

Copy link

@mariehbourget mariehbourget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rwblair and @nellh!
I tested the new version without errors on both our bids-examples datasets by running it from the bids-validator/bids-validator/ directory.

Let me know if you prefer we address the website and ENOBUF errors here, or in another PR.
Thanks!

@rwblair
Copy link
Author

rwblair commented Jan 12, 2022

@mariehbourget ENOBUF and web issue should fixed from my past couple of commits.

Feel free to merge and any further issues I can push directly to the main PR.

@mariehbourget mariehbourget merged commit bd78f58 into neuropoly:bep031 Jan 12, 2022
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

Successfully merging this pull request may close these issues.

4 participants