openvino icon indicating copy to clipboard operation
openvino copied to clipboard

[JS] Add importModel(tensor) overload, getAvailableFrontEnds binding and tests

Open Yashwanth1124 opened this issue 1 month ago • 14 comments

Summary

This PR introduces enhancements to the OpenVINO JavaScript bindings, adding new API functionality and improving test coverage and robustness.

Changes

  • Added Core.getAvailableFrontEnds() binding to the JS API.
  • Added async Core.importModel() overload that accepts an ov.Tensor as input.
  • The Promise returned by importModel() now correctly rejects on C++ exceptions.
  • Added corresponding TypeScript typings for the new overload.
  • Added unit tests validating both the getAvailableFrontEnds() binding and the new importModel(tensor) functionality.
  • Minor test robustness improvement: compiled_model tests are skipped automatically when the BATCH device is unavailable locally.

Validation

Local test results:

224 passed, 0 failed, 10 skipped

Notes

Closes #32725

Yashwanth1124 avatar Nov 07 '25 14:11 Yashwanth1124

Hi @almilosz, @Retribution98

This PR adds a few JavaScript-side enhancements and corresponding tests as discussed:

  • Added Core.getAvailableFrontEnds() binding to expose available frontends in JS.
  • Introduced an async Core.importModel() overload that accepts an ov.Tensor.
    • The Promise now properly rejects when a C++ exception occurs.
  • Updated TypeScript typings to include the new overload.
  • Added unit tests covering both getAvailableFrontEnds() and importModel(tensor).
  • Improved test robustness: compiled_model tests are skipped automatically when the BATCH device isn’t available locally.

Local test results 224 passed, 0 failed, 10 skipped

Everything builds and runs cleanly on the current v3.8_for_ie_master baseline.
Please review when you have a moment — feedback on API design and test coverage is welcome.

Yashwanth1124 avatar Nov 07 '25 15:11 Yashwanth1124

Thanks for reviewing. I’ve pushed the updates:

  • Fixed the unsafe ThreadSafeFunction error-message capture in core_wrap.cpp (captured by value to avoid lifetime issues).
  • Added guards in the compiled_model tests so they skip cleanly when the BATCH device isn’t available or compiledModel returns null.
  • Made the external-tensor interoperability tests optional by skipping when __getExternalTensor isn’t exposed by the native addon.
  • Cleaned up a stray blank line in basic.test.js.
  • Applied clang-format-18 to the modified C++ section.

Local test results:
✔️ 236 run
✔️ 224 passed
⚠️ 12 skipped
❌ 0 failed

Please re-run CI so formatting checks and platform builds can validate on the official runners.

Yashwanth1124 avatar Nov 19 '25 06:11 Yashwanth1124

Hey @mlukasze, now can you just this commit, and let me know that everything is fine. If so, you can merge this. Appreciate your review and response.

Yashwanth1124 avatar Nov 20 '25 10:11 Yashwanth1124

Yeah sure I will update them as soon as possible!! Thank you for review

Yashwanth1124 avatar Nov 20 '25 11:11 Yashwanth1124

Thanks for the review @almilosz — I’ve applied the requested changes and pushed them to [js/import-model-tensor]. Summary of fixes:

  1. Removed: getAvailableFrontEnds binding and its implementation (not part of [ov::Core] — [core_wrap.cpp]
  2. Fixed: duplicate [getAvailableDevices] registration and tidied [importModel] comments/overload notes — [core_wrap.cpp]
  3. Formatting / lint: collapsed overload signatures and fixed JSDoc in [addon.ts] (Prettier), removed unused catch params in [compiled_model.test.js] (ESLint).
  4. Removed tests: dropped out-of-scope native __getExternalTensor interoperability tests from [tensor.test.js] per your suggestion (depend on private native API).
  5. C++ style: ran clang-format on changed headers/sources and committed the results ([core_wrap.hpp]

CI status: I pushed changes and CI ran — current workflow runs show action_required (some jobs require attention). The lint/format issues reported earlier were addressed; if any CI jobs still fail I can fetch and post the failing job logs.

Please re-review when you have a moment. I’ll promptly apply any follow-ups you request.

Yashwanth1124 avatar Nov 20 '25 11:11 Yashwanth1124

Hey @almilosz, could you please approve the workflows? If any error logs come up afterward, I’ll review them.

Yashwanth1124 avatar Nov 21 '25 12:11 Yashwanth1124

Hey @mlukasze, thank you for the approval, I saw two checks were unsuccessful, and I hope I solved them, Kindly once again approve the workflow to run against checks, and if any errors raise, I am ready to tackle them.

Yashwanth1124 avatar Nov 21 '25 15:11 Yashwanth1124

build_jenkins

mlukasze avatar Nov 24 '25 16:11 mlukasze

build_jenkins

mlukasze avatar Nov 25 '25 06:11 mlukasze

some comments from review are not addressed still Code itself looks like stabilizing, but final clean up as instructed is necessary

mlukasze avatar Nov 25 '25 06:11 mlukasze

Ok, thank you for the review, I will update PR as soon as possible

Yashwanth1124 avatar Nov 26 '25 16:11 Yashwanth1124

Hello @Yashwanth1124 , are you still working on this task?

almilosz avatar Dec 09 '25 12:12 almilosz

Yes @almilosz , i have made few commits, waiting for approval since a week.

Yashwanth1124 avatar Dec 11 '25 06:12 Yashwanth1124

Yes @almilosz , i have made few commits, waiting for approval since a week.

Hi @Yashwanth1124 I see that not all of the comments have been fixed. Please check the pushed commits and review the comments one more time. Fix them or leave a reply if you have any objections.

Retribution98 avatar Dec 11 '25 09:12 Retribution98