nextmv 0.33.0.dev0__py3-none-any.whl → 0.34.0.dev0__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/local/local.py CHANGED
@@ -36,7 +36,7 @@ LOGS_KEY = "logs"
36
36
  """
37
37
  Logs key constant used for identifying logs in the run output.
38
38
  """
39
- LOGS_FILE = "stderr.log"
39
+ LOGS_FILE = "logs.log"
40
40
  """
41
41
  Constant used for identifying the file used for logging.
42
42
  """
nextmv/manifest.py CHANGED
@@ -49,7 +49,7 @@ from enum import Enum
49
49
  from typing import Any, Optional, Union
50
50
 
51
51
  import yaml
52
- from pydantic import AliasChoices, Field
52
+ from pydantic import AliasChoices, Field, field_validator
53
53
 
54
54
  from nextmv.base_model import BaseModel
55
55
  from nextmv.input import InputFormat
@@ -166,6 +166,43 @@ class ManifestRuntime(str, Enum):
166
166
  Based on the python runtime, it provisions (pre-installs) the Hexaly solver
167
167
  to run Python applications.
168
168
  """
169
+ CUOPT = "ghcr.io/nextmv-io/runtime/cuopt:latest"
170
+ """
171
+ A runtime providing the NVIDIA cuOpt solver.
172
+ """
173
+
174
+
175
+ class ManifestPythonArch(str, Enum):
176
+ """
177
+ Target architecture for bundling Python apps.
178
+
179
+ You can import the `ManifestPythonArch` class directly from `nextmv`:
180
+
181
+ ```python
182
+ from nextmv import ManifestPythonArch
183
+ ```
184
+
185
+ Attributes
186
+ ----------
187
+ ARM64 : str
188
+ ARM 64-bit architecture.
189
+ AMD64 : str
190
+ AMD 64-bit architecture.
191
+
192
+ Examples
193
+ --------
194
+ >>> from nextmv import ManifestPythonArch
195
+ >>> arch = ManifestPythonArch.ARM64
196
+ >>> arch
197
+ <ManifestPythonArch.ARM64: 'arm64'>
198
+ >>> str(arch)
199
+ 'arm64'
200
+ """
201
+
202
+ ARM64 = "arm64"
203
+ """ARM 64-bit architecture."""
204
+ AMD64 = "amd64"
205
+ """AMD 64-bit architecture."""
169
206
 
170
207
 
171
208
  class ManifestBuild(BaseModel):
@@ -325,6 +362,12 @@ class ManifestPython(BaseModel):
325
362
  Contains (additional) Python dependencies that will be bundled with the
326
363
  app.
327
364
  """
365
+ arch: Optional[ManifestPythonArch] = None
366
+ """The architecture this model is meant to run on. One of "arm64" or "amd64". Uses
367
+ "arm64" if not specified."""
368
+ version: Optional[Union[str, float]] = None
369
+ """The Python version this model is meant to run with. Uses "3.11" if not specified.
370
+ """
328
371
  model: Optional[ManifestPythonModel] = None
329
372
  """Information about an encoded decision model.
330
373
 
@@ -332,6 +375,17 @@ class ManifestPython(BaseModel):
332
375
  from the app bundle.
333
376
  """
334
377
 
378
+ @field_validator("version", mode="before")
379
+ @classmethod
380
+ def validate_version(cls, v: Optional[Union[str, float]]) -> Optional[str]:
381
+ # We allow the version to be a float in the manifest for convenience, but we want
382
+ # to store it as a string internally.
383
+ if v is None:
384
+ return None
385
+ if isinstance(v, float):
386
+ return str(v)
387
+ return v
388
+
335
389
 
336
390
  class ManifestOptionUI(BaseModel):
337
391
  """
@@ -1025,7 +1079,12 @@ class Manifest(BaseModel):
1025
1079
 
1026
1080
  def model_post_init(self, __context) -> None:
1027
1081
  if self.entrypoint is None:
1028
- if self.runtime in (ManifestRuntime.PYTHON, ManifestRuntime.HEXALY, ManifestRuntime.PYOMO):
1082
+ if self.runtime in (
1083
+ ManifestRuntime.PYTHON,
1084
+ ManifestRuntime.HEXALY,
1085
+ ManifestRuntime.PYOMO,
1086
+ ManifestRuntime.CUOPT,
1087
+ ):
1029
1088
  self.entrypoint = "./main.py"
1030
1089
  elif self.runtime == ManifestRuntime.DEFAULT:
1031
1090
  self.entrypoint = "./main"
nextmv/run.py CHANGED
@@ -52,7 +52,7 @@ from pydantic import AliasChoices, Field, field_validator
52
52
  from nextmv._serialization import serialize_json
53
53
  from nextmv.base_model import BaseModel
54
54
  from nextmv.input import Input, InputFormat
55
- from nextmv.output import Output, OutputFormat
55
+ from nextmv.output import Asset, Output, OutputFormat, Statistics
56
56
  from nextmv.status import Status, StatusV2
57
57
 
58
58
 
@@ -687,6 +687,56 @@ class Metadata(BaseModel):
687
687
  """Deprecated: use status_v2."""
688
688
 
689
689
 
690
+ class SyncedRun(BaseModel):
691
+ """
692
+ Information about a run that has been synced to a remote application.
693
+
694
+ You can import the `SyncedRun` class directly from `nextmv`:
695
+
696
+ ```python
697
+ from nextmv import SyncedRun
698
+ ```
699
+
700
+ Parameters
701
+ ----------
702
+ run_id : str
703
+ ID of the synced remote run. When the `Application.sync` method is
704
+ used, this field marks the association between the local run (`id`) and
705
+ the remote run (`synced_run.id`).
706
+ synced_at : datetime
707
+ Timestamp when the run was synced with the remote run.
708
+ app_id : str
709
+ The ID of the remote application that the local run was synced to.
710
+ instance_id : Optional[str], optional
711
+ The instance of the remote application that the local run was synced
712
+ to. This field is optional and may be None. If it is not specified, it
713
+ indicates that the run was synced against the default instance of the
714
+ app. Defaults to None.
715
+ """
716
+
717
+ run_id: str
718
+ """
719
+ ID of the synced remote run. When the `Application.sync` method is used,
720
+ this field marks the association between the local run (`id`) and the
721
+ remote run (`synced_run.id`)
722
+ """
723
+ synced_at: datetime
724
+ """
725
+ Timestamp when the run was synced with the remote run.
726
+ """
727
+ app_id: str
728
+ """
729
+ The ID of the remote application that the local run was synced to.
730
+ """
731
+
732
+ instance_id: Optional[str] = None
733
+ """
734
+ The instance of the remote application that the local run was synced to.
735
+ This field is optional and may be None. If it is not specified, it
736
+ indicates that the run was synced against the default instance of the app.
737
+ """
738
+
739
+
690
740
  class RunInformation(BaseModel):
691
741
  """
692
742
  Information of a run.
@@ -727,19 +777,18 @@ class RunInformation(BaseModel):
727
777
  """
728
778
  URL to the run in the Nextmv console.
729
779
  """
730
- synced_run_id: Optional[str] = None
731
- """
732
- ID of the synced remote run, if applicable. When the `Application.sync`
733
- method is used, this field marks the association between the local run
734
- (`id`) and the remote run (`synced_run_id`). This field is None if the run
735
- was not created using `Application.sync` or if the run has not been synced
736
- yet.
780
+ synced_runs: Optional[list[SyncedRun]] = None
737
781
  """
738
- synced_at: Optional[datetime] = None
739
- """
740
- Timestamp when the run was synced with the remote run. This field is
741
- None if the run was not created using `Application.sync` or if the run
742
- has not been synced yet.
782
+ List of synced runs associated with this run, if applicable. When the
783
+ `Application.sync` method is used, this field contains the associations
784
+ between the local run (`id`) and the remote runs (`synced_run.id`). This
785
+ field is None if the run was not created using `Application.sync` or if the
786
+ run has not been synced yet. It is possible to sync a single local run to
787
+ multiple remote runs. A remote run is identified by its application ID and
788
+ instance (if applicable). A local run cannot be synced to a remote run if
789
+ it is already present, this is, if there exists a record in the list with
790
+ the same application ID and instance. If there is not a repeated remote
791
+ run, a new record is added to the list.
743
792
  """
744
793
 
745
794
  def to_run(self) -> Run:
@@ -817,6 +866,83 @@ class RunInformation(BaseModel):
817
866
  input_set_id=None,
818
867
  )
819
868
 
869
+ def add_synced_run(self, synced_run: SyncedRun) -> bool:
870
+ """
871
+ Add a synced run to the RunInformation.
872
+
873
+ This method adds a `SyncedRun` instance to the list of synced runs
874
+ associated with this `RunInformation`. If the list is None, it
875
+ initializes it first. If the run has already been synced, then it is
876
+ not added to the list. A run is already synced if there exists a record
877
+ in the list with the same application ID. This method returns True if
878
+ the synced run was added, and False otherwise.
879
+
880
+ Parameters
881
+ ----------
882
+ synced_run : SyncedRun
883
+ The SyncedRun instance to add.
884
+
885
+ Returns
886
+ -------
887
+ bool
888
+ True if the synced run was added, False if it was already present.
889
+ """
890
+
891
+ if self.synced_runs is None:
892
+ self.synced_runs = [synced_run]
893
+
894
+ return True
895
+
896
+ if synced_run.instance_id is None:
897
+ for existing_run in self.synced_runs:
898
+ if existing_run.app_id == synced_run.app_id:
899
+ return False
900
+ else:
901
+ for existing_run in self.synced_runs:
902
+ if existing_run.app_id == synced_run.app_id and existing_run.instance_id == synced_run.instance_id:
903
+ return False
904
+
905
+ self.synced_runs.append(synced_run)
906
+
907
+ return True
908
+
909
+ def is_synced(self, app_id: str, instance_id: Optional[str] = None) -> tuple[SyncedRun, bool]:
910
+ """
911
+ Check if the run has been synced to a specific application and instance.
912
+
913
+ This method checks if there exists a `SyncedRun` in the list of synced
914
+ runs that matches the given application ID and optional instance ID.
915
+
916
+ Parameters
917
+ ----------
918
+ app_id : str
919
+ The application ID to check.
920
+ instance_id : Optional[str], optional
921
+ The instance ID to check. If None, only the application ID is
922
+ considered. Defaults to None.
923
+
924
+ Returns
925
+ -------
926
+ tuple[SyncedRun, bool]
927
+ A tuple containing the SyncedRun instance if found, and a boolean
928
+ indicating whether the run has been synced to the specified
929
+ application and instance.
930
+ """
931
+
932
+ if self.synced_runs is None:
933
+ return None, False
934
+
935
+ if instance_id is None:
936
+ for existing_run in self.synced_runs:
937
+ if existing_run.app_id == app_id:
938
+ return existing_run, True
939
+ else:
940
+ for existing_run in self.synced_runs:
941
+ if existing_run.app_id == app_id and existing_run.instance_id == instance_id:
942
+ return existing_run, True
943
+
944
+ return None, False
945
+
820
946
 
821
947
  class ErrorLog(BaseModel):
822
948
  """
@@ -1154,6 +1280,16 @@ class ExternalRunResult(BaseModel):
1154
1280
  """Error message of the run."""
1155
1281
  execution_duration: Optional[int] = None
1156
1282
  """Duration of the run, in milliseconds."""
1283
+ statistics_upload_id: Optional[str] = None
1284
+ """
1285
+ ID of the statistics upload. Use this field when working with `CSV_ARCHIVE`
1286
+ or `MULTI_FILE` output formats.
1287
+ """
1288
+ assets_upload_id: Optional[str] = None
1289
+ """
1290
+ ID of the assets upload. Use this field when working with `CSV_ARCHIVE`
1291
+ or `MULTI_FILE` output formats.
1292
+ """
1157
1293
 
1158
1294
  def __post_init_post_parse__(self):
1159
1295
  """
@@ -1265,6 +1401,18 @@ class TrackedRun:
1265
1401
  when working with `CSV_ARCHIVE` or `MULTI_FILE`. If both `output` and
1266
1402
  `output_dir_path` are specified, the `output` is ignored, and the files
1267
1403
  are saved in the directory instead. Defaults to None.
1404
+ statistics : Statistics or dict[str, Any], optional
1405
+ Statistics of the run being tracked. Only use this field if you want to
1406
+ track statistics for `CSV_ARCHIVE` or `MULTI_FILE` output formats. If you
1407
+ are working with `JSON` or `TEXT` output formats, this field will be
1408
+ ignored, as the statistics are extracted directly from the `output`.
1409
+ This field is optional. Defaults to None.
1410
+ assets : list[Asset or dict[str, Any]], optional
1411
+ Assets associated with the run being tracked. Only use this field if you
1412
+ want to track assets for `CSV_ARCHIVE` or `MULTI_FILE` output formats.
1413
+ If you are working with `JSON` or `TEXT` output formats, this field will
1414
+ be ignored, as the assets are extracted directly from the `output`.
1415
+ This field is optional. Defaults to None.
1268
1416
 
1269
1417
  Examples
1270
1418
  --------
@@ -1365,6 +1513,20 @@ class TrackedRun:
1365
1513
  `output_dir_path` are specified, the `output` is ignored, and the files
1366
1514
  are saved in the directory instead.
1367
1515
  """
1516
+ statistics: Optional[Union[Statistics, dict[str, Any]]] = None
1517
+ """
1518
+ Statistics of the run being tracked. Only use this field if you want to
1519
+ track statistics for `CSV_ARCHIVE` or `MULTI_FILE` output formats. If you
1520
+ are working with `JSON` or `TEXT` output formats, this field will be
1521
+ ignored, as the statistics are extracted directly from the `output`.
1522
+ """
1523
+ assets: Optional[list[Union[Asset, dict[str, Any]]]] = None
1524
+ """
1525
+ Assets associated with the run being tracked. Only use this field if you
1526
+ want to track assets for `CSV_ARCHIVE` or `MULTI_FILE` output formats.
1527
+ If you are working with `JSON` or `TEXT` output formats, this field will
1528
+ be ignored, as the assets are extracted directly from the `output`.
1529
+ """
1368
1530
 
1369
1531
  def __post_init__(self): # noqa: C901
1370
1532
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nextmv
3
- Version: 0.33.0.dev0
3
+ Version: 0.34.0.dev0
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/
@@ -1,29 +1,29 @@
1
- nextmv/__about__.py,sha256=swx5y44doM60f9hpn91hbwEUw-qTWVfvgrZ4zO7sCP0,29
1
+ nextmv/__about__.py,sha256=IEH4q3YZ3NJ8xLBOPvbdmzjvZQSBu6mlVa0ZYNf6FZ0,29
2
2
  nextmv/__entrypoint__.py,sha256=dA0iwwHtrq6Z9w9FxmxKLoBGLyhe7jWtUAU-Y3PEgHg,1094
3
- nextmv/__init__.py,sha256=pW2HMcJnNSFqF_tj77TtqpddEeCosTKS7NxGNPDp7mU,3620
3
+ nextmv/__init__.py,sha256=GYzXp81KEteniXZkNZ9IgLYnJNOBOQckOeGpTkxjjD4,3723
4
4
  nextmv/_serialization.py,sha256=JlSl6BL0M2Esf7F89GsGIZ__Pp8RnFRNM0UxYhuuYU4,2853
5
5
  nextmv/base_model.py,sha256=qmJ4AsYr9Yv01HQX_BERrn3229gyoZrYyP9tcyqNfeU,2311
6
6
  nextmv/deprecated.py,sha256=kEVfyQ-nT0v2ePXTNldjQG9uH5IlfQVy3L4tztIxwmU,1638
7
7
  nextmv/input.py,sha256=m9sVfO9ZL3F5i1l8amEtlWlbkekyUP4C3y9DduHWGFs,40211
8
8
  nextmv/logger.py,sha256=kNIbu46MisrzYe4T0hNMpWfRTKKacDVvbtQcNys_c_E,2513
9
- nextmv/manifest.py,sha256=wzGDrGleIgYvRvKyy73acjd68cGdCLD_7x_Dy3UhCaI,44266
9
+ nextmv/manifest.py,sha256=jCu5RUl6bip4kTDh4zaD4PTYNOIGHWKm34kfXD_rpzw,45898
10
10
  nextmv/model.py,sha256=vI3pSV3iTwjRPflar7nAg-6h98XRUyi9II5O2J06-Kc,15018
11
11
  nextmv/options.py,sha256=yPJu5lYMbV6YioMwAXv7ctpZUggLXKlZc9CqIbUFvE4,37895
12
12
  nextmv/output.py,sha256=HdvWYG3gIzwoXquulaEVI4LLchXJDjkbag0BkBPM0vQ,55128
13
13
  nextmv/polling.py,sha256=nfefvWI1smm-lIzaXE-4DMlojp6KXIvVi88XLJYUmo8,9724
14
- nextmv/run.py,sha256=lAWWkLml1C7wkXSvN8orBjudoz72Qv5ZCHCWY9e7xaY,45813
14
+ nextmv/run.py,sha256=8B9hh-jWJpoMSJiDmgmXaqvmzTicWCn75UTJu7Nf7Cs,52401
15
15
  nextmv/safe.py,sha256=VAK4fGEurbLNji4Pg5Okga5XQSbI4aI9JJf95_68Z20,3867
16
16
  nextmv/status.py,sha256=SCDLhh2om3yeO5FxO0x-_RShQsZNXEpjHNdCGdb3VUI,2787
17
17
  nextmv/cloud/__init__.py,sha256=2wI72lhWq81BYv1OpS0OOTT5-3sivpX0H4z5ANPoLMc,5051
18
- nextmv/cloud/acceptance_test.py,sha256=ZvOaVzhy3sHb5Vi9uBGhZJPggLN0oEmEvLKyc830zQ8,27439
18
+ nextmv/cloud/acceptance_test.py,sha256=ZEzCMrfJF-nUFr1nEr4IDgcoyavPhnanjFuPBJ79tAk,27731
19
19
  nextmv/cloud/account.py,sha256=jIdGNyI3l3dVh2PuriAwAOrEuWRM150WgzxcBMVBNRw,6058
20
- nextmv/cloud/application.py,sha256=wieXFWijmCsgEDpmefLWs010BkHMbAdLLV7Cwmncu5I,140555
20
+ nextmv/cloud/application.py,sha256=oUpw6I1r4u9Cn0pnlylWlm23hPgZKsg_vnBXbqTtU-w,139693
21
21
  nextmv/cloud/batch_experiment.py,sha256=13ciRpgBabMMTyazfdfEAymD3rTPrTAAorECsANxxuA,10397
22
22
  nextmv/cloud/client.py,sha256=E0DiUb377jvEnpXlRnfT1PGCI0Jm0lTUoX5VqeU91lk,18165
23
23
  nextmv/cloud/ensemble.py,sha256=glrRgyRFcEH12fNUhEl1FOo6xOTDEaF478dxfX0wj2Y,8604
24
24
  nextmv/cloud/input_set.py,sha256=NkzA6_hwgD-YwoirzwvZrObIoBTfurry7Os3jo4DyXc,4236
25
25
  nextmv/cloud/instance.py,sha256=SS4tbp0LQMWDaeYpwcNxJei82oi_Hozv1t5i3QGjASY,4024
26
- nextmv/cloud/package.py,sha256=cG75DptN4sxXaT8ruDh2EY2duaK5Jwg16X2LV0BP8ts,13021
26
+ nextmv/cloud/package.py,sha256=Xmt-daAeN9QJKpquV28IiZa2eYCX0P3wSS564JHvrtY,14495
27
27
  nextmv/cloud/scenario.py,sha256=JRFTDiFBcrgud6wE2qDHUu5oO-Ur3zbPYhhB6ONCxTo,14263
28
28
  nextmv/cloud/secrets.py,sha256=fA5cX0jfTsPVZWV7433wzETGlXpWRLHGswuObx9e6FQ,6820
29
29
  nextmv/cloud/url.py,sha256=Fz70ywkWdCLmP21ZBmJwZi5kDbjpmsX_VlwVF_xQeHg,1836
@@ -38,13 +38,13 @@ nextmv/default_app/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
38
38
  nextmv/default_app/src/main.py,sha256=WWeN_xl_mcPhICl3rSCvdEjRkFXGmAnej88FhS-fAmc,884
39
39
  nextmv/default_app/src/visuals.py,sha256=WYK_YBnLmYo3TpVev1CpoNCuW5R7hk9QIkeCmvMn1Fs,1014
40
40
  nextmv/local/__init__.py,sha256=6BsoqlK4dw6X11_uKzz9gBPfxKpdiol2FYO8R3X73SE,116
41
- nextmv/local/application.py,sha256=qq14ihKxymg5NHqhU56qTu6lVmMYWLGYUJC4MrhWB68,45815
42
- nextmv/local/executor.py,sha256=ohAUrIRohcH_qGglK1hSFR0W6bPBSuMAcMwVkW5G4vM,24338
41
+ nextmv/local/application.py,sha256=dupLPPJ0JkMsTI-7-OoPz9JCRboJyxWy6iO3SPKdA1o,46514
42
+ nextmv/local/executor.py,sha256=Num-VdI5rRecI1XDz__YtW7U2q02ulbwMfWxlhhzwU8,35202
43
43
  nextmv/local/geojson_handler.py,sha256=7FavJdkUonop-yskjis0x3qFGB8A5wZyoBUblw-bVhw,12540
44
- nextmv/local/local.py,sha256=wUHuoAXqJIZpTJBh056hmQuiPEjlZvLTR2BC6Ino-WI,2619
44
+ nextmv/local/local.py,sha256=cp56UpI8h19Ob6Jvb_Ni0ceXH5Vv3ET_iPTDe6ftq3Y,2617
45
45
  nextmv/local/plotly_handler.py,sha256=bLb50e3AkVr_W-F6S7lXfeRdN60mG2jk3UElNmhoMWU,1930
46
46
  nextmv/local/runner.py,sha256=hwkITHrQG_J9TzxufnaP1mjLWG-iSsNQD66UFZY4pp4,8602
47
- nextmv-0.33.0.dev0.dist-info/METADATA,sha256=GU6x---pvDI4R1SBV9BW1J5fVLLPxllbrccj6kLyApA,16013
48
- nextmv-0.33.0.dev0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
- nextmv-0.33.0.dev0.dist-info/licenses/LICENSE,sha256=ZIbK-sSWA-OZprjNbmJAglYRtl5_K4l9UwAV3PGJAPc,11349
50
- nextmv-0.33.0.dev0.dist-info/RECORD,,
47
+ nextmv-0.34.0.dev0.dist-info/METADATA,sha256=lqIIWxNBN6AfvZ_Nw8hmkTyxM1lOhVQ2nvm--xoPML8,16013
48
+ nextmv-0.34.0.dev0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
+ nextmv-0.34.0.dev0.dist-info/licenses/LICENSE,sha256=ZIbK-sSWA-OZprjNbmJAglYRtl5_K4l9UwAV3PGJAPc,11349
50
+ nextmv-0.34.0.dev0.dist-info/RECORD,,