-
Notifications
You must be signed in to change notification settings - Fork 363
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
[SW-2639] Expose Fields of Model Output on H2OMOJOModel Classes as Getters #2692
Conversation
doc/src/main/scala/ai/h2o/sparkling/doc/generation/ModelDetailsTemplate.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍
api-generation/src/main/scala/ai/h2o/sparkling/api/generation/common/OutputResolver.scala
Outdated
Show resolved
Hide resolved
|
||
val explicitFieldImplementations = parameterSubstitutionContext.explicitFields.flatMap(_.mojoImplementation) ++ | ||
parameterSubstitutionContext.deprecatedFields.flatMap(_.mojoImplementation) | ||
|
||
val imports = Seq( | ||
"scala.collection.JavaConverters._", | ||
"com.google.gson.JsonObject", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw. not directly related to that PR but when I was doing some changes in that class I was thinking if there's a reason we use GSON here and not some Scala specific library as it's a bit hard to work with sometimes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
H2O-3 already uses GSON for json parsing. (see https://github.com/h2oai/h2o-3/blob/879e58d3e5f98064b738189febecd845bf4f87c4/h2o-genmodel/src/main/java/hex/genmodel/ModelMojoReader.java). I think the main motivation why we didn't go for another lib was that GSON is already on driver and executor classpath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what I thought :) maybe (just maybe) we could consider json4s in the future if we ever have time for improvements as I see spark uses that
val h2oName = output.h2oName | ||
val swName = output.swName | ||
val value = output.dataType.getSimpleName match { | ||
case "boolean" => s"""outputSection.get("$h2oName").getAsBoolean()""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the outputSection...
prefix be extracted here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outputSection is not a prefix in all cases (see case "TwoDimTableV3")
Generated MOJO models (Scala):
H2OMOJOModelFactory.scala.txt
H2OGLRMMOJOModel.scala.txt
H2OPCAMOJOModel.scala.txt
H2OAutoEncoderMOJOModel.scala.txt
H2OIsolationForestMOJOModel.scala.txt
H2OCoxPHMOJOModel.scala.txt
H2OKMeansMOJOModel.scala.txt
H2ORuleFitMOJOModel.scala.txt
H2ODeepLearningMOJOModel.scala.txt
H2OGAMMOJOModel.scala.txt
H2OGLMMOJOModel.scala.txt
H2ODRFMOJOModel.scala.txt
H2OGBMMOJOModel.scala.txt
H2OXGBoostMOJOModel.scala.txt
Generated MOJO models (Python):
H2OGLRMMOJOModel.py.txt
H2OPCAMOJOModel.py.txt
H2OAutoEncoderMOJOModel.py.txt
H2OIsolationForestMOJOModel.py.txt
H2OCoxPHMOJOModel.py.txt
H2OKMeansMOJOModel.py.txt
H2ORuleFitMOJOModel.py.txt
H2ODeepLearningMOJOModel.py.txt
H2OGAMMOJOModel.py.txt
H2OGLMMOJOModel.py.txt
H2ODRFMOJOModel.py.txt
H2OGBMMOJOModel.py.txt
H2OXGBoostMOJOModel.py.txt
Generated doc files:
model_details_H2OGLRMMOJOModel.rst.txt
model_details_H2OPCAMOJOModel.rst.txt
model_details_H2OTargetEncoderMOJOModel.rst.txt
model_details_H2OAutoEncoderMOJOModel.rst.txt
model_details_H2OXGBoostMOJOModel.rst.txt
model_details_H2OGLMMOJOModel.rst.txt
model_details_H2OKMeansMOJOModel.rst.txt
model_details_H2ORuleFitMOJOModel.rst.txt
model_details_H2OGBMMOJOModel.rst.txt
model_details_H2ODeepLearningMOJOModel.rst.txt
model_details_H2OIsolationForestMOJOModel.rst.txt
model_details_H2OGAMMOJOModel.rst.txt
model_details_H2ODRFMOJOModel.rst.txt
model_details_H2OCoxPHMOJOModel.rst.txt
model_details.rst.txt