nextmv 0.26.3__py3-none-any.whl → 0.28.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nextmv/__about__.py +1 -1
- nextmv/__entrypoint__.py +3 -5
- nextmv/__init__.py +1 -0
- nextmv/base_model.py +52 -7
- nextmv/cloud/__init__.py +3 -0
- nextmv/cloud/acceptance_test.py +711 -20
- nextmv/cloud/account.py +152 -7
- nextmv/cloud/application.py +1231 -396
- nextmv/cloud/batch_experiment.py +133 -21
- nextmv/cloud/client.py +240 -46
- nextmv/cloud/input_set.py +96 -3
- nextmv/cloud/instance.py +89 -3
- nextmv/cloud/manifest.py +625 -87
- nextmv/cloud/package.py +2 -2
- nextmv/cloud/run.py +376 -45
- nextmv/cloud/safe.py +7 -7
- nextmv/cloud/scenario.py +205 -20
- nextmv/cloud/secrets.py +179 -6
- nextmv/cloud/status.py +95 -2
- nextmv/cloud/version.py +132 -4
- nextmv/deprecated.py +36 -2
- nextmv/input.py +300 -82
- nextmv/logger.py +71 -7
- nextmv/model.py +225 -58
- nextmv/options.py +301 -69
- nextmv/output.py +667 -236
- {nextmv-0.26.3.dist-info → nextmv-0.28.0.dist-info}/METADATA +1 -1
- nextmv-0.28.0.dist-info/RECORD +30 -0
- nextmv-0.26.3.dist-info/RECORD +0 -30
- {nextmv-0.26.3.dist-info → nextmv-0.28.0.dist-info}/WHEEL +0 -0
- {nextmv-0.26.3.dist-info → nextmv-0.28.0.dist-info}/licenses/LICENSE +0 -0
nextmv/cloud/acceptance_test.py
CHANGED
|
@@ -1,4 +1,45 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""
|
|
2
|
+
Definitions for acceptance tests in the Nextmv Cloud platform.
|
|
3
|
+
|
|
4
|
+
This module provides classes and enumerations for working with acceptance tests
|
|
5
|
+
in the Nextmv Cloud platform. Acceptance tests are used to compare the performance
|
|
6
|
+
of different versions of an app against a set of metrics.
|
|
7
|
+
|
|
8
|
+
Classes
|
|
9
|
+
-------
|
|
10
|
+
MetricType : Enum
|
|
11
|
+
Type of metric when doing a comparison.
|
|
12
|
+
StatisticType : Enum
|
|
13
|
+
Type of statistical process for collapsing multiple values of a metric.
|
|
14
|
+
Comparison : Enum
|
|
15
|
+
Comparison operators to use for comparing two metrics.
|
|
16
|
+
ToleranceType : Enum
|
|
17
|
+
Type of tolerance used for a metric.
|
|
18
|
+
ExperimentStatus : Enum
|
|
19
|
+
Status of an acceptance test experiment.
|
|
20
|
+
MetricTolerance : BaseModel
|
|
21
|
+
Tolerance used for a metric in an acceptance test.
|
|
22
|
+
MetricParams : BaseModel
|
|
23
|
+
Parameters of a metric comparison in an acceptance test.
|
|
24
|
+
Metric : BaseModel
|
|
25
|
+
A metric used to evaluate the performance of a test.
|
|
26
|
+
ComparisonInstance : BaseModel
|
|
27
|
+
An app instance used for a comparison in an acceptance test.
|
|
28
|
+
DistributionSummaryStatistics : BaseModel
|
|
29
|
+
Statistics of a distribution summary for metric results.
|
|
30
|
+
DistributionPercentiles : BaseModel
|
|
31
|
+
Percentiles of a metric value distribution.
|
|
32
|
+
ResultStatistics : BaseModel
|
|
33
|
+
Statistics of a single instance's metric results.
|
|
34
|
+
MetricStatistics : BaseModel
|
|
35
|
+
Statistics of a metric comparing control and candidate instances.
|
|
36
|
+
MetricResult : BaseModel
|
|
37
|
+
Result of a metric evaluation in an acceptance test.
|
|
38
|
+
AcceptanceTestResults : BaseModel
|
|
39
|
+
Results of an acceptance test.
|
|
40
|
+
AcceptanceTest : BaseModel
|
|
41
|
+
An acceptance test for evaluating app instances.
|
|
42
|
+
"""
|
|
2
43
|
|
|
3
44
|
from datetime import datetime
|
|
4
45
|
from enum import Enum
|
|
@@ -8,7 +49,30 @@ from nextmv.base_model import BaseModel
|
|
|
8
49
|
|
|
9
50
|
|
|
10
51
|
class MetricType(str, Enum):
|
|
11
|
-
"""
|
|
52
|
+
"""
|
|
53
|
+
Type of metric when doing a comparison.
|
|
54
|
+
|
|
55
|
+
You can import the `MetricType` class directly from `cloud`:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from nextmv.cloud import MetricType
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This enumeration defines the different types of metrics that can be used
|
|
62
|
+
when comparing two runs in an acceptance test.
|
|
63
|
+
|
|
64
|
+
Attributes
|
|
65
|
+
----------
|
|
66
|
+
direct_comparison : str
|
|
67
|
+
Direct comparison between metric values.
|
|
68
|
+
|
|
69
|
+
Examples
|
|
70
|
+
--------
|
|
71
|
+
>>> from nextmv.cloud import MetricType
|
|
72
|
+
>>> metric_type = MetricType.direct_comparison
|
|
73
|
+
>>> metric_type
|
|
74
|
+
<MetricType.direct_comparison: 'direct-comparison'>
|
|
75
|
+
"""
|
|
12
76
|
|
|
13
77
|
direct_comparison = "direct-comparison"
|
|
14
78
|
"""Direct comparison metric type."""
|
|
@@ -16,8 +80,55 @@ class MetricType(str, Enum):
|
|
|
16
80
|
|
|
17
81
|
class StatisticType(str, Enum):
|
|
18
82
|
"""
|
|
19
|
-
Type of statistical process for collapsing multiple values of a metric
|
|
20
|
-
|
|
83
|
+
Type of statistical process for collapsing multiple values of a metric.
|
|
84
|
+
|
|
85
|
+
You can import the `StatisticType` class directly from `cloud`:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from nextmv.cloud import StatisticType
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
This enumeration defines the different statistical methods that can be used
|
|
92
|
+
to summarize multiple values of a metric from multiple runs into a single
|
|
93
|
+
value.
|
|
94
|
+
|
|
95
|
+
Attributes
|
|
96
|
+
----------
|
|
97
|
+
min : str
|
|
98
|
+
Minimum value.
|
|
99
|
+
max : str
|
|
100
|
+
Maximum value.
|
|
101
|
+
mean : str
|
|
102
|
+
Mean value.
|
|
103
|
+
std : str
|
|
104
|
+
Standard deviation.
|
|
105
|
+
shifted_geometric_mean : str
|
|
106
|
+
Shifted geometric mean.
|
|
107
|
+
p01 : str
|
|
108
|
+
1st percentile.
|
|
109
|
+
p05 : str
|
|
110
|
+
5th percentile.
|
|
111
|
+
p10 : str
|
|
112
|
+
10th percentile.
|
|
113
|
+
p25 : str
|
|
114
|
+
25th percentile.
|
|
115
|
+
p50 : str
|
|
116
|
+
50th percentile (median).
|
|
117
|
+
p75 : str
|
|
118
|
+
75th percentile.
|
|
119
|
+
p90 : str
|
|
120
|
+
90th percentile.
|
|
121
|
+
p95 : str
|
|
122
|
+
95th percentile.
|
|
123
|
+
p99 : str
|
|
124
|
+
99th percentile.
|
|
125
|
+
|
|
126
|
+
Examples
|
|
127
|
+
--------
|
|
128
|
+
>>> from nextmv.cloud import StatisticType
|
|
129
|
+
>>> stat_type = StatisticType.mean
|
|
130
|
+
>>> stat_type
|
|
131
|
+
<StatisticType.mean: 'mean'>
|
|
21
132
|
"""
|
|
22
133
|
|
|
23
134
|
min = "min"
|
|
@@ -51,7 +162,40 @@ class StatisticType(str, Enum):
|
|
|
51
162
|
|
|
52
163
|
|
|
53
164
|
class Comparison(str, Enum):
|
|
54
|
-
"""
|
|
165
|
+
"""
|
|
166
|
+
Comparison operators to use for comparing two metrics.
|
|
167
|
+
|
|
168
|
+
You can import the `Comparison` class directly from `cloud`:
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from nextmv.cloud import Comparison
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This enumeration defines the different comparison operators that can be used
|
|
175
|
+
to compare two metric values in an acceptance test.
|
|
176
|
+
|
|
177
|
+
Attributes
|
|
178
|
+
----------
|
|
179
|
+
equal_to : str
|
|
180
|
+
Equal to operator (==).
|
|
181
|
+
greater_than : str
|
|
182
|
+
Greater than operator (>).
|
|
183
|
+
greater_than_or_equal_to : str
|
|
184
|
+
Greater than or equal to operator (>=).
|
|
185
|
+
less_than : str
|
|
186
|
+
Less than operator (<).
|
|
187
|
+
less_than_or_equal_to : str
|
|
188
|
+
Less than or equal to operator (<=).
|
|
189
|
+
not_equal_to : str
|
|
190
|
+
Not equal to operator (!=).
|
|
191
|
+
|
|
192
|
+
Examples
|
|
193
|
+
--------
|
|
194
|
+
>>> from nextmv.cloud import Comparison
|
|
195
|
+
>>> op = Comparison.greater_than
|
|
196
|
+
>>> op
|
|
197
|
+
<Comparison.greater_than: 'gt'>
|
|
198
|
+
"""
|
|
55
199
|
|
|
56
200
|
equal_to = "eq"
|
|
57
201
|
"""Equal to metric type."""
|
|
@@ -68,7 +212,34 @@ class Comparison(str, Enum):
|
|
|
68
212
|
|
|
69
213
|
|
|
70
214
|
class ToleranceType(str, Enum):
|
|
71
|
-
"""
|
|
215
|
+
"""
|
|
216
|
+
Type of tolerance used for a metric.
|
|
217
|
+
|
|
218
|
+
You can import the `ToleranceType` class directly from `cloud`:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from nextmv.cloud import ToleranceType
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
This enumeration defines the different types of tolerances that can be used
|
|
225
|
+
when comparing metrics in acceptance tests.
|
|
226
|
+
|
|
227
|
+
Attributes
|
|
228
|
+
----------
|
|
229
|
+
undefined : str
|
|
230
|
+
Undefined tolerance type (empty string).
|
|
231
|
+
absolute : str
|
|
232
|
+
Absolute tolerance type, using a fixed value.
|
|
233
|
+
relative : str
|
|
234
|
+
Relative tolerance type, using a percentage.
|
|
235
|
+
|
|
236
|
+
Examples
|
|
237
|
+
--------
|
|
238
|
+
>>> from nextmv.cloud import ToleranceType
|
|
239
|
+
>>> tol_type = ToleranceType.absolute
|
|
240
|
+
>>> tol_type
|
|
241
|
+
<ToleranceType.absolute: 'absolute'>
|
|
242
|
+
"""
|
|
72
243
|
|
|
73
244
|
undefined = ""
|
|
74
245
|
"""Undefined tolerance type."""
|
|
@@ -79,7 +250,40 @@ class ToleranceType(str, Enum):
|
|
|
79
250
|
|
|
80
251
|
|
|
81
252
|
class ExperimentStatus(str, Enum):
|
|
82
|
-
"""
|
|
253
|
+
"""
|
|
254
|
+
Status of an acceptance test experiment.
|
|
255
|
+
|
|
256
|
+
You can import the `ExperimentStatus` class directly from `cloud`:
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from nextmv.cloud import ExperimentStatus
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
This enumeration defines the different possible statuses of an experiment
|
|
263
|
+
underlying an acceptance test.
|
|
264
|
+
|
|
265
|
+
Attributes
|
|
266
|
+
----------
|
|
267
|
+
started : str
|
|
268
|
+
The experiment has started.
|
|
269
|
+
completed : str
|
|
270
|
+
The experiment was completed successfully.
|
|
271
|
+
failed : str
|
|
272
|
+
The experiment failed.
|
|
273
|
+
draft : str
|
|
274
|
+
The experiment is a draft.
|
|
275
|
+
canceled : str
|
|
276
|
+
The experiment was canceled.
|
|
277
|
+
unknown : str
|
|
278
|
+
The experiment status is unknown.
|
|
279
|
+
|
|
280
|
+
Examples
|
|
281
|
+
--------
|
|
282
|
+
>>> from nextmv.cloud import ExperimentStatus
|
|
283
|
+
>>> status = ExperimentStatus.completed
|
|
284
|
+
>>> status
|
|
285
|
+
<ExperimentStatus.completed: 'completed'>
|
|
286
|
+
"""
|
|
83
287
|
|
|
84
288
|
started = "started"
|
|
85
289
|
"""The experiment has started."""
|
|
@@ -96,7 +300,34 @@ class ExperimentStatus(str, Enum):
|
|
|
96
300
|
|
|
97
301
|
|
|
98
302
|
class MetricTolerance(BaseModel):
|
|
99
|
-
"""
|
|
303
|
+
"""
|
|
304
|
+
Tolerance used for a metric in an acceptance test.
|
|
305
|
+
|
|
306
|
+
You can import the `MetricTolerance` class directly from `cloud`:
|
|
307
|
+
|
|
308
|
+
```python
|
|
309
|
+
from nextmv.cloud import MetricTolerance
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
This class defines the tolerance to be applied when comparing metric values,
|
|
313
|
+
which can be either absolute or relative.
|
|
314
|
+
|
|
315
|
+
Attributes
|
|
316
|
+
----------
|
|
317
|
+
type : ToleranceType
|
|
318
|
+
Type of tolerance (absolute or relative).
|
|
319
|
+
value : float
|
|
320
|
+
Value of the tolerance.
|
|
321
|
+
|
|
322
|
+
Examples
|
|
323
|
+
--------
|
|
324
|
+
>>> from nextmv.cloud import MetricTolerance, ToleranceType
|
|
325
|
+
>>> tolerance = MetricTolerance(type=ToleranceType.absolute, value=0.1)
|
|
326
|
+
>>> tolerance.type
|
|
327
|
+
<ToleranceType.absolute: 'absolute'>
|
|
328
|
+
>>> tolerance.value
|
|
329
|
+
0.1
|
|
330
|
+
"""
|
|
100
331
|
|
|
101
332
|
type: ToleranceType
|
|
102
333
|
"""Type of tolerance."""
|
|
@@ -105,7 +336,35 @@ class MetricTolerance(BaseModel):
|
|
|
105
336
|
|
|
106
337
|
|
|
107
338
|
class MetricParams(BaseModel):
|
|
108
|
-
"""
|
|
339
|
+
"""
|
|
340
|
+
Parameters of a metric comparison in an acceptance test.
|
|
341
|
+
|
|
342
|
+
You can import the `MetricParams` class directly from `cloud`:
|
|
343
|
+
|
|
344
|
+
```python
|
|
345
|
+
from nextmv.cloud import MetricParams
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
This class defines the parameters used for comparing metric values,
|
|
349
|
+
including the comparison operator and tolerance.
|
|
350
|
+
|
|
351
|
+
Attributes
|
|
352
|
+
----------
|
|
353
|
+
operator : Comparison
|
|
354
|
+
Operator used to compare two metrics (e.g., greater than, less than).
|
|
355
|
+
tolerance : MetricTolerance
|
|
356
|
+
Tolerance used for the comparison.
|
|
357
|
+
|
|
358
|
+
Examples
|
|
359
|
+
--------
|
|
360
|
+
>>> from nextmv.cloud import MetricParams, Comparison, MetricTolerance, ToleranceType
|
|
361
|
+
>>> params = MetricParams(
|
|
362
|
+
... operator=Comparison.less_than,
|
|
363
|
+
... tolerance=MetricTolerance(type=ToleranceType.absolute, value=0.5)
|
|
364
|
+
... )
|
|
365
|
+
>>> params.operator
|
|
366
|
+
<Comparison.less_than: 'lt'>
|
|
367
|
+
"""
|
|
109
368
|
|
|
110
369
|
operator: Comparison
|
|
111
370
|
"""Operator used to compare two metrics."""
|
|
@@ -114,8 +373,51 @@ class MetricParams(BaseModel):
|
|
|
114
373
|
|
|
115
374
|
|
|
116
375
|
class Metric(BaseModel):
|
|
117
|
-
"""
|
|
118
|
-
performance of a test.
|
|
376
|
+
"""
|
|
377
|
+
A metric used to evaluate the performance of a test.
|
|
378
|
+
|
|
379
|
+
You can import the `Metric` class directly from `cloud`:
|
|
380
|
+
|
|
381
|
+
```python
|
|
382
|
+
from nextmv.cloud import Metric
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
A metric is a key performance indicator that is used to evaluate the
|
|
386
|
+
performance of a test. It defines the field to measure, the type of
|
|
387
|
+
comparison, and the statistical method to use.
|
|
388
|
+
|
|
389
|
+
Attributes
|
|
390
|
+
----------
|
|
391
|
+
field : str
|
|
392
|
+
Field of the metric to measure (e.g., "solution.objective").
|
|
393
|
+
metric_type : MetricType
|
|
394
|
+
Type of the metric comparison.
|
|
395
|
+
params : MetricParams
|
|
396
|
+
Parameters of the metric comparison.
|
|
397
|
+
statistic : StatisticType
|
|
398
|
+
Type of statistical process for collapsing multiple values into a single value.
|
|
399
|
+
|
|
400
|
+
Examples
|
|
401
|
+
--------
|
|
402
|
+
>>> from nextmv.cloud import (
|
|
403
|
+
... Metric, MetricType, MetricParams, Comparison,
|
|
404
|
+
... MetricTolerance, ToleranceType, StatisticType
|
|
405
|
+
... )
|
|
406
|
+
>>> metric = Metric(
|
|
407
|
+
... field="solution.objective",
|
|
408
|
+
... metric_type=MetricType.direct_comparison,
|
|
409
|
+
... params=MetricParams(
|
|
410
|
+
... operator=Comparison.less_than,
|
|
411
|
+
... tolerance=MetricTolerance(
|
|
412
|
+
... type=ToleranceType.relative,
|
|
413
|
+
... value=0.05
|
|
414
|
+
... )
|
|
415
|
+
... ),
|
|
416
|
+
... statistic=StatisticType.mean
|
|
417
|
+
... )
|
|
418
|
+
>>> metric.field
|
|
419
|
+
'solution.objective'
|
|
420
|
+
"""
|
|
119
421
|
|
|
120
422
|
field: str
|
|
121
423
|
"""Field of the metric."""
|
|
@@ -131,7 +433,37 @@ class Metric(BaseModel):
|
|
|
131
433
|
|
|
132
434
|
|
|
133
435
|
class ComparisonInstance(BaseModel):
|
|
134
|
-
"""
|
|
436
|
+
"""
|
|
437
|
+
An app instance used for a comparison in an acceptance test.
|
|
438
|
+
|
|
439
|
+
You can import the `ComparisonInstance` class directly from `cloud`:
|
|
440
|
+
|
|
441
|
+
```python
|
|
442
|
+
from nextmv.cloud import ComparisonInstance
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
This class represents an app instance used in a comparison,
|
|
446
|
+
identifying both the instance and its version.
|
|
447
|
+
|
|
448
|
+
Attributes
|
|
449
|
+
----------
|
|
450
|
+
instance_id : str
|
|
451
|
+
ID of the instance.
|
|
452
|
+
version_id : str
|
|
453
|
+
ID of the version.
|
|
454
|
+
|
|
455
|
+
Examples
|
|
456
|
+
--------
|
|
457
|
+
>>> from nextmv.cloud import ComparisonInstance
|
|
458
|
+
>>> instance = ComparisonInstance(
|
|
459
|
+
... instance_id="instance-123",
|
|
460
|
+
... version_id="version-456"
|
|
461
|
+
... )
|
|
462
|
+
>>> instance.instance_id
|
|
463
|
+
'instance-123'
|
|
464
|
+
>>> instance.version_id
|
|
465
|
+
'version-456'
|
|
466
|
+
"""
|
|
135
467
|
|
|
136
468
|
instance_id: str
|
|
137
469
|
"""ID of the instance."""
|
|
@@ -140,7 +472,52 @@ class ComparisonInstance(BaseModel):
|
|
|
140
472
|
|
|
141
473
|
|
|
142
474
|
class DistributionSummaryStatistics(BaseModel):
|
|
143
|
-
"""
|
|
475
|
+
"""
|
|
476
|
+
Statistics of a distribution summary for metric results.
|
|
477
|
+
|
|
478
|
+
You can import the `DistributionSummaryStatistics` class directly from `cloud`:
|
|
479
|
+
|
|
480
|
+
```python
|
|
481
|
+
from nextmv.cloud import DistributionSummaryStatistics
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
This class contains statistical measures summarizing the distribution of
|
|
485
|
+
metric values across multiple runs.
|
|
486
|
+
|
|
487
|
+
Attributes
|
|
488
|
+
----------
|
|
489
|
+
min : float
|
|
490
|
+
Minimum value in the distribution.
|
|
491
|
+
max : float
|
|
492
|
+
Maximum value in the distribution.
|
|
493
|
+
count : int
|
|
494
|
+
Count of runs in the distribution.
|
|
495
|
+
mean : float
|
|
496
|
+
Mean value of the distribution.
|
|
497
|
+
std : float
|
|
498
|
+
Standard deviation of the distribution.
|
|
499
|
+
shifted_geometric_mean : float
|
|
500
|
+
Shifted geometric mean of the distribution.
|
|
501
|
+
shift_parameter : float
|
|
502
|
+
Shift parameter used for the geometric mean calculation.
|
|
503
|
+
|
|
504
|
+
Examples
|
|
505
|
+
--------
|
|
506
|
+
>>> from nextmv.cloud import DistributionSummaryStatistics
|
|
507
|
+
>>> stats = DistributionSummaryStatistics(
|
|
508
|
+
... min=10.0,
|
|
509
|
+
... max=20.0,
|
|
510
|
+
... count=5,
|
|
511
|
+
... mean=15.0,
|
|
512
|
+
... std=4.0,
|
|
513
|
+
... shifted_geometric_mean=14.5,
|
|
514
|
+
... shift_parameter=1.0
|
|
515
|
+
... )
|
|
516
|
+
>>> stats.mean
|
|
517
|
+
15.0
|
|
518
|
+
>>> stats.count
|
|
519
|
+
5
|
|
520
|
+
"""
|
|
144
521
|
|
|
145
522
|
min: float
|
|
146
523
|
"""Minimum value."""
|
|
@@ -159,7 +536,56 @@ class DistributionSummaryStatistics(BaseModel):
|
|
|
159
536
|
|
|
160
537
|
|
|
161
538
|
class DistributionPercentiles(BaseModel):
|
|
162
|
-
"""
|
|
539
|
+
"""
|
|
540
|
+
Percentiles of a metric value distribution.
|
|
541
|
+
|
|
542
|
+
You can import the `DistributionPercentiles` class directly from `cloud`:
|
|
543
|
+
|
|
544
|
+
```python
|
|
545
|
+
from nextmv.cloud import DistributionPercentiles
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
This class contains the different percentiles of a distribution of metric values
|
|
549
|
+
across multiple runs.
|
|
550
|
+
|
|
551
|
+
Attributes
|
|
552
|
+
----------
|
|
553
|
+
p01 : float
|
|
554
|
+
1st percentile of the distribution.
|
|
555
|
+
p05 : float
|
|
556
|
+
5th percentile of the distribution.
|
|
557
|
+
p10 : float
|
|
558
|
+
10th percentile of the distribution.
|
|
559
|
+
p25 : float
|
|
560
|
+
25th percentile of the distribution.
|
|
561
|
+
p50 : float
|
|
562
|
+
50th percentile of the distribution (median).
|
|
563
|
+
p75 : float
|
|
564
|
+
75th percentile of the distribution.
|
|
565
|
+
p90 : float
|
|
566
|
+
90th percentile of the distribution.
|
|
567
|
+
p95 : float
|
|
568
|
+
95th percentile of the distribution.
|
|
569
|
+
p99 : float
|
|
570
|
+
99th percentile of the distribution.
|
|
571
|
+
|
|
572
|
+
Examples
|
|
573
|
+
--------
|
|
574
|
+
>>> from nextmv.cloud import DistributionPercentiles
|
|
575
|
+
>>> percentiles = DistributionPercentiles(
|
|
576
|
+
... p01=10.0,
|
|
577
|
+
... p05=12.0,
|
|
578
|
+
... p10=13.0,
|
|
579
|
+
... p25=14.0,
|
|
580
|
+
... p50=15.0,
|
|
581
|
+
... p75=16.0,
|
|
582
|
+
... p90=17.0,
|
|
583
|
+
... p95=18.0,
|
|
584
|
+
... p99=19.0
|
|
585
|
+
... )
|
|
586
|
+
>>> percentiles.p50 # median
|
|
587
|
+
15.0
|
|
588
|
+
"""
|
|
163
589
|
|
|
164
590
|
p01: float
|
|
165
591
|
"""1st percentile."""
|
|
@@ -182,7 +608,64 @@ class DistributionPercentiles(BaseModel):
|
|
|
182
608
|
|
|
183
609
|
|
|
184
610
|
class ResultStatistics(BaseModel):
|
|
185
|
-
"""
|
|
611
|
+
"""
|
|
612
|
+
Statistics of a single instance's metric results.
|
|
613
|
+
|
|
614
|
+
You can import the `ResultStatistics` class directly from `cloud`:
|
|
615
|
+
|
|
616
|
+
```python
|
|
617
|
+
from nextmv.cloud import ResultStatistics
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
This class aggregates the statistical information about the metric results
|
|
621
|
+
for a specific instance in a comparison.
|
|
622
|
+
|
|
623
|
+
Attributes
|
|
624
|
+
----------
|
|
625
|
+
instance_id : str
|
|
626
|
+
ID of the instance.
|
|
627
|
+
version_id : str
|
|
628
|
+
ID of the version.
|
|
629
|
+
number_of_runs_total : int
|
|
630
|
+
Total number of runs included in the statistics.
|
|
631
|
+
distribution_summary_statistics : DistributionSummaryStatistics
|
|
632
|
+
Summary statistics of the metric value distribution.
|
|
633
|
+
distribution_percentiles : DistributionPercentiles
|
|
634
|
+
Percentiles of the metric value distribution.
|
|
635
|
+
|
|
636
|
+
Examples
|
|
637
|
+
--------
|
|
638
|
+
>>> from nextmv.cloud import (
|
|
639
|
+
... ResultStatistics, DistributionSummaryStatistics, DistributionPercentiles
|
|
640
|
+
... )
|
|
641
|
+
>>> result_stats = ResultStatistics(
|
|
642
|
+
... instance_id="instance-123",
|
|
643
|
+
... version_id="version-456",
|
|
644
|
+
... number_of_runs_total=10,
|
|
645
|
+
... distribution_summary_statistics=DistributionSummaryStatistics(
|
|
646
|
+
... min=10.0,
|
|
647
|
+
... max=20.0,
|
|
648
|
+
... count=10,
|
|
649
|
+
... mean=15.0,
|
|
650
|
+
... std=3.0,
|
|
651
|
+
... shifted_geometric_mean=14.5,
|
|
652
|
+
... shift_parameter=1.0
|
|
653
|
+
... ),
|
|
654
|
+
... distribution_percentiles=DistributionPercentiles(
|
|
655
|
+
... p01=10.5,
|
|
656
|
+
... p05=11.0,
|
|
657
|
+
... p10=12.0,
|
|
658
|
+
... p25=13.5,
|
|
659
|
+
... p50=15.0,
|
|
660
|
+
... p75=16.5,
|
|
661
|
+
... p90=18.0,
|
|
662
|
+
... p95=19.0,
|
|
663
|
+
... p99=19.5
|
|
664
|
+
... )
|
|
665
|
+
... )
|
|
666
|
+
>>> result_stats.number_of_runs_total
|
|
667
|
+
10
|
|
668
|
+
"""
|
|
186
669
|
|
|
187
670
|
instance_id: str
|
|
188
671
|
"""ID of the instance."""
|
|
@@ -197,7 +680,62 @@ class ResultStatistics(BaseModel):
|
|
|
197
680
|
|
|
198
681
|
|
|
199
682
|
class MetricStatistics(BaseModel):
|
|
200
|
-
"""
|
|
683
|
+
"""
|
|
684
|
+
Statistics of a metric comparing control and candidate instances.
|
|
685
|
+
|
|
686
|
+
You can import the `MetricStatistics` class directly from `cloud`:
|
|
687
|
+
|
|
688
|
+
```python
|
|
689
|
+
from nextmv.cloud import MetricStatistics
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
This class holds the statistical information for both the control and candidate
|
|
693
|
+
instances being compared in the acceptance test.
|
|
694
|
+
|
|
695
|
+
Attributes
|
|
696
|
+
----------
|
|
697
|
+
control : ResultStatistics
|
|
698
|
+
Statistics for the control instance.
|
|
699
|
+
candidate : ResultStatistics
|
|
700
|
+
Statistics for the candidate instance.
|
|
701
|
+
|
|
702
|
+
Examples
|
|
703
|
+
--------
|
|
704
|
+
>>> from nextmv.cloud import (
|
|
705
|
+
... MetricStatistics, ResultStatistics,
|
|
706
|
+
... DistributionSummaryStatistics, DistributionPercentiles
|
|
707
|
+
... )
|
|
708
|
+
>>> stats = MetricStatistics(
|
|
709
|
+
... control=ResultStatistics(
|
|
710
|
+
... instance_id="control-instance",
|
|
711
|
+
... version_id="control-version",
|
|
712
|
+
... number_of_runs_total=10,
|
|
713
|
+
... distribution_summary_statistics=DistributionSummaryStatistics(
|
|
714
|
+
... min=10.0, max=20.0, count=10, mean=15.0, std=3.0,
|
|
715
|
+
... shifted_geometric_mean=14.5, shift_parameter=1.0
|
|
716
|
+
... ),
|
|
717
|
+
... distribution_percentiles=DistributionPercentiles(
|
|
718
|
+
... p01=10.5, p05=11.0, p10=12.0, p25=13.5, p50=15.0,
|
|
719
|
+
... p75=16.5, p90=18.0, p95=19.0, p99=19.5
|
|
720
|
+
... )
|
|
721
|
+
... ),
|
|
722
|
+
... candidate=ResultStatistics(
|
|
723
|
+
... instance_id="candidate-instance",
|
|
724
|
+
... version_id="candidate-version",
|
|
725
|
+
... number_of_runs_total=10,
|
|
726
|
+
... distribution_summary_statistics=DistributionSummaryStatistics(
|
|
727
|
+
... min=9.0, max=18.0, count=10, mean=13.0, std=2.5,
|
|
728
|
+
... shifted_geometric_mean=12.8, shift_parameter=1.0
|
|
729
|
+
... ),
|
|
730
|
+
... distribution_percentiles=DistributionPercentiles(
|
|
731
|
+
... p01=9.5, p05=10.0, p10=11.0, p25=12.0, p50=13.0,
|
|
732
|
+
... p75=14.0, p90=15.5, p95=16.5, p99=17.5
|
|
733
|
+
... )
|
|
734
|
+
... )
|
|
735
|
+
... )
|
|
736
|
+
>>> stats.control.mean > stats.candidate.mean
|
|
737
|
+
True
|
|
738
|
+
"""
|
|
201
739
|
|
|
202
740
|
control: ResultStatistics
|
|
203
741
|
"""Control statistics."""
|
|
@@ -206,7 +744,53 @@ class MetricStatistics(BaseModel):
|
|
|
206
744
|
|
|
207
745
|
|
|
208
746
|
class MetricResult(BaseModel):
|
|
209
|
-
"""
|
|
747
|
+
"""
|
|
748
|
+
Result of a metric evaluation in an acceptance test.
|
|
749
|
+
|
|
750
|
+
You can import the `MetricResult` class directly from `cloud`:
|
|
751
|
+
|
|
752
|
+
```python
|
|
753
|
+
from nextmv.cloud import MetricResult
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
This class represents the result of evaluating a specific metric in an
|
|
757
|
+
acceptance test, including whether the candidate passed according to this metric.
|
|
758
|
+
|
|
759
|
+
Attributes
|
|
760
|
+
----------
|
|
761
|
+
metric : Metric
|
|
762
|
+
The metric that was evaluated.
|
|
763
|
+
statistics : MetricStatistics
|
|
764
|
+
Statistics comparing control and candidate instances for this metric.
|
|
765
|
+
passed : bool
|
|
766
|
+
Whether the candidate passed for this metric.
|
|
767
|
+
|
|
768
|
+
Examples
|
|
769
|
+
--------
|
|
770
|
+
>>> from nextmv.cloud import (
|
|
771
|
+
... MetricResult, Metric, MetricType, MetricParams, Comparison,
|
|
772
|
+
... MetricTolerance, ToleranceType, StatisticType, MetricStatistics
|
|
773
|
+
... )
|
|
774
|
+
>>> # Assume we have statistics object already created
|
|
775
|
+
>>> result = MetricResult(
|
|
776
|
+
... metric=Metric(
|
|
777
|
+
... field="solution.objective",
|
|
778
|
+
... metric_type=MetricType.direct_comparison,
|
|
779
|
+
... params=MetricParams(
|
|
780
|
+
... operator=Comparison.less_than,
|
|
781
|
+
... tolerance=MetricTolerance(
|
|
782
|
+
... type=ToleranceType.relative,
|
|
783
|
+
... value=0.05
|
|
784
|
+
... )
|
|
785
|
+
... ),
|
|
786
|
+
... statistic=StatisticType.mean
|
|
787
|
+
... ),
|
|
788
|
+
... statistics=statistics, # previously created statistics object
|
|
789
|
+
... passed=True
|
|
790
|
+
... )
|
|
791
|
+
>>> result.passed
|
|
792
|
+
True
|
|
793
|
+
"""
|
|
210
794
|
|
|
211
795
|
metric: Metric
|
|
212
796
|
"""Metric of the result."""
|
|
@@ -217,7 +801,48 @@ class MetricResult(BaseModel):
|
|
|
217
801
|
|
|
218
802
|
|
|
219
803
|
class AcceptanceTestResults(BaseModel):
|
|
220
|
-
"""
|
|
804
|
+
"""
|
|
805
|
+
Results of an acceptance test.
|
|
806
|
+
|
|
807
|
+
You can import the `AcceptanceTestResults` class directly from `cloud`:
|
|
808
|
+
|
|
809
|
+
```python
|
|
810
|
+
from nextmv.cloud import AcceptanceTestResults
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
This class contains the overall results of an acceptance test, including
|
|
814
|
+
whether the test passed and detailed results for each metric.
|
|
815
|
+
|
|
816
|
+
Attributes
|
|
817
|
+
----------
|
|
818
|
+
passed : bool
|
|
819
|
+
Whether the acceptance test passed overall.
|
|
820
|
+
metric_results : list[MetricResult], optional
|
|
821
|
+
Results for each metric in the test.
|
|
822
|
+
error : str, optional
|
|
823
|
+
Error message if the acceptance test failed.
|
|
824
|
+
|
|
825
|
+
Examples
|
|
826
|
+
--------
|
|
827
|
+
>>> from nextmv.cloud import AcceptanceTestResults
|
|
828
|
+
>>> # Assume metric_results is a list of MetricResult objects
|
|
829
|
+
>>> results = AcceptanceTestResults(
|
|
830
|
+
... passed=True,
|
|
831
|
+
... metric_results=metric_results # previously created list of results
|
|
832
|
+
... )
|
|
833
|
+
>>> results.passed
|
|
834
|
+
True
|
|
835
|
+
>>>
|
|
836
|
+
>>> # Example with error
|
|
837
|
+
>>> error_results = AcceptanceTestResults(
|
|
838
|
+
... passed=False,
|
|
839
|
+
... error="Experiment failed to complete"
|
|
840
|
+
... )
|
|
841
|
+
>>> error_results.passed
|
|
842
|
+
False
|
|
843
|
+
>>> error_results.error
|
|
844
|
+
'Experiment failed to complete'
|
|
845
|
+
"""
|
|
221
846
|
|
|
222
847
|
passed: bool
|
|
223
848
|
"""Whether the acceptance test passed (or not)."""
|
|
@@ -228,8 +853,74 @@ class AcceptanceTestResults(BaseModel):
|
|
|
228
853
|
|
|
229
854
|
|
|
230
855
|
class AcceptanceTest(BaseModel):
|
|
231
|
-
"""
|
|
232
|
-
|
|
856
|
+
"""
|
|
857
|
+
An acceptance test for evaluating app instances.
|
|
858
|
+
|
|
859
|
+
You can import the `AcceptanceTest` class directly from `cloud`:
|
|
860
|
+
|
|
861
|
+
```python
|
|
862
|
+
from nextmv.cloud import AcceptanceTest
|
|
863
|
+
```
|
|
864
|
+
|
|
865
|
+
An acceptance test gives a go/no-go decision criteria for a set of
|
|
866
|
+
metrics. It relies on a batch experiment to compare a candidate app instance
|
|
867
|
+
against a control app instance.
|
|
868
|
+
|
|
869
|
+
Attributes
|
|
870
|
+
----------
|
|
871
|
+
id : str
|
|
872
|
+
ID of the acceptance test.
|
|
873
|
+
name : str
|
|
874
|
+
Name of the acceptance test.
|
|
875
|
+
description : str
|
|
876
|
+
Description of the acceptance test.
|
|
877
|
+
app_id : str
|
|
878
|
+
ID of the app that owns the acceptance test.
|
|
879
|
+
experiment_id : str
|
|
880
|
+
ID of the batch experiment underlying the acceptance test.
|
|
881
|
+
control : ComparisonInstance
|
|
882
|
+
Control instance of the acceptance test.
|
|
883
|
+
candidate : ComparisonInstance
|
|
884
|
+
Candidate instance of the acceptance test.
|
|
885
|
+
metrics : list[Metric]
|
|
886
|
+
Metrics to evaluate in the acceptance test.
|
|
887
|
+
created_at : datetime
|
|
888
|
+
Creation date of the acceptance test.
|
|
889
|
+
updated_at : datetime
|
|
890
|
+
Last update date of the acceptance test.
|
|
891
|
+
status : ExperimentStatus, optional
|
|
892
|
+
Status of the acceptance test.
|
|
893
|
+
results : AcceptanceTestResults, optional
|
|
894
|
+
Results of the acceptance test.
|
|
895
|
+
|
|
896
|
+
Examples
|
|
897
|
+
--------
|
|
898
|
+
>>> from nextmv.cloud import (
|
|
899
|
+
... AcceptanceTest, ComparisonInstance, Metric, ExperimentStatus
|
|
900
|
+
... )
|
|
901
|
+
>>> from datetime import datetime
|
|
902
|
+
>>> test = AcceptanceTest(
|
|
903
|
+
... id="test-123",
|
|
904
|
+
... name="Performance acceptance test",
|
|
905
|
+
... description="Testing performance improvements",
|
|
906
|
+
... app_id="app-456",
|
|
907
|
+
... experiment_id="exp-789",
|
|
908
|
+
... control=ComparisonInstance(
|
|
909
|
+
... instance_id="control-instance",
|
|
910
|
+
... version_id="control-version"
|
|
911
|
+
... ),
|
|
912
|
+
... candidate=ComparisonInstance(
|
|
913
|
+
... instance_id="candidate-instance",
|
|
914
|
+
... version_id="candidate-version"
|
|
915
|
+
... ),
|
|
916
|
+
... metrics=[metric1, metric2], # previously created metrics
|
|
917
|
+
... created_at=datetime.now(),
|
|
918
|
+
... updated_at=datetime.now(),
|
|
919
|
+
... status=ExperimentStatus.started
|
|
920
|
+
... )
|
|
921
|
+
>>> test.status
|
|
922
|
+
<ExperimentStatus.started: 'started'>
|
|
923
|
+
"""
|
|
233
924
|
|
|
234
925
|
id: str
|
|
235
926
|
"""ID of the acceptance test."""
|