nextmv 0.18.0__py3-none-any.whl → 1.0.0.dev2__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 (175) hide show
  1. nextmv/__about__.py +1 -1
  2. nextmv/__entrypoint__.py +8 -13
  3. nextmv/__init__.py +53 -0
  4. nextmv/_serialization.py +96 -0
  5. nextmv/base_model.py +54 -9
  6. nextmv/cli/CONTRIBUTING.md +511 -0
  7. nextmv/cli/__init__.py +0 -0
  8. nextmv/cli/cloud/__init__.py +47 -0
  9. nextmv/cli/cloud/acceptance/__init__.py +27 -0
  10. nextmv/cli/cloud/acceptance/create.py +393 -0
  11. nextmv/cli/cloud/acceptance/delete.py +68 -0
  12. nextmv/cli/cloud/acceptance/get.py +104 -0
  13. nextmv/cli/cloud/acceptance/list.py +62 -0
  14. nextmv/cli/cloud/acceptance/update.py +95 -0
  15. nextmv/cli/cloud/account/__init__.py +28 -0
  16. nextmv/cli/cloud/account/create.py +83 -0
  17. nextmv/cli/cloud/account/delete.py +60 -0
  18. nextmv/cli/cloud/account/get.py +66 -0
  19. nextmv/cli/cloud/account/update.py +70 -0
  20. nextmv/cli/cloud/app/__init__.py +35 -0
  21. nextmv/cli/cloud/app/create.py +141 -0
  22. nextmv/cli/cloud/app/delete.py +58 -0
  23. nextmv/cli/cloud/app/exists.py +44 -0
  24. nextmv/cli/cloud/app/get.py +66 -0
  25. nextmv/cli/cloud/app/list.py +61 -0
  26. nextmv/cli/cloud/app/push.py +137 -0
  27. nextmv/cli/cloud/app/update.py +124 -0
  28. nextmv/cli/cloud/batch/__init__.py +29 -0
  29. nextmv/cli/cloud/batch/create.py +454 -0
  30. nextmv/cli/cloud/batch/delete.py +68 -0
  31. nextmv/cli/cloud/batch/get.py +104 -0
  32. nextmv/cli/cloud/batch/list.py +63 -0
  33. nextmv/cli/cloud/batch/metadata.py +66 -0
  34. nextmv/cli/cloud/batch/update.py +95 -0
  35. nextmv/cli/cloud/data/__init__.py +26 -0
  36. nextmv/cli/cloud/data/upload.py +162 -0
  37. nextmv/cli/cloud/ensemble/__init__.py +31 -0
  38. nextmv/cli/cloud/ensemble/create.py +414 -0
  39. nextmv/cli/cloud/ensemble/delete.py +67 -0
  40. nextmv/cli/cloud/ensemble/get.py +65 -0
  41. nextmv/cli/cloud/ensemble/update.py +103 -0
  42. nextmv/cli/cloud/input_set/__init__.py +30 -0
  43. nextmv/cli/cloud/input_set/create.py +170 -0
  44. nextmv/cli/cloud/input_set/get.py +63 -0
  45. nextmv/cli/cloud/input_set/list.py +63 -0
  46. nextmv/cli/cloud/input_set/update.py +123 -0
  47. nextmv/cli/cloud/instance/__init__.py +35 -0
  48. nextmv/cli/cloud/instance/create.py +290 -0
  49. nextmv/cli/cloud/instance/delete.py +62 -0
  50. nextmv/cli/cloud/instance/exists.py +39 -0
  51. nextmv/cli/cloud/instance/get.py +62 -0
  52. nextmv/cli/cloud/instance/list.py +60 -0
  53. nextmv/cli/cloud/instance/update.py +216 -0
  54. nextmv/cli/cloud/managed_input/__init__.py +31 -0
  55. nextmv/cli/cloud/managed_input/create.py +146 -0
  56. nextmv/cli/cloud/managed_input/delete.py +65 -0
  57. nextmv/cli/cloud/managed_input/get.py +63 -0
  58. nextmv/cli/cloud/managed_input/list.py +60 -0
  59. nextmv/cli/cloud/managed_input/update.py +97 -0
  60. nextmv/cli/cloud/run/__init__.py +37 -0
  61. nextmv/cli/cloud/run/cancel.py +37 -0
  62. nextmv/cli/cloud/run/create.py +530 -0
  63. nextmv/cli/cloud/run/get.py +199 -0
  64. nextmv/cli/cloud/run/input.py +86 -0
  65. nextmv/cli/cloud/run/list.py +80 -0
  66. nextmv/cli/cloud/run/logs.py +167 -0
  67. nextmv/cli/cloud/run/metadata.py +67 -0
  68. nextmv/cli/cloud/run/track.py +501 -0
  69. nextmv/cli/cloud/scenario/__init__.py +29 -0
  70. nextmv/cli/cloud/scenario/create.py +451 -0
  71. nextmv/cli/cloud/scenario/delete.py +65 -0
  72. nextmv/cli/cloud/scenario/get.py +102 -0
  73. nextmv/cli/cloud/scenario/list.py +63 -0
  74. nextmv/cli/cloud/scenario/metadata.py +67 -0
  75. nextmv/cli/cloud/scenario/update.py +93 -0
  76. nextmv/cli/cloud/secrets/__init__.py +33 -0
  77. nextmv/cli/cloud/secrets/create.py +206 -0
  78. nextmv/cli/cloud/secrets/delete.py +67 -0
  79. nextmv/cli/cloud/secrets/get.py +66 -0
  80. nextmv/cli/cloud/secrets/list.py +60 -0
  81. nextmv/cli/cloud/secrets/update.py +147 -0
  82. nextmv/cli/cloud/shadow/__init__.py +33 -0
  83. nextmv/cli/cloud/shadow/create.py +184 -0
  84. nextmv/cli/cloud/shadow/delete.py +68 -0
  85. nextmv/cli/cloud/shadow/get.py +61 -0
  86. nextmv/cli/cloud/shadow/list.py +63 -0
  87. nextmv/cli/cloud/shadow/metadata.py +66 -0
  88. nextmv/cli/cloud/shadow/start.py +43 -0
  89. nextmv/cli/cloud/shadow/stop.py +43 -0
  90. nextmv/cli/cloud/shadow/update.py +95 -0
  91. nextmv/cli/cloud/upload/__init__.py +22 -0
  92. nextmv/cli/cloud/upload/create.py +39 -0
  93. nextmv/cli/cloud/version/__init__.py +33 -0
  94. nextmv/cli/cloud/version/create.py +97 -0
  95. nextmv/cli/cloud/version/delete.py +62 -0
  96. nextmv/cli/cloud/version/exists.py +39 -0
  97. nextmv/cli/cloud/version/get.py +62 -0
  98. nextmv/cli/cloud/version/list.py +60 -0
  99. nextmv/cli/cloud/version/update.py +92 -0
  100. nextmv/cli/community/__init__.py +24 -0
  101. nextmv/cli/community/clone.py +270 -0
  102. nextmv/cli/community/list.py +265 -0
  103. nextmv/cli/configuration/__init__.py +23 -0
  104. nextmv/cli/configuration/config.py +195 -0
  105. nextmv/cli/configuration/create.py +94 -0
  106. nextmv/cli/configuration/delete.py +67 -0
  107. nextmv/cli/configuration/list.py +77 -0
  108. nextmv/cli/main.py +188 -0
  109. nextmv/cli/message.py +153 -0
  110. nextmv/cli/options.py +206 -0
  111. nextmv/cli/version.py +38 -0
  112. nextmv/cloud/__init__.py +71 -17
  113. nextmv/cloud/acceptance_test.py +757 -51
  114. nextmv/cloud/account.py +406 -17
  115. nextmv/cloud/application/__init__.py +957 -0
  116. nextmv/cloud/application/_acceptance.py +419 -0
  117. nextmv/cloud/application/_batch_scenario.py +860 -0
  118. nextmv/cloud/application/_ensemble.py +251 -0
  119. nextmv/cloud/application/_input_set.py +227 -0
  120. nextmv/cloud/application/_instance.py +289 -0
  121. nextmv/cloud/application/_managed_input.py +227 -0
  122. nextmv/cloud/application/_run.py +1393 -0
  123. nextmv/cloud/application/_secrets.py +294 -0
  124. nextmv/cloud/application/_shadow.py +314 -0
  125. nextmv/cloud/application/_utils.py +54 -0
  126. nextmv/cloud/application/_version.py +303 -0
  127. nextmv/cloud/assets.py +48 -0
  128. nextmv/cloud/batch_experiment.py +294 -33
  129. nextmv/cloud/client.py +307 -66
  130. nextmv/cloud/ensemble.py +247 -0
  131. nextmv/cloud/input_set.py +120 -2
  132. nextmv/cloud/instance.py +133 -8
  133. nextmv/cloud/integration.py +533 -0
  134. nextmv/cloud/package.py +168 -53
  135. nextmv/cloud/scenario.py +410 -0
  136. nextmv/cloud/secrets.py +234 -0
  137. nextmv/cloud/shadow.py +190 -0
  138. nextmv/cloud/url.py +73 -0
  139. nextmv/cloud/version.py +132 -4
  140. nextmv/default_app/.gitignore +1 -0
  141. nextmv/default_app/README.md +32 -0
  142. nextmv/default_app/app.yaml +12 -0
  143. nextmv/default_app/input.json +5 -0
  144. nextmv/default_app/main.py +37 -0
  145. nextmv/default_app/requirements.txt +2 -0
  146. nextmv/default_app/src/__init__.py +0 -0
  147. nextmv/default_app/src/visuals.py +36 -0
  148. nextmv/deprecated.py +47 -0
  149. nextmv/input.py +861 -90
  150. nextmv/local/__init__.py +5 -0
  151. nextmv/local/application.py +1251 -0
  152. nextmv/local/executor.py +1042 -0
  153. nextmv/local/geojson_handler.py +323 -0
  154. nextmv/local/local.py +97 -0
  155. nextmv/local/plotly_handler.py +61 -0
  156. nextmv/local/runner.py +274 -0
  157. nextmv/logger.py +80 -9
  158. nextmv/manifest.py +1466 -0
  159. nextmv/model.py +241 -66
  160. nextmv/options.py +708 -115
  161. nextmv/output.py +1301 -274
  162. nextmv/polling.py +325 -0
  163. nextmv/run.py +1702 -0
  164. nextmv/safe.py +145 -0
  165. nextmv/status.py +122 -0
  166. nextmv-1.0.0.dev2.dist-info/METADATA +311 -0
  167. nextmv-1.0.0.dev2.dist-info/RECORD +170 -0
  168. {nextmv-0.18.0.dist-info → nextmv-1.0.0.dev2.dist-info}/WHEEL +1 -1
  169. nextmv-1.0.0.dev2.dist-info/entry_points.txt +2 -0
  170. nextmv/cloud/application.py +0 -1405
  171. nextmv/cloud/manifest.py +0 -234
  172. nextmv/cloud/status.py +0 -29
  173. nextmv-0.18.0.dist-info/METADATA +0 -770
  174. nextmv-0.18.0.dist-info/RECORD +0 -25
  175. {nextmv-0.18.0.dist-info → nextmv-1.0.0.dev2.dist-info}/licenses/LICENSE +0 -0
nextmv/cloud/manifest.py DELETED
@@ -1,234 +0,0 @@
1
- """Module with the logic for handling an app manifest."""
2
-
3
- import os
4
- from enum import Enum
5
- from typing import Any, Optional
6
-
7
- import yaml
8
- from pydantic import AliasChoices, Field
9
-
10
- from nextmv.base_model import BaseModel
11
- from nextmv.model import _REQUIREMENTS_FILE, ModelConfiguration
12
-
13
- FILE_NAME = "app.yaml"
14
- """Name of the app manifest file."""
15
-
16
-
17
- class ManifestType(str, Enum):
18
- """Type of application in the manifest, based on the programming
19
- language."""
20
-
21
- PYTHON = "python"
22
- """Python format"""
23
- GO = "go"
24
- """Go format"""
25
- JAVA = "java"
26
- """Java format"""
27
-
28
-
29
- class ManifestRuntime(str, Enum):
30
- """Runtime (environment) where the app will be run on Nextmv Cloud."""
31
-
32
- DEFAULT = "ghcr.io/nextmv-io/runtime/default:latest"
33
- """This runtime is used to run compiled applications such as Go binaries."""
34
- PYTHON = "ghcr.io/nextmv-io/runtime/python:3.11"
35
- """
36
- This runtime is used as the basis for all other Python runtimes and Python
37
- applications.
38
- """
39
- JAVA = "ghcr.io/nextmv-io/runtime/java:latest"
40
- """This runtime is used to run Java applications."""
41
- PYOMO = "ghcr.io/nextmv-io/runtime/pyomo:latest"
42
- """This runtime provisions Python packages to run Pyomo applications."""
43
- HEXALY = "ghcr.io/nextmv-io/runtime/hexaly:latest"
44
- """
45
- Based on the python runtime, it provisions (pre-installs) the Hexaly solver
46
- to run Python applications.
47
- """
48
-
49
-
50
- class ManifestBuild(BaseModel):
51
- """Build-specific attributes."""
52
-
53
- command: Optional[str] = None
54
- """
55
- The command to run to build the app. This command will be executed without
56
- a shell, i.e., directly. The command must exit with a status of 0 to
57
- continue the push process of the app to Nextmv Cloud. This command is
58
- executed prior to the pre-push command.
59
- """
60
- environment: Optional[dict[str, Any]] = None
61
- """
62
- Environment variables to set when running the build command given as
63
- key-value pairs.
64
- """
65
-
66
- def environment_to_dict(self) -> dict[str, str]:
67
- """
68
- Convert the environment variables to a dictionary.
69
-
70
- Returns
71
- -------
72
- dict[str, str]
73
- The environment variables as a dictionary.
74
-
75
- """
76
-
77
- if self.environment is None:
78
- return {}
79
-
80
- return {key: str(value) for key, value in self.environment.items()}
81
-
82
-
83
- class ManifestPythonModel(BaseModel):
84
- """Model-specific instructions for a Python app."""
85
-
86
- name: str
87
- """The name of the decision model."""
88
- options: Optional[list[dict[str, Any]]] = None
89
- """
90
- Options for the decision model. This is a data representation of the
91
- `nextmv.Options` class. It consists of a list of dicts. Each dict
92
- represents the `nextmv.Parameter` class. It is used to be able to
93
- reconstruct an Options object from data when loading a decision model.
94
- """
95
-
96
-
97
- class ManifestPython(BaseModel):
98
- """Python-specific instructions."""
99
-
100
- pip_requirements: Optional[str] = Field(
101
- serialization_alias="pip-requirements",
102
- validation_alias=AliasChoices("pip-requirements", "pip_requirements"),
103
- default=None,
104
- )
105
- """
106
- Path to a requirements.txt file containing (additional) Python
107
- dependencies that will be bundled with the app.
108
- """
109
- model: Optional[ManifestPythonModel] = None
110
- """
111
- Information about an encoded decision model as handlded via mlflow. This
112
- information is used to load the decision model from the app bundle.
113
- """
114
-
115
-
116
- class Manifest(BaseModel):
117
- """
118
- An application that runs on the Nextmv Platform must contain a file named
119
- `app.yaml` which is known as the app manifest. This file is used to specify
120
- the execution environment for the app.
121
-
122
- This class represents the app manifest and allows you to load it from a
123
- file or create it programmatically.
124
- """
125
-
126
- files: list[str]
127
- """Mandatory. The files to include (or exclude) in the app."""
128
-
129
- runtime: ManifestRuntime = ManifestRuntime.PYTHON
130
- """
131
- Mandatory. The runtime to use for the app, it provides the environment in
132
- which the app runs.
133
- """
134
- type: ManifestType = ManifestType.PYTHON
135
- """Mandatory. Type of application, based on the programming language."""
136
- build: Optional[ManifestBuild] = None
137
- """
138
- Optional. Build-specific attributes. The build.command to run to build the
139
- app. This command will be executed without a shell, i.e., directly. The
140
- command must exit with a status of 0 to continue the push process of the
141
- app to Nextmv Cloud. This command is executed prior to the pre-push
142
- command. The build.environment is used to set environment variables when
143
- running the build command given as key-value pairs.
144
- """
145
- pre_push: Optional[str] = Field(
146
- serialization_alias="pre-push",
147
- validation_alias=AliasChoices("pre-push", "pre_push"),
148
- default=None,
149
- )
150
- """
151
- Optional. A command to run before the app is pushed to the Nextmv Cloud.
152
- This command can be used to compile a binary, run tests or similar tasks.
153
- One difference with what is specified under build, is that the command will
154
- be executed via the shell (i.e., bash -c on Linux & macOS or cmd /c on
155
- Windows). The command must exit with a status of 0 to continue the push
156
- process. This command is executed just before the app gets bundled and
157
- pushed (after the build command).
158
- """
159
- python: Optional[ManifestPython] = None
160
- """
161
- Optional. Only for Python apps. Contains further Python-specific
162
- attributes.
163
- """
164
-
165
- @classmethod
166
- def from_yaml(cls, dirpath: str) -> "Manifest":
167
- """
168
- Load a manifest from a YAML file.
169
-
170
- Parameters
171
- ----------
172
- dirpath : str
173
- Path to the directory containing the app.yaml file.
174
-
175
- Returns
176
- -------
177
- Manifest
178
- The loaded manifest.
179
-
180
- """
181
-
182
- with open(os.path.join(dirpath, FILE_NAME)) as file:
183
- raw_manifest = yaml.safe_load(file)
184
-
185
- return cls.from_dict(raw_manifest)
186
-
187
- def to_yaml(self, dirpath: str) -> None:
188
- """
189
- Write the manifest to a YAML file.
190
-
191
- Parameters
192
- ----------
193
- dirpath : str
194
- Path to the directory where the app.yaml file will be written.
195
-
196
- """
197
-
198
- with open(os.path.join(dirpath, FILE_NAME), "w") as file:
199
- yaml.dump(self.to_dict(), file)
200
-
201
- @classmethod
202
- def from_model_configuration(cls, model_configuration: ModelConfiguration) -> "Manifest":
203
- """
204
- Create a Python manifest from a Python model configuration.
205
-
206
- Parameters
207
- ----------
208
- model_configuration : ModelConfiguration
209
- The model configuration.
210
-
211
- Returns
212
- -------
213
- Manifest
214
- The Python manifest.
215
- """
216
-
217
- manifest_python_dict = {
218
- "pip-requirements": _REQUIREMENTS_FILE,
219
- "model": {
220
- "name": model_configuration.name,
221
- },
222
- }
223
-
224
- if model_configuration.options is not None:
225
- manifest_python_dict["model"]["options"] = model_configuration.options.parameters_dict()
226
-
227
- manifest_python = ManifestPython.from_dict(manifest_python_dict)
228
-
229
- return cls(
230
- files=["main.py", f"{model_configuration.name}/**"],
231
- runtime=ManifestRuntime.PYTHON,
232
- type=ManifestType.PYTHON,
233
- python=manifest_python,
234
- )
nextmv/cloud/status.py DELETED
@@ -1,29 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class Status(str, Enum):
5
- """Status of a run. Deprecated: use StatusV2."""
6
-
7
- failed = "failed"
8
- """Run failed."""
9
- running = "running"
10
- """Run is running."""
11
- succeeded = "succeeded"
12
- """Run succeeded."""
13
-
14
-
15
- class StatusV2(str, Enum):
16
- """Status of a run."""
17
-
18
- canceled = "canceled"
19
- """Run was canceled."""
20
- failed = "failed"
21
- """Run failed."""
22
- none = "none"
23
- """Run has no status."""
24
- queued = "queued"
25
- """Run is queued."""
26
- running = "running"
27
- """Run is running."""
28
- succeeded = "succeeded"
29
- """Run succeeded."""