jiangxin369 commented on code in PR #193:
URL: https://github.com/apache/flink-ml/pull/193#discussion_r1062159232


##########
flink-ml-benchmark/src/test/java/org/apache/flink/ml/benchmark/BenchmarkTest.java:
##########
@@ -54,6 +60,44 @@ public void testParseJsonFile() throws Exception {
         assertTrue(benchmarks.containsKey("KMeansModel-1"));
     }
 
+    @Test
+    public void testJsonFileLegality() throws IOException, 
ClassNotFoundException {
+        File resourcesDir =

Review Comment:
   Sure.



##########
flink-ml-benchmark/src/test/java/org/apache/flink/ml/benchmark/BenchmarkTest.java:
##########
@@ -54,6 +60,44 @@ public void testParseJsonFile() throws Exception {
         assertTrue(benchmarks.containsKey("KMeansModel-1"));
     }
 
+    @Test
+    public void testJsonFileLegality() throws IOException, 
ClassNotFoundException {
+        File resourcesDir =
+                new File(
+                                this.getClass()
+                                        .getClassLoader()
+                                        .getResource("benchmark-demo.json")
+                                        .getPath())
+                        .getParentFile();
+        File[] jsonFiles =
+                resourcesDir.listFiles(
+                        (dir, name) ->
+                                name.endsWith(".json") && 
!name.equals("benchmark-demo.json"));
+
+        for (File file : jsonFiles) {
+            Map<String, Map<String, Map<String, ?>>> benchmarks =
+                    BenchmarkUtils.parseJsonFile(file.getAbsolutePath());
+            for (Map<String, Map<String, ?>> params : benchmarks.values()) {
+                assertTrue(
+                        Arrays.asList("stage", "inputData", "modelData")
+                                .containsAll(params.keySet()));
+
+                WithParams stage = 
ReadWriteUtils.instantiateWithParams(params.get("stage"));
+                assertTrue(stage instanceof Stage);

Review Comment:
   Using `instanceOf` gives a clearer error message if someone writes an 
incorrect class in json file, instead of `ClassCastException`. The approach in 
`BenchmarkUtils#runBenchmark` has no warning because of the `@SuppressWarnings` 
annotation, I can add this annotation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to