|
1 | 1 | package ml.comet.experiment.impl; |
2 | 2 |
|
3 | 3 | import ml.comet.experiment.ApiExperiment; |
| 4 | +import ml.comet.experiment.ExperimentBuilder; |
4 | 5 | import ml.comet.experiment.OnlineExperiment; |
5 | 6 | import ml.comet.experiment.asset.LoggedExperimentAsset; |
6 | 7 | import ml.comet.experiment.context.ExperimentContext; |
@@ -129,25 +130,33 @@ public void testLogCurve() throws Exception { |
129 | 130 |
|
130 | 131 | @Test |
131 | 132 | public void testLogCurveOverwrite() throws Exception { |
| 133 | + String experimentKey; |
| 134 | + String fileName = "someCurve"; |
| 135 | + int pointsCount = 10; |
| 136 | + long size; |
132 | 137 | try (ApiExperiment apiExperiment = createApiExperiment()) { |
133 | | - String fileName = "someCurve"; |
134 | | - int pointsCount = 10; |
135 | 138 | Curve curve = createCurve(fileName, pointsCount); |
136 | 139 | apiExperiment.logCurve(curve, false, SOME_FULL_CONTEXT); |
137 | 140 |
|
138 | 141 | // check that CURVE asset was saved as expected |
139 | 142 | List<LoggedExperimentAsset> assets = apiExperiment.getAssetList(CURVE.type()); |
140 | 143 | assertEquals(1, assets.size(), "wrong number of assets returned"); |
141 | 144 |
|
142 | | - long size = assets.get(0).getSize().orElse((long) -1); |
| 145 | + size = assets.get(0).getSize().orElse((long) -1); |
143 | 146 | assertTrue(size > 0, "wrong asset size"); |
144 | 147 |
|
| 148 | + experimentKey = apiExperiment.getExperimentKey(); |
| 149 | + } |
| 150 | + |
| 151 | + // create new experiment and overwrite curve |
| 152 | + try (ApiExperiment apiExperiment = ExperimentBuilder.ApiExperiment() |
| 153 | + .withExistingExperimentKey(experimentKey).withApiKey(API_KEY).build()) { |
145 | 154 | // overwrite created curve with bigger ones |
146 | 155 | // |
147 | | - curve = createCurve(fileName, pointsCount * 2); |
| 156 | + Curve curve = createCurve(fileName, pointsCount * 2); |
148 | 157 | apiExperiment.logCurve(curve, true, SOME_FULL_CONTEXT); |
149 | 158 |
|
150 | | - assets = apiExperiment.getAssetList(CURVE.type()); |
| 159 | + List<LoggedExperimentAsset> assets = apiExperiment.getAssetList(CURVE.type()); |
151 | 160 | assertEquals(1, assets.size(), "wrong number of assets returned"); |
152 | 161 |
|
153 | 162 | long newSize = assets.get(0).getSize().orElse((long) -1); |
|
0 commit comments