nextmv 0.30.0__py3-none-any.whl → 0.32.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/__init__.py +35 -0
- nextmv/cloud/__init__.py +38 -33
- nextmv/cloud/account.py +1 -1
- nextmv/cloud/application.py +249 -484
- nextmv/cloud/batch_experiment.py +7 -1
- nextmv/cloud/input_set.py +1 -1
- nextmv/cloud/package.py +1 -1
- nextmv/cloud/url.py +73 -0
- nextmv/default_app/.gitignore +1 -0
- nextmv/default_app/README.md +17 -2
- nextmv/default_app/app.yaml +1 -0
- nextmv/default_app/input.json +5 -0
- nextmv/default_app/main.py +37 -0
- nextmv/default_app/src/main.py +2 -1
- nextmv/input.py +11 -1
- nextmv/local/__init__.py +5 -0
- nextmv/local/application.py +1173 -0
- nextmv/local/executor.py +713 -0
- nextmv/local/geojson_handler.py +323 -0
- nextmv/local/local.py +97 -0
- nextmv/local/plotly_handler.py +61 -0
- nextmv/local/runner.py +274 -0
- nextmv/{cloud/manifest.py → manifest.py} +110 -69
- nextmv/output.py +41 -8
- nextmv/polling.py +287 -0
- nextmv/run.py +1460 -0
- nextmv/{cloud/safe.py → safe.py} +35 -3
- nextmv/{cloud/status.py → status.py} +9 -9
- {nextmv-0.30.0.dist-info → nextmv-0.32.0.dist-info}/METADATA +5 -1
- nextmv-0.32.0.dist-info/RECORD +49 -0
- nextmv/cloud/run.py +0 -755
- nextmv-0.30.0.dist-info/RECORD +0 -37
- {nextmv-0.30.0.dist-info → nextmv-0.32.0.dist-info}/WHEEL +0 -0
- {nextmv-0.30.0.dist-info → nextmv-0.32.0.dist-info}/licenses/LICENSE +0 -0
nextmv/cloud/batch_experiment.py
CHANGED
|
@@ -21,6 +21,7 @@ from typing import Any, Optional
|
|
|
21
21
|
|
|
22
22
|
from nextmv.base_model import BaseModel
|
|
23
23
|
from nextmv.cloud.input_set import InputSet
|
|
24
|
+
from nextmv.run import Run
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class ExperimentStatus(str, Enum):
|
|
@@ -191,7 +192,10 @@ class BatchExperiment(BatchExperimentInformation):
|
|
|
191
192
|
instance_ids : list[str]
|
|
192
193
|
List of instance IDs used for the experiment.
|
|
193
194
|
grouped_distributional_summaries : list[dict[str, Any]], optional
|
|
194
|
-
Grouped distributional summaries of the batch experiment. Defaults to
|
|
195
|
+
Grouped distributional summaries of the batch experiment. Defaults to
|
|
196
|
+
None.
|
|
197
|
+
runs : list[Run], optional
|
|
198
|
+
List of runs in the batch experiment. Defaults to None.
|
|
195
199
|
"""
|
|
196
200
|
|
|
197
201
|
input_set_id: str
|
|
@@ -200,6 +204,8 @@ class BatchExperiment(BatchExperimentInformation):
|
|
|
200
204
|
"""List of instance IDs used for the experiment."""
|
|
201
205
|
grouped_distributional_summaries: Optional[list[dict[str, Any]]] = None
|
|
202
206
|
"""Grouped distributional summaries of the batch experiment."""
|
|
207
|
+
runs: Optional[list[Run]] = None
|
|
208
|
+
"""List of runs in the batch experiment."""
|
|
203
209
|
|
|
204
210
|
|
|
205
211
|
class BatchExperimentRun(BaseModel):
|
nextmv/cloud/input_set.py
CHANGED
nextmv/cloud/package.py
CHANGED
|
@@ -10,8 +10,8 @@ import tarfile
|
|
|
10
10
|
import tempfile
|
|
11
11
|
from typing import Optional
|
|
12
12
|
|
|
13
|
-
from nextmv.cloud.manifest import MANIFEST_FILE_NAME, Manifest, ManifestBuild, ManifestType
|
|
14
13
|
from nextmv.logger import log
|
|
14
|
+
from nextmv.manifest import MANIFEST_FILE_NAME, Manifest, ManifestBuild, ManifestType
|
|
15
15
|
from nextmv.model import Model, ModelConfiguration, _cleanup_python_model
|
|
16
16
|
|
|
17
17
|
_MANDATORY_FILES_PER_TYPE = {
|
nextmv/cloud/url.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module for declarations related to upload and download URLs in Nextmv Cloud.
|
|
3
|
+
|
|
4
|
+
Classes
|
|
5
|
+
-------
|
|
6
|
+
DownloadURL
|
|
7
|
+
Represents a download URL for fetching content from Nextmv Cloud.
|
|
8
|
+
UploadURL
|
|
9
|
+
Represents an upload URL for sending content to Nextmv Cloud.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from nextmv.base_model import BaseModel
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DownloadURL(BaseModel):
|
|
16
|
+
"""
|
|
17
|
+
Result of getting a download URL.
|
|
18
|
+
|
|
19
|
+
You can import the `DownloadURL` class directly from `cloud`:
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from nextmv.cloud import DownloadURL
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This class represents a download URL that can be used to fetch content
|
|
26
|
+
from Nextmv Cloud, typically used for downloading large run results.
|
|
27
|
+
|
|
28
|
+
Attributes
|
|
29
|
+
----------
|
|
30
|
+
url : str
|
|
31
|
+
URL to use for downloading the file.
|
|
32
|
+
|
|
33
|
+
Examples
|
|
34
|
+
--------
|
|
35
|
+
>>> download_url = DownloadURL(url="https://example.com/download")
|
|
36
|
+
>>> response = requests.get(download_url.url)
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
url: str
|
|
40
|
+
"""URL to use for downloading the file."""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class UploadURL(BaseModel):
|
|
44
|
+
"""
|
|
45
|
+
Result of getting an upload URL.
|
|
46
|
+
|
|
47
|
+
You can import the `UploadURL` class directly from `cloud`:
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from nextmv.cloud import UploadURL
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This class represents an upload URL that can be used to send data to
|
|
54
|
+
Nextmv Cloud, typically used for uploading large inputs for runs.
|
|
55
|
+
|
|
56
|
+
Attributes
|
|
57
|
+
----------
|
|
58
|
+
upload_id : str
|
|
59
|
+
ID of the upload, used to reference the uploaded content.
|
|
60
|
+
upload_url : str
|
|
61
|
+
URL to use for uploading the file.
|
|
62
|
+
|
|
63
|
+
Examples
|
|
64
|
+
--------
|
|
65
|
+
>>> upload_url = UploadURL(upload_id="123", upload_url="https://example.com/upload")
|
|
66
|
+
>>> with open("large_input.json", "rb") as f:
|
|
67
|
+
... requests.put(upload_url.upload_url, data=f)
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
upload_id: str
|
|
71
|
+
"""ID of the upload."""
|
|
72
|
+
upload_url: str
|
|
73
|
+
"""URL to use for uploading the file."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.nextmv
|
nextmv/default_app/README.md
CHANGED
|
@@ -4,6 +4,7 @@ This is the basic structure of a Nextmv application.
|
|
|
4
4
|
|
|
5
5
|
```text
|
|
6
6
|
├── app.yaml
|
|
7
|
+
├── main.py
|
|
7
8
|
├── README.md
|
|
8
9
|
├── requirements.txt
|
|
9
10
|
└── src
|
|
@@ -11,7 +12,21 @@ This is the basic structure of a Nextmv application.
|
|
|
11
12
|
|
|
12
13
|
* `app.yaml`: App manifest, containing the configuration to run the app
|
|
13
14
|
remotely on Nextmv Cloud.
|
|
15
|
+
* `main.py`: Entry point for the app.
|
|
14
16
|
* `README.md`: Description of the app.
|
|
15
17
|
* `requirements.txt`: Python dependencies for the app.
|
|
16
|
-
* `src/`: Source code for the app.
|
|
17
|
-
|
|
18
|
+
* `src/`: Source code for the app.
|
|
19
|
+
|
|
20
|
+
A sample input file is also provided as `input.json`.
|
|
21
|
+
|
|
22
|
+
1. Install packages.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip3 install -r requirements.txt
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. Run the app.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
cat input.json | python3 main.py
|
|
32
|
+
```
|
nextmv/default_app/app.yaml
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from src.visuals import create_visuals
|
|
2
|
+
|
|
3
|
+
import nextmv
|
|
4
|
+
|
|
5
|
+
# Read the input from stdin.
|
|
6
|
+
input = nextmv.load()
|
|
7
|
+
name = input.data["name"]
|
|
8
|
+
|
|
9
|
+
options = nextmv.Options(
|
|
10
|
+
nextmv.Option("details", bool, True, "Print details to logs. Default true.", False),
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
##### Insert model here
|
|
14
|
+
|
|
15
|
+
# Print logs that render in the run view in Nextmv Console.
|
|
16
|
+
message = f"Hello, {name}"
|
|
17
|
+
nextmv.log(message)
|
|
18
|
+
|
|
19
|
+
if options.details:
|
|
20
|
+
detail = f"You are {input.data['distance']} million km from the sun"
|
|
21
|
+
nextmv.log(detail)
|
|
22
|
+
|
|
23
|
+
assets = create_visuals(name, input.data["radius"], input.data["distance"])
|
|
24
|
+
|
|
25
|
+
# Write output and statistics.
|
|
26
|
+
output = nextmv.Output(
|
|
27
|
+
options=options,
|
|
28
|
+
solution={"message": message},
|
|
29
|
+
statistics=nextmv.Statistics(
|
|
30
|
+
result=nextmv.ResultStatistics(
|
|
31
|
+
value=1.23,
|
|
32
|
+
custom={"message": message},
|
|
33
|
+
),
|
|
34
|
+
),
|
|
35
|
+
assets=assets,
|
|
36
|
+
)
|
|
37
|
+
nextmv.write(output)
|
nextmv/default_app/src/main.py
CHANGED
|
@@ -24,7 +24,8 @@ assets = create_visuals(name, input.data["radius"], input.data["distance"])
|
|
|
24
24
|
|
|
25
25
|
# Write output and statistics.
|
|
26
26
|
output = nextmv.Output(
|
|
27
|
-
|
|
27
|
+
options=options,
|
|
28
|
+
solution={"message": message},
|
|
28
29
|
statistics=nextmv.Statistics(
|
|
29
30
|
result=nextmv.ResultStatistics(
|
|
30
31
|
value=1.23,
|
nextmv/input.py
CHANGED
|
@@ -20,6 +20,11 @@ Functions
|
|
|
20
20
|
---------
|
|
21
21
|
load
|
|
22
22
|
Load input data using a specified loader.
|
|
23
|
+
|
|
24
|
+
Attributes
|
|
25
|
+
----------
|
|
26
|
+
INPUTS_KEY : str
|
|
27
|
+
Key used for identifying inputs in the run.
|
|
23
28
|
"""
|
|
24
29
|
|
|
25
30
|
import copy
|
|
@@ -36,6 +41,11 @@ from nextmv._serialization import serialize_json
|
|
|
36
41
|
from nextmv.deprecated import deprecated
|
|
37
42
|
from nextmv.options import Options
|
|
38
43
|
|
|
44
|
+
INPUTS_KEY = "inputs"
|
|
45
|
+
"""
|
|
46
|
+
Inputs key constant used for identifying inputs in the run.
|
|
47
|
+
"""
|
|
48
|
+
|
|
39
49
|
|
|
40
50
|
class InputFormat(str, Enum):
|
|
41
51
|
"""
|
|
@@ -911,7 +921,7 @@ class LocalInputLoader(InputLoader):
|
|
|
911
921
|
If the path is not a directory or the default directory doesn't exist.
|
|
912
922
|
"""
|
|
913
923
|
|
|
914
|
-
dir_path =
|
|
924
|
+
dir_path = INPUTS_KEY
|
|
915
925
|
if path is not None and path != "":
|
|
916
926
|
if not os.path.isdir(path):
|
|
917
927
|
raise ValueError(f"path {path} is not a directory")
|