nextmv 1.0.0.dev5__py3-none-any.whl → 1.0.0.dev7__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/_serialization.py +1 -1
- nextmv/cli/cloud/acceptance/create.py +12 -12
- nextmv/cli/cloud/app/push.py +15 -15
- nextmv/cli/cloud/input_set/__init__.py +2 -0
- nextmv/cli/cloud/input_set/delete.py +67 -0
- nextmv/cli/cloud/run/create.py +4 -9
- nextmv/cli/cloud/shadow/stop.py +14 -2
- nextmv/cli/cloud/switchback/stop.py +14 -2
- nextmv/cli/community/clone.py +11 -197
- nextmv/cli/community/list.py +46 -116
- nextmv/cloud/__init__.py +4 -0
- nextmv/cloud/application/__init__.py +1 -200
- nextmv/cloud/application/_acceptance.py +13 -8
- nextmv/cloud/application/_input_set.py +42 -6
- nextmv/cloud/application/_run.py +1 -8
- nextmv/cloud/application/_shadow.py +9 -3
- nextmv/cloud/application/_switchback.py +11 -2
- nextmv/cloud/batch_experiment.py +3 -1
- nextmv/cloud/client.py +1 -1
- nextmv/cloud/community.py +441 -0
- nextmv/cloud/integration.py +7 -4
- nextmv/cloud/shadow.py +25 -0
- nextmv/cloud/switchback.py +2 -0
- nextmv/default_app/main.py +6 -4
- nextmv/local/executor.py +3 -83
- nextmv/local/geojson_handler.py +1 -1
- nextmv/manifest.py +7 -11
- nextmv/model.py +2 -2
- nextmv/options.py +1 -1
- nextmv/output.py +21 -57
- nextmv/run.py +3 -12
- {nextmv-1.0.0.dev5.dist-info → nextmv-1.0.0.dev7.dist-info}/METADATA +3 -1
- {nextmv-1.0.0.dev5.dist-info → nextmv-1.0.0.dev7.dist-info}/RECORD +37 -35
- {nextmv-1.0.0.dev5.dist-info → nextmv-1.0.0.dev7.dist-info}/WHEEL +0 -0
- {nextmv-1.0.0.dev5.dist-info → nextmv-1.0.0.dev7.dist-info}/entry_points.txt +0 -0
- {nextmv-1.0.0.dev5.dist-info → nextmv-1.0.0.dev7.dist-info}/licenses/LICENSE +0 -0
nextmv/cloud/shadow.py
CHANGED
|
@@ -19,6 +19,7 @@ ShadowTest
|
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
21
|
from datetime import datetime
|
|
22
|
+
from enum import Enum
|
|
22
23
|
from typing import Any
|
|
23
24
|
|
|
24
25
|
from pydantic import AliasChoices, Field
|
|
@@ -227,3 +228,27 @@ class ShadowTest(BaseModel):
|
|
|
227
228
|
"""Grouped distributional summaries of the shadow test."""
|
|
228
229
|
runs: list[Run] | None = None
|
|
229
230
|
"""List of runs in the shadow test."""
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class StopIntent(str, Enum):
|
|
234
|
+
"""
|
|
235
|
+
Intent for stopping a shadow test.
|
|
236
|
+
|
|
237
|
+
You can import the `StopIntent` class directly from `cloud`:
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
from nextmv.cloud import StopIntent
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Attributes
|
|
244
|
+
----------
|
|
245
|
+
complete : str
|
|
246
|
+
The test is marked as complete.
|
|
247
|
+
cancel : str
|
|
248
|
+
The test is canceled.
|
|
249
|
+
"""
|
|
250
|
+
|
|
251
|
+
complete = "complete"
|
|
252
|
+
"""The test is marked as complete."""
|
|
253
|
+
cancel = "cancel"
|
|
254
|
+
"""The test is canceled."""
|
nextmv/cloud/switchback.py
CHANGED
|
@@ -45,6 +45,8 @@ class TestComparisonSingle(BaseModel):
|
|
|
45
45
|
ID of the candidate instance for comparison.
|
|
46
46
|
"""
|
|
47
47
|
|
|
48
|
+
__test__ = False # Prevents pytest from collecting this class as a test case
|
|
49
|
+
|
|
48
50
|
baseline_instance_id: str
|
|
49
51
|
"""ID of the baseline instance for comparison."""
|
|
50
52
|
candidate_instance_id: str
|
nextmv/default_app/main.py
CHANGED
|
@@ -26,10 +26,12 @@ assets = create_visuals(name, input.data["radius"], input.data["distance"])
|
|
|
26
26
|
output = nextmv.Output(
|
|
27
27
|
options=options,
|
|
28
28
|
solution={"message": message},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
statistics=nextmv.Statistics(
|
|
30
|
+
result=nextmv.ResultStatistics(
|
|
31
|
+
value=1.23,
|
|
32
|
+
custom={"message": message},
|
|
33
|
+
),
|
|
34
|
+
),
|
|
33
35
|
assets=assets,
|
|
34
36
|
)
|
|
35
37
|
nextmv.write(output)
|
nextmv/local/executor.py
CHANGED
|
@@ -22,8 +22,6 @@ process_run_information
|
|
|
22
22
|
Function to update run metadata including duration and status.
|
|
23
23
|
process_run_logs
|
|
24
24
|
Function to process and save run logs.
|
|
25
|
-
process_run_metrics
|
|
26
|
-
Function to process and save run metrics.
|
|
27
25
|
process_run_statistics
|
|
28
26
|
Function to process and save run statistics.
|
|
29
27
|
process_run_assets
|
|
@@ -59,16 +57,7 @@ from nextmv.local.local import (
|
|
|
59
57
|
)
|
|
60
58
|
from nextmv.local.plotly_handler import handle_plotly_visual
|
|
61
59
|
from nextmv.manifest import Manifest, ManifestType
|
|
62
|
-
from nextmv.output import
|
|
63
|
-
ASSETS_KEY,
|
|
64
|
-
METRICS_KEY,
|
|
65
|
-
OUTPUTS_KEY,
|
|
66
|
-
SOLUTIONS_KEY,
|
|
67
|
-
STATISTICS_KEY,
|
|
68
|
-
Asset,
|
|
69
|
-
OutputFormat,
|
|
70
|
-
VisualSchema,
|
|
71
|
-
)
|
|
60
|
+
from nextmv.output import ASSETS_KEY, OUTPUTS_KEY, SOLUTIONS_KEY, STATISTICS_KEY, Asset, OutputFormat, VisualSchema
|
|
72
61
|
from nextmv.status import StatusV2
|
|
73
62
|
|
|
74
63
|
|
|
@@ -316,7 +305,7 @@ def process_run_output(
|
|
|
316
305
|
) -> None:
|
|
317
306
|
"""
|
|
318
307
|
Processes the result of the subprocess run. This function is in charge of
|
|
319
|
-
handling the run results, including solutions, statistics,
|
|
308
|
+
handling the run results, including solutions, statistics, logs, assets,
|
|
320
309
|
and visuals.
|
|
321
310
|
|
|
322
311
|
Parameters
|
|
@@ -358,13 +347,6 @@ def process_run_output(
|
|
|
358
347
|
result=result,
|
|
359
348
|
stdout_output=stdout_output,
|
|
360
349
|
)
|
|
361
|
-
process_run_metrics(
|
|
362
|
-
temp_run_outputs_dir=temp_run_outputs_dir,
|
|
363
|
-
outputs_dir=outputs_dir,
|
|
364
|
-
stdout_output=stdout_output,
|
|
365
|
-
temp_src=temp_src,
|
|
366
|
-
manifest=manifest,
|
|
367
|
-
)
|
|
368
350
|
process_run_statistics(
|
|
369
351
|
temp_run_outputs_dir=temp_run_outputs_dir,
|
|
370
352
|
outputs_dir=outputs_dir,
|
|
@@ -517,65 +499,6 @@ def process_run_logs(
|
|
|
517
499
|
|
|
518
500
|
f.write(std_err)
|
|
519
501
|
|
|
520
|
-
def process_run_metrics(
|
|
521
|
-
temp_run_outputs_dir: str,
|
|
522
|
-
outputs_dir: str,
|
|
523
|
-
stdout_output: str | dict[str, Any],
|
|
524
|
-
temp_src: str,
|
|
525
|
-
manifest: Manifest,
|
|
526
|
-
) -> None:
|
|
527
|
-
"""
|
|
528
|
-
Processes the metrics of the run. Checks for an outputs/metrics folder
|
|
529
|
-
or custom metrics file location from manifest. If found, copies to run
|
|
530
|
-
directory. Otherwise, attempts to extract metrics from stdout.
|
|
531
|
-
|
|
532
|
-
Parameters
|
|
533
|
-
----------
|
|
534
|
-
temp_run_outputs_dir : str
|
|
535
|
-
The path to the temporary outputs directory.
|
|
536
|
-
outputs_dir : str
|
|
537
|
-
The path to the outputs directory in the run directory.
|
|
538
|
-
stdout_output : Union[str, dict[str, Any]]
|
|
539
|
-
The stdout output of the run, either as raw string or parsed dictionary.
|
|
540
|
-
temp_src : str
|
|
541
|
-
The path to the temporary source directory.
|
|
542
|
-
manifest : Manifest
|
|
543
|
-
The application manifest containing configuration and custom paths.
|
|
544
|
-
"""
|
|
545
|
-
|
|
546
|
-
metrics_dst = os.path.join(outputs_dir, METRICS_KEY)
|
|
547
|
-
os.makedirs(metrics_dst, exist_ok=True)
|
|
548
|
-
metrics_file = f"{METRICS_KEY}.json"
|
|
549
|
-
|
|
550
|
-
# Check for custom location in manifest and override metrics_src if needed.
|
|
551
|
-
if (
|
|
552
|
-
manifest.configuration is not None
|
|
553
|
-
and manifest.configuration.content is not None
|
|
554
|
-
and manifest.configuration.content.format == OutputFormat.MULTI_FILE
|
|
555
|
-
and manifest.configuration.content.multi_file is not None
|
|
556
|
-
):
|
|
557
|
-
metrics_src_file = os.path.join(temp_src, manifest.configuration.content.multi_file.output.metrics)
|
|
558
|
-
|
|
559
|
-
# If the custom metrics file exists, copy it to the metrics destination
|
|
560
|
-
if os.path.exists(metrics_src_file) and os.path.isfile(metrics_src_file):
|
|
561
|
-
metrics_dst_file = os.path.join(metrics_dst, metrics_file)
|
|
562
|
-
shutil.copy2(metrics_src_file, metrics_dst_file)
|
|
563
|
-
return
|
|
564
|
-
|
|
565
|
-
metrics_src = os.path.join(temp_run_outputs_dir, METRICS_KEY)
|
|
566
|
-
if os.path.exists(metrics_src) and os.path.isdir(metrics_src):
|
|
567
|
-
shutil.copytree(metrics_src, metrics_dst, dirs_exist_ok=True)
|
|
568
|
-
return
|
|
569
|
-
|
|
570
|
-
if not isinstance(stdout_output, dict):
|
|
571
|
-
return
|
|
572
|
-
|
|
573
|
-
if METRICS_KEY not in stdout_output:
|
|
574
|
-
return
|
|
575
|
-
|
|
576
|
-
with open(os.path.join(metrics_dst, metrics_file), "w") as f:
|
|
577
|
-
metrics = {METRICS_KEY: stdout_output[METRICS_KEY]}
|
|
578
|
-
json.dump(metrics, f, indent=2)
|
|
579
502
|
|
|
580
503
|
def process_run_statistics(
|
|
581
504
|
temp_run_outputs_dir: str,
|
|
@@ -585,9 +508,6 @@ def process_run_statistics(
|
|
|
585
508
|
manifest: Manifest,
|
|
586
509
|
) -> None:
|
|
587
510
|
"""
|
|
588
|
-
!!! warning
|
|
589
|
-
`process_run_statistics` is deprecated, use `process_run_metrics` instead.
|
|
590
|
-
|
|
591
511
|
Processes the statistics of the run. Checks for an outputs/statistics folder
|
|
592
512
|
or custom statistics file location from manifest. If found, copies to run
|
|
593
513
|
directory. Otherwise, attempts to extract statistics from stdout.
|
|
@@ -928,7 +848,7 @@ def _copy_new_or_modified_files( # noqa: C901
|
|
|
928
848
|
This function identifies files that are either new (not present in the original
|
|
929
849
|
source) or have been modified (different content, checksum, or modification time)
|
|
930
850
|
compared to the original source. It excludes files that exist in specified
|
|
931
|
-
exclusion directories to avoid copying input data, statistics,
|
|
851
|
+
exclusion directories to avoid copying input data, statistics, or assets as
|
|
932
852
|
solution outputs.
|
|
933
853
|
|
|
934
854
|
Parameters
|
nextmv/local/geojson_handler.py
CHANGED
|
@@ -111,7 +111,7 @@ def extract_coordinates(coords, all_coords) -> None:
|
|
|
111
111
|
like Polygons and MultiPolygons
|
|
112
112
|
"""
|
|
113
113
|
if isinstance(coords, list):
|
|
114
|
-
if len(coords) == 2 and isinstance(coords[0], int
|
|
114
|
+
if len(coords) == 2 and isinstance(coords[0], (int, float)) and isinstance(coords[1], (int, float)):
|
|
115
115
|
# This is a coordinate pair [lon, lat]
|
|
116
116
|
all_coords.append(coords)
|
|
117
117
|
else:
|
nextmv/manifest.py
CHANGED
|
@@ -829,9 +829,7 @@ class ManifestContentMultiFileOutput(BaseModel):
|
|
|
829
829
|
Parameters
|
|
830
830
|
----------
|
|
831
831
|
statistics : Optional[str], default=""
|
|
832
|
-
|
|
833
|
-
metrics : Optional[str], default=""
|
|
834
|
-
The path to the metrics file.
|
|
832
|
+
The path to the statistics file.
|
|
835
833
|
assets : Optional[str], default=""
|
|
836
834
|
The path to the assets file.
|
|
837
835
|
solutions : Optional[str], default=""
|
|
@@ -841,18 +839,16 @@ class ManifestContentMultiFileOutput(BaseModel):
|
|
|
841
839
|
--------
|
|
842
840
|
>>> from nextmv import ManifestContentMultiFileOutput
|
|
843
841
|
>>> output_config = ManifestContentMultiFileOutput(
|
|
844
|
-
...
|
|
842
|
+
... statistics="my-outputs/statistics.json",
|
|
845
843
|
... assets="my-outputs/assets.json",
|
|
846
844
|
... solutions="my-outputs/solutions/"
|
|
847
845
|
... )
|
|
848
|
-
>>> output_config.
|
|
849
|
-
'my-outputs/
|
|
846
|
+
>>> output_config.statistics
|
|
847
|
+
'my-outputs/statistics.json'
|
|
850
848
|
"""
|
|
851
849
|
|
|
852
850
|
statistics: str | None = ""
|
|
853
|
-
"""
|
|
854
|
-
metrics: str | None = ""
|
|
855
|
-
"""The path to the metrics file."""
|
|
851
|
+
"""The path to the statistics file."""
|
|
856
852
|
assets: str | None = ""
|
|
857
853
|
"""The path to the assets file."""
|
|
858
854
|
solutions: str | None = ""
|
|
@@ -882,7 +878,7 @@ class ManifestContentMultiFile(BaseModel):
|
|
|
882
878
|
>>> multi_file_config = ManifestContentMultiFile(
|
|
883
879
|
... input=ManifestContentMultiFileInput(path="data/input/"),
|
|
884
880
|
... output=ManifestContentMultiFileOutput(
|
|
885
|
-
...
|
|
881
|
+
... statistics="my-outputs/statistics.json",
|
|
886
882
|
... assets="my-outputs/assets.json",
|
|
887
883
|
... solutions="my-outputs/solutions/"
|
|
888
884
|
... )
|
|
@@ -923,7 +919,7 @@ class ManifestContent(BaseModel):
|
|
|
923
919
|
... multi_file=ManifestContentMultiFile(
|
|
924
920
|
... input=ManifestContentMultiFileInput(path="data/input/"),
|
|
925
921
|
... output=ManifestContentMultiFileOutput(
|
|
926
|
-
...
|
|
922
|
+
... statistics="my-outputs/statistics.json",
|
|
927
923
|
... assets="my-outputs/assets.json",
|
|
928
924
|
... solutions="my-outputs/solutions/"
|
|
929
925
|
... )
|
nextmv/model.py
CHANGED
|
@@ -195,7 +195,7 @@ class Model:
|
|
|
195
195
|
... return nextmv.Output(
|
|
196
196
|
... options=input.options,
|
|
197
197
|
... solution=nextroute_output.solutions[0].to_dict(),
|
|
198
|
-
...
|
|
198
|
+
... statistics=nextroute_output.statistics.to_dict(),
|
|
199
199
|
... )
|
|
200
200
|
"""
|
|
201
201
|
|
|
@@ -234,7 +234,7 @@ class Model:
|
|
|
234
234
|
... return Output(
|
|
235
235
|
... options=input.options,
|
|
236
236
|
... solution=result,
|
|
237
|
-
...
|
|
237
|
+
... statistics={"processing_time": 0.5}
|
|
238
238
|
... )
|
|
239
239
|
"""
|
|
240
240
|
|
nextmv/options.py
CHANGED
nextmv/output.py
CHANGED
|
@@ -8,9 +8,9 @@ destinations.
|
|
|
8
8
|
Classes
|
|
9
9
|
-------
|
|
10
10
|
RunStatistics
|
|
11
|
-
|
|
11
|
+
Statistics about a general run.
|
|
12
12
|
ResultStatistics
|
|
13
|
-
|
|
13
|
+
Statistics about a specific result.
|
|
14
14
|
DataPoint
|
|
15
15
|
A data point representing a 2D coordinate.
|
|
16
16
|
Series
|
|
@@ -18,10 +18,7 @@ Series
|
|
|
18
18
|
SeriesData
|
|
19
19
|
Data container for multiple series of data points.
|
|
20
20
|
Statistics
|
|
21
|
-
|
|
22
|
-
solution, including run metrics and result data.
|
|
23
|
-
Metrics
|
|
24
|
-
Metrics container for a solution.
|
|
21
|
+
Complete statistics container for a solution, including run metrics and result data.
|
|
25
22
|
OutputFormat
|
|
26
23
|
Enumeration of supported output formats.
|
|
27
24
|
SolutionFile
|
|
@@ -49,9 +46,7 @@ Attributes
|
|
|
49
46
|
ASSETS_KEY : str
|
|
50
47
|
Assets key constant used for identifying assets in the run output.
|
|
51
48
|
STATISTICS_KEY : str
|
|
52
|
-
|
|
53
|
-
METRICS_KEY : str
|
|
54
|
-
Metrics key constant used for identifying metrics in the run output.
|
|
49
|
+
Statistics key constant used for identifying statistics in the run output.
|
|
55
50
|
SOLUTIONS_KEY : str
|
|
56
51
|
Solutions key constant used for identifying solutions in the run output.
|
|
57
52
|
OUTPUTS_KEY : str
|
|
@@ -80,11 +75,7 @@ Assets key constant used for identifying assets in the run output.
|
|
|
80
75
|
"""
|
|
81
76
|
STATISTICS_KEY = "statistics"
|
|
82
77
|
"""
|
|
83
|
-
|
|
84
|
-
"""
|
|
85
|
-
METRICS_KEY = "metrics"
|
|
86
|
-
"""
|
|
87
|
-
Metrics key constant used for identifying metrics in the run output.
|
|
78
|
+
Statistics key constant used for identifying statistics in the run output.
|
|
88
79
|
"""
|
|
89
80
|
SOLUTIONS_KEY = "solutions"
|
|
90
81
|
"""
|
|
@@ -98,7 +89,7 @@ Outputs key constant used for identifying outputs in the run output.
|
|
|
98
89
|
|
|
99
90
|
class RunStatistics(BaseModel):
|
|
100
91
|
"""
|
|
101
|
-
|
|
92
|
+
Statistics about a general run.
|
|
102
93
|
|
|
103
94
|
You can import the `RunStatistics` class directly from `nextmv`:
|
|
104
95
|
|
|
@@ -138,7 +129,7 @@ class RunStatistics(BaseModel):
|
|
|
138
129
|
|
|
139
130
|
class ResultStatistics(BaseModel):
|
|
140
131
|
"""
|
|
141
|
-
|
|
132
|
+
Statistics about a specific result.
|
|
142
133
|
|
|
143
134
|
You can import the `ResultStatistics` class directly from `nextmv`:
|
|
144
135
|
|
|
@@ -178,7 +169,7 @@ class ResultStatistics(BaseModel):
|
|
|
178
169
|
|
|
179
170
|
class DataPoint(BaseModel):
|
|
180
171
|
"""
|
|
181
|
-
|
|
172
|
+
A data point representing a 2D coordinate.
|
|
182
173
|
|
|
183
174
|
You can import the `DataPoint` class directly from `nextmv`:
|
|
184
175
|
|
|
@@ -211,7 +202,7 @@ class DataPoint(BaseModel):
|
|
|
211
202
|
|
|
212
203
|
class Series(BaseModel):
|
|
213
204
|
"""
|
|
214
|
-
|
|
205
|
+
A series of data points for visualization or analysis.
|
|
215
206
|
|
|
216
207
|
You can import the `Series` class directly from `nextmv`:
|
|
217
208
|
|
|
@@ -245,7 +236,7 @@ class Series(BaseModel):
|
|
|
245
236
|
|
|
246
237
|
class SeriesData(BaseModel):
|
|
247
238
|
"""
|
|
248
|
-
|
|
239
|
+
Data container for multiple series of data points.
|
|
249
240
|
|
|
250
241
|
You can import the `SeriesData` class directly from `nextmv`:
|
|
251
242
|
|
|
@@ -280,9 +271,6 @@ class SeriesData(BaseModel):
|
|
|
280
271
|
|
|
281
272
|
class Statistics(BaseModel):
|
|
282
273
|
"""
|
|
283
|
-
!!! warning
|
|
284
|
-
`Statistics` is deprecated, use `Metrics` instead.
|
|
285
|
-
|
|
286
274
|
Complete statistics container for a solution, including run metrics and
|
|
287
275
|
result data.
|
|
288
276
|
|
|
@@ -889,9 +877,7 @@ class Output:
|
|
|
889
877
|
The solution to the decision problem. The type must match the
|
|
890
878
|
`output_format`. Default is None.
|
|
891
879
|
statistics : Optional[Union[Statistics, dict[str, Any]]], optional
|
|
892
|
-
|
|
893
|
-
metrics : Optional[dict[str, Any]], optional
|
|
894
|
-
Metrics of the solution. Default is None.
|
|
880
|
+
Statistics of the solution. Default is None.
|
|
895
881
|
csv_configurations : Optional[dict[str, Any]], optional
|
|
896
882
|
Configuration for writing CSV files. Default is None.
|
|
897
883
|
json_configurations : Optional[dict[str, Any]], optional
|
|
@@ -930,16 +916,17 @@ class Output:
|
|
|
930
916
|
Examples
|
|
931
917
|
--------
|
|
932
918
|
>>> from nextmv.output import Output, OutputFormat, Statistics, RunStatistics
|
|
933
|
-
>>>
|
|
919
|
+
>>> run_stats = RunStatistics(duration=30.0, iterations=100)
|
|
920
|
+
>>> stats = Statistics(run=run_stats)
|
|
934
921
|
>>> solution = {"routes": [{"vehicle": 1, "stops": [1, 2, 3]}, {"vehicle": 2, "stops": [4, 5]}]}
|
|
935
922
|
>>> output = Output(
|
|
936
923
|
... output_format=OutputFormat.JSON,
|
|
937
924
|
... solution=solution,
|
|
938
|
-
...
|
|
925
|
+
... statistics=stats,
|
|
939
926
|
... json_configurations={"indent": 4}
|
|
940
927
|
... )
|
|
941
928
|
>>> output_dict = output.to_dict()
|
|
942
|
-
>>> "solution" in output_dict and "
|
|
929
|
+
>>> "solution" in output_dict and "statistics" in output_dict
|
|
943
930
|
True
|
|
944
931
|
"""
|
|
945
932
|
|
|
@@ -982,16 +969,11 @@ class Output:
|
|
|
982
969
|
"""
|
|
983
970
|
statistics: Statistics | dict[str, Any] | None = None
|
|
984
971
|
"""
|
|
985
|
-
Deprecated: Use Metrics instead.
|
|
986
972
|
Statistics of the solution. These statistics can be of type `Statistics` or a
|
|
987
973
|
simple dictionary. If the statistics are of type `Statistics`, they will be
|
|
988
974
|
serialized to a dictionary using the `to_dict` method. If they are a
|
|
989
|
-
dictionary, they will be used as is.
|
|
990
|
-
|
|
991
|
-
metrics: dict[str, Any] | None = None
|
|
992
|
-
"""
|
|
993
|
-
Metrics of the solution. These metrics should be provided as a simple or
|
|
994
|
-
nested dictionary.
|
|
975
|
+
dictionary, they will be used as is. If the statistics are not provided, an
|
|
976
|
+
empty dictionary will be used.
|
|
995
977
|
"""
|
|
996
978
|
csv_configurations: dict[str, Any] | None = None
|
|
997
979
|
"""
|
|
@@ -1106,7 +1088,7 @@ class Output:
|
|
|
1106
1088
|
# Statistics need to end up as a dict, so we achieve that based on the
|
|
1107
1089
|
# type of statistics that were used to create the class.
|
|
1108
1090
|
if self.statistics is None:
|
|
1109
|
-
statistics =
|
|
1091
|
+
statistics = {}
|
|
1110
1092
|
elif isinstance(self.statistics, Statistics):
|
|
1111
1093
|
statistics = self.statistics.to_dict()
|
|
1112
1094
|
elif isinstance(self.statistics, dict):
|
|
@@ -1116,18 +1098,6 @@ class Output:
|
|
|
1116
1098
|
f"unsupported statistics type: {type(self.statistics)}, supported types are `Statistics` or `dict`"
|
|
1117
1099
|
)
|
|
1118
1100
|
|
|
1119
|
-
if self.metrics is None:
|
|
1120
|
-
metrics = None
|
|
1121
|
-
elif isinstance(self.metrics, dict):
|
|
1122
|
-
metrics = self.metrics
|
|
1123
|
-
else:
|
|
1124
|
-
raise TypeError(f"unsupported metrics type: {type(self.metrics)}, supported type is `dict`")
|
|
1125
|
-
|
|
1126
|
-
# if both metrics and statistics are None, set statistics to an
|
|
1127
|
-
# empty dict for backward compatibility
|
|
1128
|
-
if statistics is None and metrics is None:
|
|
1129
|
-
statistics = {}
|
|
1130
|
-
|
|
1131
1101
|
# Assets need to end up as a list of dicts, so we achieve that based on
|
|
1132
1102
|
# the type of each asset in the list.
|
|
1133
1103
|
assets = []
|
|
@@ -1147,16 +1117,10 @@ class Output:
|
|
|
1147
1117
|
output_dict = {
|
|
1148
1118
|
"options": options,
|
|
1149
1119
|
"solution": self.solution if self.solution is not None else {},
|
|
1120
|
+
STATISTICS_KEY: statistics,
|
|
1150
1121
|
ASSETS_KEY: assets,
|
|
1151
1122
|
}
|
|
1152
1123
|
|
|
1153
|
-
# Only include statistics in output if it's not None
|
|
1154
|
-
if statistics is not None:
|
|
1155
|
-
output_dict[STATISTICS_KEY] = statistics
|
|
1156
|
-
|
|
1157
|
-
if metrics is not None:
|
|
1158
|
-
output_dict[METRICS_KEY] = metrics
|
|
1159
|
-
|
|
1160
1124
|
# Add the auxiliary configurations to the output dictionary if they are
|
|
1161
1125
|
# defined and not empty.
|
|
1162
1126
|
if (
|
|
@@ -1229,9 +1193,9 @@ class LocalOutputWriter(OutputWriter):
|
|
|
1229
1193
|
|
|
1230
1194
|
Examples
|
|
1231
1195
|
--------
|
|
1232
|
-
>>> from nextmv.output import LocalOutputWriter, Output,
|
|
1196
|
+
>>> from nextmv.output import LocalOutputWriter, Output, Statistics
|
|
1233
1197
|
>>> writer = LocalOutputWriter()
|
|
1234
|
-
>>> output = Output(solution={"result": 42},
|
|
1198
|
+
>>> output = Output(solution={"result": 42}, statistics=Statistics())
|
|
1235
1199
|
>>> # Write to stdout
|
|
1236
1200
|
>>> writer.write(output, path=None)
|
|
1237
1201
|
>>> # Write to a file
|
nextmv/run.py
CHANGED
|
@@ -434,9 +434,6 @@ class RunInfoStatistics(BaseModel):
|
|
|
434
434
|
"""List of statistics indicators."""
|
|
435
435
|
|
|
436
436
|
|
|
437
|
-
RunInfoMetrics = RunInfoStatistics
|
|
438
|
-
|
|
439
|
-
|
|
440
437
|
class OptionsSummaryItem(BaseModel):
|
|
441
438
|
"""
|
|
442
439
|
Summary item for options used in a run.
|
|
@@ -532,9 +529,7 @@ class Run(BaseModel):
|
|
|
532
529
|
experiment_id : str, optional
|
|
533
530
|
ID of the experiment associated with the run. Defaults to None.
|
|
534
531
|
statistics : RunInfoStatistics, optional
|
|
535
|
-
|
|
536
|
-
metrics: RunInfoMetrics, optional
|
|
537
|
-
Metrics of the run. Defaults to None.
|
|
532
|
+
Statistics of the run. Defaults to None.
|
|
538
533
|
input_id : str, optional
|
|
539
534
|
ID of the input associated with the run. Defaults to None.
|
|
540
535
|
option_set : str, optional
|
|
@@ -608,9 +603,7 @@ class Run(BaseModel):
|
|
|
608
603
|
experiment_id: str | None = None
|
|
609
604
|
"""ID of the experiment associated with the run."""
|
|
610
605
|
statistics: RunInfoStatistics | None = None
|
|
611
|
-
"""
|
|
612
|
-
metrics: RunInfoMetrics | None = None
|
|
613
|
-
"""Metrics of the run."""
|
|
606
|
+
"""Statistics of the run."""
|
|
614
607
|
input_id: str | None = None
|
|
615
608
|
"""ID of the input associated with the run."""
|
|
616
609
|
option_set: str | None = None
|
|
@@ -684,9 +677,7 @@ class Metadata(BaseModel):
|
|
|
684
677
|
status_v2: StatusV2
|
|
685
678
|
"""Status of the run."""
|
|
686
679
|
statistics: dict[str, Any] | None = None
|
|
687
|
-
"""
|
|
688
|
-
metrics: dict[str, Any] | None = None
|
|
689
|
-
"""User defined metrics of the run."""
|
|
680
|
+
"""User defined statistics of the run."""
|
|
690
681
|
|
|
691
682
|
def run_is_finalized(self) -> bool:
|
|
692
683
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nextmv
|
|
3
|
-
Version: 1.0.0.
|
|
3
|
+
Version: 1.0.0.dev7
|
|
4
4
|
Summary: The all-purpose Python SDK for Nextmv
|
|
5
5
|
Project-URL: Homepage, https://www.nextmv.io
|
|
6
6
|
Project-URL: Documentation, https://nextmv-py.docs.nextmv.io/en/latest/nextmv/
|
|
@@ -230,11 +230,13 @@ Provides-Extra: dev
|
|
|
230
230
|
Requires-Dist: build>=1.0.3; extra == 'dev'
|
|
231
231
|
Requires-Dist: folium>=0.20.0; extra == 'dev'
|
|
232
232
|
Requires-Dist: mlflow>=2.19.0; extra == 'dev'
|
|
233
|
+
Requires-Dist: nextpipe>=0.6.0; extra == 'dev'
|
|
233
234
|
Requires-Dist: nextroute>=1.11.1; extra == 'dev'
|
|
234
235
|
Requires-Dist: openpyxl>=3.1.5; extra == 'dev'
|
|
235
236
|
Requires-Dist: pandas>=2.2.3; extra == 'dev'
|
|
236
237
|
Requires-Dist: plotly>=6.0.1; extra == 'dev'
|
|
237
238
|
Requires-Dist: pydantic>=2.5.2; extra == 'dev'
|
|
239
|
+
Requires-Dist: pytest>=9.0.2; extra == 'dev'
|
|
238
240
|
Requires-Dist: pyyaml>=6.0.1; extra == 'dev'
|
|
239
241
|
Requires-Dist: requests>=2.31.0; extra == 'dev'
|
|
240
242
|
Requires-Dist: ruff>=0.1.7; extra == 'dev'
|