Serialize mleap defaultleapframe to json

Open
#716 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
scala

Research direction

Start with the linked DefaultLeapFrame.scala and LeapFrame.scala files, then inspect the documentation example and its imports or dependencies for the writer method. Confirm the supported JSON serialization API and update the example or usage guidance so it matches the available API.

Written by the indexing model from the issue text.

Description

I am trying to serialize mleap's DefaultLeapFrame to json format.
The doc shows the following example:

val schema = StructType(StructField("features", TensorType(BasicType.Double)),
  StructField("name", ScalarType.String),
  StructField("list_data", ListType(BasicType.String)),
  StructField("nullable_double", ScalarType(BasicType.Double, true)),
  StructField("float", ScalarType.Float),
  StructField("byte_tensor", TensorType(BasicType.Byte)),
  StructField("short_list", ListType(BasicType.Short)),
  StructField("nullable_string", ScalarType(BasicType.String, true))).get
val dataset = Seq(Row(Tensor.denseVector(Array(20.0, 10.0, 5.0)),
  "hello", Seq("hello", "there"),
  Option(56.7d), 32.4f,
  Tensor.denseVector(Array[Byte](1, 2, 3, 4)),
  Seq[Short](99, 12, 45),
  None))

val frame = DefaultLeapFrame(schema, dataset)

// Store Leap Frame
for(bytes <- frame.writer("ml.combust.mleap.json").toBytes();
    frame2 <- FrameReader("ml.combust.mleap.json").fromBytes(bytes)) {
  println(new String(bytes)) // print the JSON bytes
  assert(frame == frame2)
}

But locally I don't find the method writer for the DefaultLeapFrame object. I checked the source code for DefaultLeapFrame and LeapFrame as well but couldn't find the writer method there as well, as mentioned in the doc example.

Is it some implicit import or something ? Please do let know.

Thanks in advance.

Dominant language
Scala
Stars
1.5k
Forks
313
Avg merge
22m
Merged PRs (30d)
1

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from combust/mleap

All issues in combust/mleap

Similar issues

More Scala issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.