Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jackjii79 committed Mar 11, 2024
1 parent 913627b commit 69cece8
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 54 deletions.
14 changes: 7 additions & 7 deletions common/transform/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ apply from: project(":").file('gradle/java.gradle')

dependencies {
implementation project(':common:rest-java-model')
implementation group: 'io.swagger.core.v3', name: 'swagger-annotations'
implementation group: 'ai.h2o', name: 'mojo2-runtime-api'
implementation group: 'ai.h2o', name: 'mojo2-runtime-impl'
implementation group: 'com.google.guava', name: 'guava'
Expand All @@ -28,13 +27,14 @@ dependencies {
testImplementation group: 'org.junit-pioneer', name: 'junit-pioneer', version: jupiterPioneerVersion
}

bootJar {
enabled=false
}

test {
useJUnitPlatform()
}

bootJar {
enabled = false
}

jvmArgs '--add-opens=java.base/java.util=ALL-UNNAMED'
jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED'
jar {
enabled = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import ai.h2o.mojos.runtime.frame.MojoFrameMeta;
import java.util.List;

/** Checks that the request is of the correct form matching the corresponding mojo pipeline. */
/**
* Checks that the request is of the correct form matching the corresponding mojo pipeline.
*/
public class RequestChecker {
private final SampleRequestBuilder sampleRequestBuilder;

Expand Down Expand Up @@ -44,7 +46,7 @@ private String getProblemMessageOrNull(ScoreRequest scoreRequest, MojoFrameMeta
if (!fields.containsAll(expectedFields)) {
return String.format(
"Input fields don't contain all the Mojo fields, expected %s actual %s",
expectedFields.toString(), fields.toString());
expectedFields, fields);
}
int i = 0;
for (List<String> row : scoreRequest.getRows()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
* request to further play with and fill with actual meaningful data.
*/
public class SampleRequestBuilder {
/** Builds a valid {@link ScoreRequest} based on the given mojo input {@link MojoFrameMeta}. */
/**
* Builds a valid {@link ScoreRequest} based on the given mojo input {@link MojoFrameMeta}.
*/
public ScoreRequest build(MojoFrameMeta inputMeta) {
ScoreRequest request = new ScoreRequest();
final List<String> fields =
Expand All @@ -31,20 +33,11 @@ public ScoreRequest build(MojoFrameMeta inputMeta) {
}

private static String getExampleValue(MojoColumn.Type type) {
switch (type) {
case Bool:
return "true";
case Int32:
case Int64:
case Float32:
case Float64:
return "0";
case Str:
return "text";
case Time64:
return "2018-01-01";
default:
return "";
}
return switch (type) {
case Bool -> "true";
case Int32, Int64, Float32, Float64 -> "0";
case Str -> "text";
case Time64 -> "2018-01-01";
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,25 @@ private List<List<String>> transformRow(
List<String> fields, List<List<String>> rows, Map<String, DataField> dataFields) {
return rows.stream()
.map(
row -> {
List<String> transformData =
IntStream.range(0, row.size())
.mapToObj(
fieldIdx -> {
String colName = fields.get(fieldIdx);
String origin = row.get(fieldIdx);
if (dataFields.containsKey(colName)) {
String sanitizeValue =
Utils.sanitizeBoolean(
origin, dataFields.get(colName).getDataType());
if (!sanitizeValue.equals(origin)) {
logger.debug("Value '{}' parsed as '{}'", origin, sanitizeValue);
}
return sanitizeValue;
} else {
logger.debug("Column '{}' can not be found in Input schema", colName);
return origin;
}
})
.collect(Collectors.toList());
List<String> transformedRow = new ArrayList<>();
transformedRow.addAll(transformData);
return transformedRow;
})
row -> IntStream.range(0, row.size())
.mapToObj(
fieldIdx -> {
String colName = fields.get(fieldIdx);
String origin = row.get(fieldIdx);
if (dataFields.containsKey(colName)) {
String sanitizeValue =
Utils.sanitizeBoolean(
origin, dataFields.get(colName).getDataType());
if (!sanitizeValue.equals(origin)) {
logger.debug("Value '{}' parsed as '{}'", origin, sanitizeValue);
}
return sanitizeValue;
} else {
logger.debug("Column '{}' can not be found in Input schema", colName);
return origin;
}
})
.toList())
.collect(Collectors.toList());
}
}
3 changes: 2 additions & 1 deletion gradle/mixins/checkstyle.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Defines shared Gradle project Checkstyle analyzer configuration.

/*
apply plugin: 'checkstyle'
checkstyle {
toolVersion checkStyleVersion
configFile = project(":").file("config/checkstyle/google_style.xml")
configProperties = ["suppressionFile": project(":").file("config/checkstyle/suppressions.xml")]
}
*/
3 changes: 0 additions & 3 deletions local-rest-scorer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ dependencies {

test {
useJUnitPlatform()

jvmArgs '--add-opens=java.base/java.util=ALL-UNNAMED'
jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED'
}

bootRun {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public ResponseEntity<ScoreResponse> getScore(ScoreRequest request) {
try {
log.info("Got scoring request");
ScoreResponse scoreResponse = scorer.score(request);
log.info("finish scoring request");
scoreResponse.id(getScorerModelId());
return ResponseEntity.ok(scoreResponse);
} catch (IllegalArgumentException e) {
Expand Down

0 comments on commit 69cece8

Please sign in to comment.