Skip to content

Commit

Permalink
Remove metrics mode configuration from metric config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Naman Nandan committed Apr 11, 2023
1 parent 49fdbd7 commit 0576bd4
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
import org.pytorch.serve.util.ConfigManager;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.composer.ComposerException;
import org.yaml.snakeyaml.constructor.Constructor;

public class MetricConfiguration {
private String mode;
private List<String> dimensions;

@SuppressWarnings("checkstyle:MemberName")
Expand All @@ -19,14 +17,6 @@ public class MetricConfiguration {
@SuppressWarnings("checkstyle:MemberName")
private MetricTypes model_metrics;

public void setMode(String mode) {
this.mode = mode;
}

public String getMode() {
return mode;
}

public void setDimensions(List<String> dimensions) {
this.dimensions = dimensions;
}
Expand Down Expand Up @@ -71,7 +61,6 @@ public static MetricConfiguration loadConfiguration(String configFilePath)
Yaml yaml = new Yaml(constructor);
FileInputStream inputStream = new FileInputStream(new File(configFilePath));
MetricConfiguration config = yaml.load(inputStream);
config.setMode(ConfigManager.getInstance().getMetricsMode());
config.validate();

return config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.pytorch.serve.metrics.configuration;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import org.pytorch.serve.util.ConfigManager;
Expand All @@ -17,8 +16,6 @@ public void testLoadValidConfiguration()
MetricConfiguration.loadConfiguration(
"src/test/resources/metrics/valid_configuration.yaml");

Assert.assertEquals(config.getMode(), "log");

Assert.assertEquals(
config.getDimensions(),
new ArrayList<String>(
Expand Down Expand Up @@ -81,8 +78,6 @@ public void testLoadValidConfigurationEmptyMetricDimensions()
MetricConfiguration.loadConfiguration(
"src/test/resources/metrics/valid_configuration_empty_metric_dimensions.yaml");

Assert.assertEquals(config.getMode(), "log");

Assert.assertEquals(config.getDimensions(), null);

Assert.assertEquals(config.getTs_metrics().getCounter().size(), 1);
Expand Down Expand Up @@ -127,12 +122,13 @@ public void testLoadInvalidConfigurationMissingMetricUnit() {
}

@Test
public void testLoadValidConfigurationModeEnvironmentVariable()
throws IOException, FileNotFoundException {
ConfigManager.getInstance().setProperty("metrics_mode", "test_metrics_mode");
MetricConfiguration config =
MetricConfiguration.loadConfiguration(
"src/test/resources/metrics/valid_configuration.yaml");
Assert.assertEquals(config.getMode(), "test_metrics_mode");
public void testMetricsModeConfiguration() {
ConfigManager configManager = ConfigManager.getInstance();
String existingMetricsModeConfiguration = configManager.getMetricsMode();
Assert.assertEquals(existingMetricsModeConfiguration, "log");
configManager.setProperty("metrics_mode", "test_metrics_mode");
Assert.assertEquals(configManager.getMetricsMode(), "test_metrics_mode");
// Restore original metrics mode configuration
configManager.setProperty("metrics_mode", existingMetricsModeConfiguration);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mode: log

dimensions:
- &model_name "ModelName"
- &model_version "ModelVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mode: log

dimensions:
- &model_name "ModelName"
- &model_version "ModelVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mode: log

dimensions:
- &model_name "ModelName"
- &model_version "ModelVersion"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mode: log

dimensions:
- &model_name "ModelName"
- &model_version "ModelVersion"
Expand Down
2 changes: 0 additions & 2 deletions ts/configs/metrics.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mode: log

dimensions:
- &model_name "ModelName"
- &model_version "ModelVersion"
Expand Down

0 comments on commit 0576bd4

Please sign in to comment.