nextmv 0.10.3.dev0__py3-none-any.whl → 0.35.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.
Files changed (61) hide show
  1. nextmv/__about__.py +1 -1
  2. nextmv/__entrypoint__.py +39 -0
  3. nextmv/__init__.py +57 -0
  4. nextmv/_serialization.py +96 -0
  5. nextmv/base_model.py +79 -9
  6. nextmv/cloud/__init__.py +71 -10
  7. nextmv/cloud/acceptance_test.py +888 -17
  8. nextmv/cloud/account.py +154 -10
  9. nextmv/cloud/application.py +3644 -437
  10. nextmv/cloud/batch_experiment.py +292 -33
  11. nextmv/cloud/client.py +354 -53
  12. nextmv/cloud/ensemble.py +247 -0
  13. nextmv/cloud/input_set.py +121 -4
  14. nextmv/cloud/instance.py +125 -0
  15. nextmv/cloud/package.py +474 -0
  16. nextmv/cloud/scenario.py +410 -0
  17. nextmv/cloud/secrets.py +234 -0
  18. nextmv/cloud/url.py +73 -0
  19. nextmv/cloud/version.py +174 -0
  20. nextmv/default_app/.gitignore +1 -0
  21. nextmv/default_app/README.md +32 -0
  22. nextmv/default_app/app.yaml +12 -0
  23. nextmv/default_app/input.json +5 -0
  24. nextmv/default_app/main.py +37 -0
  25. nextmv/default_app/requirements.txt +2 -0
  26. nextmv/default_app/src/__init__.py +0 -0
  27. nextmv/default_app/src/main.py +37 -0
  28. nextmv/default_app/src/visuals.py +36 -0
  29. nextmv/deprecated.py +47 -0
  30. nextmv/input.py +883 -78
  31. nextmv/local/__init__.py +5 -0
  32. nextmv/local/application.py +1263 -0
  33. nextmv/local/executor.py +1040 -0
  34. nextmv/local/geojson_handler.py +323 -0
  35. nextmv/local/local.py +97 -0
  36. nextmv/local/plotly_handler.py +61 -0
  37. nextmv/local/runner.py +274 -0
  38. nextmv/logger.py +80 -9
  39. nextmv/manifest.py +1472 -0
  40. nextmv/model.py +431 -0
  41. nextmv/options.py +968 -78
  42. nextmv/output.py +1363 -231
  43. nextmv/polling.py +287 -0
  44. nextmv/run.py +1623 -0
  45. nextmv/safe.py +145 -0
  46. nextmv/status.py +122 -0
  47. {nextmv-0.10.3.dev0.dist-info → nextmv-0.35.0.dist-info}/METADATA +51 -288
  48. nextmv-0.35.0.dist-info/RECORD +50 -0
  49. {nextmv-0.10.3.dev0.dist-info → nextmv-0.35.0.dist-info}/WHEEL +1 -1
  50. nextmv/cloud/status.py +0 -29
  51. nextmv/nextroute/__init__.py +0 -2
  52. nextmv/nextroute/check/__init__.py +0 -26
  53. nextmv/nextroute/check/schema.py +0 -141
  54. nextmv/nextroute/schema/__init__.py +0 -19
  55. nextmv/nextroute/schema/input.py +0 -52
  56. nextmv/nextroute/schema/location.py +0 -13
  57. nextmv/nextroute/schema/output.py +0 -136
  58. nextmv/nextroute/schema/stop.py +0 -61
  59. nextmv/nextroute/schema/vehicle.py +0 -68
  60. nextmv-0.10.3.dev0.dist-info/RECORD +0 -28
  61. {nextmv-0.10.3.dev0.dist-info → nextmv-0.35.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,247 @@
1
+ """
2
+ Classes for working with Nextmv Cloud Ensemble Runs.
3
+
4
+ This module provides classes for interacting with ensemble runs in Nextmv Cloud.
5
+ It details the core data structures for ensemble definitions.
6
+
7
+ Classes
8
+ -------
9
+ RunGroup
10
+ A structure to group execution of child runs for an ensemble run.
11
+ RuleObjective
12
+ An enum that specifies the supported evaluation rule objectives.
13
+ ToleranceType
14
+ An enum that specifies the supported tolerance types for evaluation rules.
15
+ RuleTolerance
16
+ A structure for defining tolerance thresholds for an evaluation rule
17
+ EvaluationRule
18
+ A structure to evaluate run results for an ensemble run.
19
+ EnsembleDefinition
20
+ Representation of a Nextmv Cloud Ensemble Definition for an application.
21
+ """
22
+
23
+ from datetime import datetime
24
+ from enum import Enum
25
+
26
+ from nextmv.base_model import BaseModel
27
+
28
+
29
+ class RunGroup(BaseModel):
30
+ """A structure to group child runs for an ensemble run.
31
+
32
+ You can import the `RunGroup` class directly from `cloud`:
33
+
34
+ ```python
35
+ from nextmv.cloud import RunGroup
36
+ ```
37
+
38
+ This class represents a grouping of child runs that share a configuration
39
+ for ensemble run executions.
40
+
41
+ Parameters
42
+ ----------
43
+ id : str
44
+ The unique identifier of the run group.
45
+ instance_id : str
46
+ ID of the app instance that this run group executes on.
47
+ options : dict, optional
48
+ Runtime options/parameters for the application.
49
+ repetitions : int, optional
50
+ The number of times the run is to be repeated on the instance and with
51
+ the options defined in the run group
52
+ """
53
+
54
+ id: str
55
+ """The unique identifier of the run group."""
56
+ instance_id: str
57
+ """ID of the app instance that this run group executes on."""
58
+ options: dict | None = None
59
+ """Runtime options/parameters for the application."""
60
+ repetitions: int | None = None
61
+ """The number of times the run is to be repeated on the instance and with
62
+ the options defined in the run group"""
63
+
64
+
65
+ class RuleObjective(str, Enum):
66
+ """The value of this data determines how a value of a run is optimized to
67
+ determined which ensemble child run is the "best" for a given metric and
68
+ rule, as well as which other ones are within tolerance of that run for the
69
+ purposes of selecting a result for the ensemble run from among the child runs.
70
+
71
+ You can import the `RuleObjective` class directly from `cloud`:
72
+
73
+ ```python
74
+ from nextmv.cloud import RuleObjective
75
+ ```
76
+
77
+ This enum specifies the supported evaluation rule objectives.
78
+
79
+ Attributes
80
+ ----------
81
+ MAXIMIZE : str
82
+ Maximize the value of the evaluated metric.
83
+ MINIMIZE : str
84
+ Minimize the value of the evaluated metric.
85
+ """
86
+
87
+ MAXIMIZE = "maximize"
88
+ """Maximize the value of the evaluated metric."""
89
+ MINIMIZE = "minimize"
90
+ """Minimize the value of the evaluated metric."""
91
+
92
+
93
+ class RuleToleranceType(str, Enum):
94
+ """The type of comparison used to determine if a run metric is within
95
+ tolerance of a the "best" run for that rule and metric
96
+
97
+ You can import the `RuleToleranceType` class directly from `cloud`:
98
+
99
+ ```python
100
+ from nextmv.cloud import RuleToleranceType
101
+ ```
102
+
103
+ This enum specifies the supported tolerance types.
104
+
105
+ Attributes
106
+ ----------
107
+ ABSOLUTE : str
108
+ Uses the absolute difference between the value of the "best" run and
109
+ the run being evaluated for tolerance
110
+ RELATIVE : str
111
+ Uses the the percentage of the "best" run by which the run being
112
+ evaluted for tolerance differs. A value of `1` is 100%.
113
+ """
114
+
115
+ ABSOLUTE = "absolute"
116
+ """Uses the absolute difference between the value of the "best" run and
117
+ the run being evaluated for tolerance"""
118
+ RELATIVE = "relative"
119
+ """Uses the the percentage of the "best" run by which the run being
120
+ evaluted for tolerance differs. A value of `1` is 100%."""
121
+
122
+
123
+ class RuleTolerance(BaseModel):
124
+ """A structure used to determine if a run is within tolerance of of the best
125
+ run (as determined by the objective of the `EvaluationRule` it is defined on).
126
+
127
+ You can import the `RuleTolerance` class directly from `cloud`:
128
+
129
+ ```python
130
+ from nextmv.cloud import RuleTolerance
131
+ ```
132
+
133
+ This class represents the tolerance on a particular evaluation rule by
134
+ which a child run may be selected as the result of an ensemble run.
135
+
136
+ value : float
137
+ The value within which runs can deviate from the "best" run
138
+ for that metric to be considered within tolerance of it.
139
+ type : ToleranceType
140
+ The method by which runs are determined to be within tolerance.
141
+ """
142
+
143
+ value: float
144
+ """The value within which runs can deviate from the "best" run
145
+ for that metric to be considered within tolerance of it."""
146
+ type: RuleToleranceType
147
+ """The method by which runs are determined to be within tolerance."""
148
+
149
+
150
+ class EvaluationRule(BaseModel):
151
+ """A structure to evaluate run results for an ensemble run.
152
+
153
+ You can import the `EvaluationRule` class directly from `cloud`:
154
+
155
+ ```python
156
+ from nextmv.cloud import EvaluationRule
157
+ ```
158
+
159
+ This class represents a rule by which the child runs for an ensemble run
160
+ will be evaluated for the purpose of selecting an optimal result for the
161
+ ensemble run.
162
+
163
+ Parameters
164
+ ----------
165
+ id : str
166
+ The unique identifier of the evaluation rule.
167
+ statistics_path : str
168
+ The path within the statistics of a run output (conforming to Nextmv
169
+ statistics convention and flattened to a string starting with `$` and
170
+ delimited by `.` e.g. `$.result.value`.)
171
+ objective : RuleObjective
172
+ The objective by which runs are optimized for this rule
173
+ tolerance : RuleTolerance
174
+ The tolerance by which runs can be accepted as a potential result
175
+ for an evaluation rule
176
+ index : int, optional
177
+ The index (non-negative integer) of the evalutation rule. Lower indicies
178
+ are evaluated first.
179
+ """
180
+
181
+ id: str
182
+ """The unique identifier of the evaluation rule."""
183
+ statistics_path: str
184
+ """The path within the statistics of a run output (conforming to Nextmv
185
+ statistics convention and flattened to a string starting with `$` and
186
+ delimited by `.` e.g. `$.result.value`.)"""
187
+ objective: RuleObjective
188
+ """The objective by which runs are optimized for this rule"""
189
+ tolerance: RuleTolerance
190
+ """The tolerance by which runs can be accepted as a potential result
191
+ for an evaluation rule"""
192
+ index: int
193
+ """The index (non-negative integer) of the evalutation rule. Lower indicies
194
+ are evaluated first."""
195
+
196
+
197
+ class EnsembleDefinition(BaseModel):
198
+ """An ensemble definition for an application.
199
+
200
+ You can import the `EnsembleDefinition` class directly from `cloud`:
201
+
202
+ ```python
203
+ from nextmv.cloud import EnsembleDefinition
204
+ ```
205
+
206
+ A Nextmv Cloud ensemble definition represents a structure by which an
207
+ application can coordinate and execute, and determine the optimal result of
208
+ an ensemble run.
209
+
210
+ Parameters
211
+ ----------
212
+ id : str
213
+ The unique identifier of the ensemble definition.
214
+ application_id : str
215
+ ID of the application that this ensemble definition belongs to.
216
+ name : str
217
+ Human-readable name of the ensemble definition.
218
+ description : str
219
+ Detailed description of the ensemble definition.
220
+ run_groups : list[RunGroup], optional
221
+ The run groups that structure the execution of an ensemble run
222
+ rules : list[EvaluationRule], optional
223
+ The rules by which ensemble child runs are evaluated
224
+ to find an optimal result.
225
+ created_at : datetime
226
+ Timestamp when the ensemble definition was created.
227
+ updated_at : datetime
228
+ Timestamp when the ensemble definition was last updated.
229
+ """
230
+
231
+ id: str
232
+ """The unique identifier of the ensemble definition."""
233
+ application_id: str
234
+ """ID of the application that this ensemble definition belongs to."""
235
+ name: str = ""
236
+ """Human-readable name of the ensemble definition."""
237
+ description: str = ""
238
+ """Detailed description of the ensemble definition."""
239
+ run_groups: list[RunGroup]
240
+ """The run groups that structure the execution of an ensemble run"""
241
+ rules: list[EvaluationRule]
242
+ """The rules by which ensemble child runs are evaluated
243
+ to find an optimal result."""
244
+ created_at: datetime
245
+ """Timestamp when the ensemble definition was created."""
246
+ updated_at: datetime
247
+ """Timestamp when the ensemble definition was last updated."""
nextmv/cloud/input_set.py CHANGED
@@ -1,13 +1,128 @@
1
- """This module contains definitions for input sets."""
1
+ """Definitions for input sets and related cloud objects.
2
+
3
+ This module provides classes for managing inputs and input sets in the Nextmv Cloud.
4
+
5
+ Classes
6
+ -------
7
+ ManagedInput
8
+ An input created for experimenting with an application.
9
+ InputSet
10
+ A collection of inputs from associated runs.
11
+ """
2
12
 
3
13
  from datetime import datetime
4
- from typing import List
5
14
 
6
15
  from nextmv.base_model import BaseModel
16
+ from nextmv.run import Format
17
+
18
+
19
+ class ManagedInput(BaseModel):
20
+ """An input created for experimenting with an application.
21
+
22
+ You can import the `ManagedInput` class directly from `cloud`:
23
+
24
+ ```python
25
+ from nextmv.cloud import ManagedInput
26
+ ```
27
+
28
+ This class represents an input that was uploaded to the Nextmv Cloud
29
+ for experimentation purposes. It contains metadata about the input,
30
+ such as its ID, name, description, and creation time.
31
+
32
+ Parameters
33
+ ----------
34
+ id : str
35
+ Unique identifier of the input.
36
+ name : str, optional
37
+ User-defined name of the input.
38
+ description : str, optional
39
+ User-defined description of the input.
40
+ run_id : str, optional
41
+ Identifier of the run that created this input.
42
+ upload_id : str, optional
43
+ Identifier of the upload that created this input.
44
+ format : Format, optional
45
+ Format of the input (e.g., JSON, CSV).
46
+ created_at : datetime, optional
47
+ Timestamp when the input was created.
48
+ updated_at : datetime, optional
49
+ Timestamp when the input was last updated.
50
+
51
+ Examples
52
+ --------
53
+ >>> input = ManagedInput(id="inp_123456789")
54
+ >>> print(input.id)
55
+ inp_123456789
56
+ """
57
+
58
+ id: str
59
+ """ID of the input."""
60
+
61
+ name: str | None = None
62
+ """Name of the input."""
63
+ description: str | None = None
64
+ """Description of the input."""
65
+ run_id: str | None = None
66
+ """ID of the run that created the input."""
67
+ upload_id: str | None = None
68
+ """ID of the upload that created the input."""
69
+ format: Format | None = None
70
+ """Format of the input."""
71
+ created_at: datetime | None = None
72
+ """Creation time of the input."""
73
+ updated_at: datetime | None = None
74
+ """Last update time of the input."""
7
75
 
8
76
 
9
77
  class InputSet(BaseModel):
10
- """An input set is the collection of inputs from the associated runs."""
78
+ """A collection of inputs from associated runs.
79
+
80
+ You can import the `InputSet` class directly from `cloud`:
81
+
82
+ ```python
83
+ from nextmv.cloud import InputSet
84
+ ```
85
+
86
+ An input set aggregates multiple inputs used for experimentation with an application
87
+ in the Nextmv Cloud. It allows organizing and managing related inputs
88
+ for comparison and analysis.
89
+
90
+ Parameters
91
+ ----------
92
+ app_id : str
93
+ Identifier of the application that the input set belongs to.
94
+ created_at : datetime
95
+ Timestamp when the input set was created.
96
+ description : str
97
+ User-defined description of the input set.
98
+ id : str
99
+ Unique identifier of the input set.
100
+ input_ids : list[str]
101
+ List of identifiers of the inputs in the input set.
102
+ name : str
103
+ User-defined name of the input set.
104
+ updated_at : datetime
105
+ Timestamp when the input set was last updated.
106
+ inputs : list[ManagedInput]
107
+ List of ManagedInput objects contained in this input set.
108
+
109
+ Examples
110
+ --------
111
+ >>> input_set = InputSet(
112
+ ... app_id="app_123456789",
113
+ ... id="is_987654321",
114
+ ... name="My Input Set",
115
+ ... description="A collection of routing inputs",
116
+ ... input_ids=["inp_111", "inp_222"],
117
+ ... created_at=datetime.now(),
118
+ ... updated_at=datetime.now(),
119
+ ... inputs=[]
120
+ ... )
121
+ >>> print(input_set.name)
122
+ My Input Set
123
+ >>> print(len(input_set.input_ids))
124
+ 2
125
+ """
11
126
 
12
127
  app_id: str
13
128
  """ID of the application that the input set belongs to."""
@@ -17,9 +132,11 @@ class InputSet(BaseModel):
17
132
  """Description of the input set."""
18
133
  id: str
19
134
  """ID of the input set."""
20
- input_ids: List[str]
135
+ input_ids: list[str]
21
136
  """IDs of the inputs in the input set."""
22
137
  name: str
23
138
  """Name of the input set."""
24
139
  updated_at: datetime
25
140
  """Last update time of the input set."""
141
+ inputs: list[ManagedInput]
142
+ """List of inputs in the input set."""
@@ -0,0 +1,125 @@
1
+ """Classes for working with Nextmv Cloud Instances.
2
+
3
+ This module provides classes for interacting with instances in Nextmv Cloud.
4
+ It defines the core data structures for both instance configuration and the
5
+ instance itself.
6
+
7
+ Classes
8
+ -------
9
+ InstanceConfiguration
10
+ Configuration settings for a Nextmv Cloud instance.
11
+ Instance
12
+ Representation of a Nextmv Cloud instance tied to an application version.
13
+ """
14
+
15
+ from datetime import datetime
16
+
17
+ from nextmv.base_model import BaseModel
18
+
19
+
20
+ class InstanceConfiguration(BaseModel):
21
+ """Configuration for a Nextmv Cloud instance.
22
+
23
+ You can import the `InstanceConfiguration` class directly from `cloud`:
24
+
25
+ ```python
26
+ from nextmv.cloud import InstanceConfiguration
27
+ ```
28
+
29
+ This class represents the configuration settings that can be applied to a
30
+ Nextmv Cloud instance, including execution class, options, and secrets.
31
+
32
+ Parameters
33
+ ----------
34
+ execution_class : str, optional
35
+ The execution class for the instance, which determines compute resources.
36
+ options : dict, optional
37
+ Runtime options/parameters for the application.
38
+ secrets_collection_id : str, optional
39
+ ID of the secrets collection to use with this instance.
40
+
41
+ Examples
42
+ --------
43
+ >>> config = InstanceConfiguration(
44
+ ... execution_class="small",
45
+ ... options={"max_runtime": 30},
46
+ ... secrets_collection_id="sc_1234567890"
47
+ ... )
48
+ """
49
+
50
+ execution_class: str | None = None
51
+ """Execution class for the instance."""
52
+ options: dict | None = None
53
+ """Options of the app that the instance uses."""
54
+ secrets_collection_id: str | None = None
55
+ """ID of the secrets collection that the instance uses."""
56
+
57
+
58
+ class Instance(BaseModel):
59
+ """An instance of an application tied to a version with configuration.
60
+
61
+ You can import the `Instance` class directly from `cloud`:
62
+
63
+ ```python
64
+ from nextmv.cloud import Instance
65
+ ```
66
+
67
+ A Nextmv Cloud instance represents a deployable configuration of an application
68
+ version. Instances have their own unique identity and can be used to run jobs
69
+ with specific configurations.
70
+
71
+ Parameters
72
+ ----------
73
+ id : str
74
+ The unique identifier of the instance.
75
+ application_id : str
76
+ ID of the application that this instance belongs to.
77
+ version_id : str
78
+ ID of the application version this instance uses.
79
+ name : str
80
+ Human-readable name of the instance.
81
+ description : str
82
+ Detailed description of the instance.
83
+ configuration : InstanceConfiguration
84
+ Configuration settings for this instance.
85
+ locked : bool
86
+ Whether the instance is locked for modifications.
87
+ created_at : datetime
88
+ Timestamp when the instance was created.
89
+ updated_at : datetime
90
+ Timestamp when the instance was last updated.
91
+
92
+ Examples
93
+ --------
94
+ >>> from nextmv.cloud import Instance, InstanceConfiguration
95
+ >>> instance = Instance(
96
+ ... id="inst_1234567890",
97
+ ... application_id="app_1234567890",
98
+ ... version_id="ver_1234567890",
99
+ ... name="Production Routing Instance",
100
+ ... description="Instance for daily production routing jobs",
101
+ ... configuration=InstanceConfiguration(execution_class="small"),
102
+ ... locked=False,
103
+ ... created_at=datetime.now(),
104
+ ... updated_at=datetime.now()
105
+ ... )
106
+ """
107
+
108
+ id: str
109
+ """ID of the instance."""
110
+ application_id: str
111
+ """ID of the application that this is an instance of."""
112
+ version_id: str
113
+ """ID of the version that this instance is uses."""
114
+ name: str
115
+ """Name of the instance."""
116
+ description: str
117
+ """Description of the instance."""
118
+ configuration: InstanceConfiguration
119
+ """Configuration for the instance."""
120
+ locked: bool
121
+ """Whether the instance is locked."""
122
+ created_at: datetime
123
+ """Creation time of the instance."""
124
+ updated_at: datetime
125
+ """Last update time of the instance."""