forked from mlflow/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MLeap Flavor/Deployment mlflow#3: Java implementation of a scoring se…
…rver for SageMaker (mlflow#327) * Add SparkJava plugin * Change default port * Support multiple instances of SageMakerServer * Add SageMaker tests * Rename SageMakerServer >> ScoringServer and add new tests * New tests * Format code * Remove unused import * Format again * New test and artifact name update * Using jetty scoring server * Select random port * Port fixes * Add port number to start method * Use apache http for tests * pom versioning * More tests * Code formatting * Line removal * Format again * Format code, address comments * Format code, docs * Add stream parsing test, fix other test asserts * Import fix * Add CSV to predictor error test * Fix test * Fix test, format code * Remove abstractions for testing sys env reading * Fixes * Address comments
- Loading branch information
Showing
10 changed files
with
656 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
mlflow/java/src/main/java/org/mlflow/sagemaker/DataFrame.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
mlflow/java/src/main/java/org/mlflow/sagemaker/Predictor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package org.mlflow.sagemaker; | ||
|
||
|
||
/** | ||
* A generic predictor object that provides a uniform interface for model inference. By extending | ||
* {@link org.mlflow.sagemaker.Predictor}, models of a specific flavor can expose their inference | ||
* routines for use by generic tools, such as model containers | ||
*/ | ||
public abstract class Predictor { | ||
/** Performs inference on the specified input and produces a result */ | ||
protected abstract DataFrame predict(DataFrame input) throws PredictorEvaluationException; | ||
protected abstract PredictorDataWrapper predict(PredictorDataWrapper input) | ||
throws PredictorEvaluationException; | ||
} |
47 changes: 47 additions & 0 deletions
47
mlflow/java/src/main/java/org/mlflow/sagemaker/PredictorDataWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.mlflow.sagemaker; | ||
|
||
/** Input/output data representation for use by {@link org.mlflow.sagemaker.Predictor} objects */ | ||
public class PredictorDataWrapper { | ||
public enum ContentType { | ||
Json, | ||
Csv | ||
} | ||
|
||
private final String content; | ||
private final ContentType contentType; | ||
|
||
/** Constructs a PredictorDataWrapper */ | ||
public PredictorDataWrapper(String content, ContentType contentType) { | ||
this.content = content; | ||
this.contentType = contentType; | ||
} | ||
|
||
/** @return The type of content contained in the wrapper (JSON, CSV, etc.) */ | ||
ContentType getContentType() { | ||
return this.contentType; | ||
} | ||
|
||
/** | ||
* Produces a JSON string representation of the PredictorDataWrapper | ||
* | ||
* @return A string in JSON format | ||
*/ | ||
String toJson() { | ||
if (this.contentType == ContentType.Json) { | ||
return this.content; | ||
} else { | ||
throw new UnsupportedOperationException( | ||
"Converting a data wrapper of a non-JSON content type to JSON is not yet supported."); | ||
} | ||
} | ||
|
||
/** | ||
* Produces a CSV string representation of the PredictorDataWrapper | ||
* | ||
* @return A string in CSV format | ||
*/ | ||
String toCsv() { | ||
throw new UnsupportedOperationException( | ||
"Converting a data wrapper to CSV is not yet supported."); | ||
} | ||
} |
Oops, something went wrong.