[ML][Train] Fixes for error types of compile() and run() 31/274731/2
authorPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Fri, 6 May 2022 11:58:22 +0000 (13:58 +0200)
committerPiotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics <p.kosko@samsung.com>
Fri, 6 May 2022 14:10:03 +0000 (16:10 +0200)
commitb5db9a566a41f837c539a06d7cffc441afe018ae
treef33d559fd1b4551ddf29c0505fa4e1206809d0e7
parent9383d6e81a3dd80251793b10e6edc25c8a4d0450
[ML][Train] Fixes for error types of compile() and run()

Fixed error handling for compile() and run() - all errors were casted to
AbortError. After fix, errors reported by native API are casted to
proper Web type if possible.

Added proper handling for null/undefined values passed as options.

[Verification]
modelFile = "/home/owner/media/Documents/test_model.ini"
var Model = tizen.ml.trainer.createModel(modelFile);

Model.compile({loss:"test"})  // InvalidValuesError
// Model.compile({loss:true}) // InvalidValuesError
// Model.compile(null)        // success
// Model.compile()            // success

sCb = (s) => console.log(s)
eCb = (e) => console.log(e)
Model.run({save_path:"not_a_virutal_path"}, sCb, eCb);
//InvalidValuesError via eCb

// Model.run({save_path:"/not_a_real_path"}, sCb, eCb);
// InvalidValuesError via eCb

// Model.run({epochs: "aaaa"}, sCb, eCb)
// InvalidValuesError via eCb

// Model.run({epochs: true}, sCb, eCb)
// InvalidValuesError via eCb

// Model.run(null, sCb, eCb)   // success
// Model.run("abcd", sCb, eCb) // TypeMismatchError

Change-Id: Ibb59f7720048b499ce0d576666fad2d5764637e5
src/ml/js/ml_trainer.js
src/ml/ml_trainer_manager.cc