From edd5fa253007ca7c9e62a80652e739e693029c16 Mon Sep 17 00:00:00 2001 From: Nikhil Kulkarni Date: Tue, 8 Aug 2023 20:05:22 +0000 Subject: [PATCH 1/3] Update snakeyaml version --- frontend/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/gradle.properties b/frontend/gradle.properties index 2590230cc1..c9f7d91936 100644 --- a/frontend/gradle.properties +++ b/frontend/gradle.properties @@ -8,7 +8,7 @@ slf4j_api_version=1.7.32 slf4j_log4j_version=2.17.1 testng_version=7.1.0 torchserve_sdk_version=0.0.5 -snakeyaml_version=1.31 +snakeyaml_version=2.1 grpc_version=1.50.0 protoc_version=3.18.0 lmax_disruptor_version=3.4.4 From 840dcafb147ce8c81c3bb43a1a557d57065a3ca5 Mon Sep 17 00:00:00 2001 From: Nikhil Kulkarni Date: Tue, 8 Aug 2023 21:09:13 +0000 Subject: [PATCH 2/3] User LoaderOptions in snakeyaml2 --- .../java/org/pytorch/serve/archive/utils/ArchiveUtils.java | 3 ++- .../serve/metrics/configuration/MetricConfiguration.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ArchiveUtils.java b/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ArchiveUtils.java index ff24e483e3..370763a6ae 100644 --- a/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ArchiveUtils.java +++ b/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ArchiveUtils.java @@ -21,6 +21,7 @@ import org.pytorch.serve.archive.DownloadArchiveException; import org.pytorch.serve.archive.model.InvalidModelException; import org.pytorch.serve.archive.s3.HttpUtils; +import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.error.YAMLException; @@ -47,7 +48,7 @@ public static T readFile(File file, Class type) public static T readYamlFile(File file, Class type) throws InvalidModelException, IOException { - Yaml yaml = new Yaml(new Constructor(type)); + Yaml yaml = new Yaml(new Constructor(type, new LoaderOptions())); try (Reader r = new InputStreamReader( Files.newInputStream(file.toPath()), StandardCharsets.UTF_8)) { diff --git a/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java b/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java index cb41a0d907..cf3c44cd5c 100644 --- a/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java +++ b/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java @@ -9,6 +9,7 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.composer.ComposerException; import org.yaml.snakeyaml.constructor.Constructor; +import org.yaml.snakeyaml.LoaderOptions; public class MetricConfiguration { private static final Logger logger = LoggerFactory.getLogger(MetricConfiguration.class); @@ -64,7 +65,7 @@ public void validate() { public static MetricConfiguration loadConfiguration(String configFilePath) throws FileNotFoundException, ComposerException, RuntimeException { - Constructor constructor = new Constructor(MetricConfiguration.class); + Constructor constructor = new Constructor(MetricConfiguration.class, new LoaderOptions()); Yaml yaml = new Yaml(constructor); FileInputStream inputStream = new FileInputStream(new File(configFilePath)); MetricConfiguration config = yaml.load(inputStream); From 119d8d3e116a37f5b9947f3fe42685af29da19be Mon Sep 17 00:00:00 2001 From: Nikhil Kulkarni Date: Tue, 8 Aug 2023 21:47:50 +0000 Subject: [PATCH 3/3] Run target formatJava --- .../serve/metrics/configuration/MetricConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java b/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java index cf3c44cd5c..12f4c8bd72 100644 --- a/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java +++ b/frontend/server/src/main/java/org/pytorch/serve/metrics/configuration/MetricConfiguration.java @@ -6,10 +6,10 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.composer.ComposerException; import org.yaml.snakeyaml.constructor.Constructor; -import org.yaml.snakeyaml.LoaderOptions; public class MetricConfiguration { private static final Logger logger = LoggerFactory.getLogger(MetricConfiguration.class);