import ml.combust.mleap.tensorflow.TensorflowModel import ml.combust.mleap.core.types.TensorType import ml.combust.mleap.tensor.{DenseTensor, Tensor} import scala.util.{Try, Success, Failure} println("=== Test A: does TensorflowModel construction/load itself parse the GraphDef eagerly? ===") val garbage: Array[Byte] = Array.fill(64)(0x41.toByte) // 64 bytes of 'A', not a valid GraphDef val modelA = TensorflowModel( inputs = Seq(), outputs = Seq(), nodes = None, format = Some("graph"), modelBytes = garbage ) println(s"[Test A] TensorflowModel(...) constructed WITHOUT any exception at construction time (garbage modelBytes of ${garbage.length} bytes) -- confirms MLeap does zero eager validation at load/construction: $modelA") println("\n=== Test B: what happens when apply() actually triggers GraphDef.parseFrom + importGraphDef on garbage bytes? ===") val resultB = Try { modelA.apply() } resultB match { case Success(v) => println(s"[Test B UNEXPECTED SUCCESS] $v") case Failure(e) => println(s"[Test B EXCEPTION] ${e.getClass.getName}: ${e.getMessage}") } println("\n=== Test C: same, but with a well-formed EMPTY protobuf (0 bytes) as modelBytes, to see baseline behavior ===") val modelC = TensorflowModel( inputs = Seq(), outputs = Seq(), nodes = None, format = Some("graph"), modelBytes = Array.emptyByteArray ) val resultC = Try { modelC.apply() } resultC match { case Success(v) => println(s"[Test C UNEXPECTED SUCCESS] $v") case Failure(e) => println(s"[Test C EXCEPTION] ${e.getClass.getName}: ${e.getMessage}") } println("\n=== DONE ===")