yunfengzhou-hub commented on a change in pull request #71:
URL: https://github.com/apache/flink-ml/pull/71#discussion_r840329681
##########
File path:
flink-ml-core/src/main/java/org/apache/flink/ml/util/ReadWriteUtils.java
##########
@@ -94,25 +95,29 @@
*/
public static void saveMetadata(Stage<?> stage, String path, Map<String,
?> extraMetadata)
throws IOException {
- // Creates parent directories if not already created.
- FileSystem fs = mkdirs(path);
-
Map<String, Object> metadata = new HashMap<>(extraMetadata);
metadata.put("className", stage.getClass().getName());
metadata.put("timestamp", System.currentTimeMillis());
metadata.put("paramMap", jsonEncode(stage.getParamMap()));
// TODO: add version in the metadata.
String metadataStr = OBJECT_MAPPER.writeValueAsString(metadata);
- Path metadataPath = new Path(path, "metadata");
- if (fs.exists(metadataPath)) {
- throw new IOException("File " + metadataPath + " already exists.");
+ saveToFile(new Path(path, "metadata"), metadataStr);
+ }
+
+ /** Saves a given string to the specified file. */
+ public static void saveToFile(Path path, String content) throws
IOException {
+ // Creates parent directories if not already created.
+ FileSystem fs = mkdirs(path.getParent().toString());
+
+ if (fs.exists(path)) {
+ throw new IOException("File " + path + " already exists.");
Review comment:
Shall we just overwrite the file when saving the benchmark results, or
also overwrite the files when saving Stages?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]