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.
@@ -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 None.
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
@@ -14,7 +14,7 @@ from datetime import datetime
14
14
  from typing import Optional
15
15
 
16
16
  from nextmv.base_model import BaseModel
17
- from nextmv.cloud.run import Format
17
+ from nextmv.run import Format
18
18
 
19
19
 
20
20
  class ManagedInput(BaseModel):
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
@@ -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. The `main.py` file is the entry point for
17
- the app.
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
+ ```
@@ -9,3 +9,4 @@ python:
9
9
  # (e.g.: configs/*.json) is supported.
10
10
  files:
11
11
  - src/
12
+ - main.py
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "Patches",
3
+ "radius": 6378,
4
+ "distance": 147.6
5
+ }
@@ -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)
@@ -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
- solution=None,
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 = "inputs"
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")
@@ -0,0 +1,5 @@
1
+ """
2
+ Functionality for locally simulating the Nextmv Cloud.
3
+ """
4
+
5
+ from .application import Application as Application