Skip to content

Conversation

anjalisood
Copy link
Contributor

No description provided.

val protocol = getProtocol(marSavePath)

if ("file".equalsIgnoreCase(protocol)) {
print("Local")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove or enhance these prints (or log)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the debug statements

jarFileList = jarFileList ::: List(new File(modelSrcDir.toString))
}
else {
print("not local")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

* @return The protocol for the given source.
*/
def getProtocol(source: String): String = {
require(source != null, "marfile source must not be null")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for empty as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

def getProtocol(source: String): String = {
require(source != null, "marfile source must not be null")

var protocol: String = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make protocol a val and assign to the try statement directly

catch {
case ex: Exception =>
if (source.startsWith("//")) {
throw new IllegalArgumentException("Relative context: " + source)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Relative context" - not sure how that message helps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it to: "Does not support Relative context: " + source

result = file.toURI.toURL.getProtocol
}
catch {
case ex: Exception => result = "unknown"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this catch and return "unknown" --this mean you've go to have logic somewhere else to make sense of it. It's stronger to let the exception run free or at least have this method return a Try object.

val protocol = ScoringModelUtils.getProtocol(storagePath)

if ("file".equalsIgnoreCase(protocol)) {
print("Local")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improve print message.

Does this really mean local? What about s3? --does it fall under local or hdsf? Could provide more help in making the right set of options, besides local and hdfs?

Also, this reveals to me that the protocol/path work you've added above is not unique to ScoringModelUtils, but more generally to sparktk saveload. That logic should move to this more generic location. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants