Skip to content

Commit 5ccfe02

Browse files
authored
handle coefficients as map (#57)
1 parent be2130d commit 5ccfe02

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>cloud.eppo</groupId>
88
<artifactId>eppo-server-sdk</artifactId>
9-
<version>2.4.5</version>
9+
<version>2.4.6</version>
1010

1111
<name>${project.groupId}:${project.artifactId}</name>
1212
<description>Eppo Server-Side SDK for Java</description>

src/main/java/com/eppo/sdk/deserializer/BanditsDeserializer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ public Map<String, BanditParameters> deserialize(
5353
JsonNode coefficientsNode = modelDataNode.get("coefficients");
5454

5555
Map<String, BanditCoefficients> coefficients = new HashMap<>();
56-
coefficientsNode.iterator().forEachRemaining(actionCoefficientsNode -> {
57-
BanditCoefficients actionCoefficients = this.parseActionCoefficientsNode(actionCoefficientsNode);
58-
coefficients.put(actionCoefficients.getActionKey(), actionCoefficients);
56+
Iterator<Map.Entry<String, JsonNode>> coefficientIterator = coefficientsNode.fields();
57+
coefficientIterator.forEachRemaining(field -> {
58+
BanditCoefficients actionCoefficients = this.parseActionCoefficientsNode(field.getValue());
59+
coefficients.put(field.getKey(), actionCoefficients);
5960
});
6061

6162
modelData.setCoefficients(coefficients);

src/test/resources/bandits/bandits-parameters-1.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"gamma": 1.0,
1111
"defaultActionScore": 0.0,
1212
"actionProbabilityFloor": 0.0,
13-
"coefficients": [
14-
{
13+
"coefficients": {
14+
"nike": {
1515
"actionKey": "nike",
1616
"intercept": 1.0,
1717
"actionNumericCoefficients": [
@@ -50,7 +50,7 @@
5050
}
5151
]
5252
},
53-
{
53+
"adidas": {
5454
"actionKey": "adidas",
5555
"intercept": 1.1,
5656
"actionNumericCoefficients": [
@@ -82,7 +82,7 @@
8282
}
8383
]
8484
}
85-
]
85+
}
8686
}
8787
},
8888
{
@@ -94,7 +94,7 @@
9494
"gamma": 1.0,
9595
"defaultActionScore": 0.0,
9696
"actionProbabilityFloor": 0.0,
97-
"coefficients": []
97+
"coefficients": {}
9898
}
9999
}
100100
]

0 commit comments

Comments
 (0)