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

Error when calling async runModel with empty inputs array #498

Closed
chrispcampbell opened this issue Jun 6, 2024 · 1 comment · Fixed by #499 or #476
Closed

Error when calling async runModel with empty inputs array #498

chrispcampbell opened this issue Jun 6, 2024 · 1 comment · Fixed by #499 or #476

Comments

@chrispcampbell
Copy link
Contributor

This is a bit of an edge case, since most models will have at least one input, but in the case where runModel (specifically the async runner implementation) is called with an empty inputs array, it produces an error:

 FAIL  src/runnable-model/buffered-run-model-params.spec.ts > BufferedRunModelParams > should copy inputs
TypeError: Cannot convert undefined or null to object
 ❯ BufferedRunModelParams.copyInputs src/runnable-model/buffered-run-model-params.ts:122:11
    120| 
    121|     // Copy from the internal buffer to the a…
    122|     array.set(this.inputs.view)
       |           ^
    123|   }
    124| 
 ❯ src/runnable-model/buffered-run-model-params.spec.ts:172:12

 FAIL  tests/runner.spec.ts > spawnAsyncModelRunner (with mock 'js' model) > should run the model (with empty inputs array)
TypeError: Cannot convert undefined or null to object
 ❯ runModel dist/index.cjs:103:19
 ❯ ../../node_modules/.pnpm/[email protected]/node_modules/threads/dist/worker/index.js:109:26
 ❯ ../../node_modules/.pnpm/[email protected]/node_modules/threads/dist/worker/index.js:8:71
 ❯ __awaiter ../../node_modules/.pnpm/[email protected]/node_modules/threads/dist/worker/index.js:4:12
 ❯ runFunction ../../node_modules/.pnpm/[email protected]/node_modules/threads/dist/worker/index.js:106:12
@chrispcampbell
Copy link
Contributor Author

The fix is to check for an empty (internal) inputs buffer in BufferedRunModelParams and skip the copy if the buffer is empty. This is the same approach we used for the outputIndices buffer.

I will add tests for both RunModelParams implementations as well as for the synchronous and async ModelRunner implementations.

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