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


##########
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:
   Sounds good. Thanks for the example.



##########
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:
   Sounds good. Thanks for the example.



-- 
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