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

Use compact and compressed model json by default #375

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.salesforce.op.filters.RawFeatureFilterResults
import com.salesforce.op.stages.{OPStage, OpPipelineStageWriter}
import enumeratum._
import org.apache.hadoop.fs.Path
import org.apache.hadoop.io.compress.GzipCodec
import org.apache.spark.ml.util.MLWriter
import org.json4s.JsonAST.{JArray, JObject, JString}
import org.json4s.JsonDSL._
Expand All @@ -54,7 +55,8 @@ class OpWorkflowModelWriter(val model: OpWorkflowModel) extends MLWriter {
implicit val jsonFormats: Formats = DefaultFormats

override protected def saveImpl(path: String): Unit = {
sc.parallelize(Seq(toJsonString(path)), 1).saveAsTextFile(OpWorkflowModelReadWriteShared.jsonPath(path))
sc.parallelize(Seq(toJsonString(path)), 1)
.saveAsTextFile(OpWorkflowModelReadWriteShared.jsonPath(path), classOf[GzipCodec])
}

/**
Expand All @@ -63,7 +65,7 @@ class OpWorkflowModelWriter(val model: OpWorkflowModel) extends MLWriter {
* @param path to save the model and its stages
* @return model json string
*/
def toJsonString(path: String): String = pretty(render(toJson(path)))
def toJsonString(path: String): String = compact(render(toJson(path)))

/**
* Json serialize model instance
Expand Down