nextmv 0.31.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 CHANGED
@@ -1 +1 @@
1
- __version__ = "v0.31.0"
1
+ __version__ = "v0.32.0"
nextmv/__init__.py CHANGED
@@ -3,8 +3,6 @@
3
3
  from .__about__ import __version__
4
4
  from .base_model import BaseModel as BaseModel
5
5
  from .base_model import from_dict as from_dict
6
- from .input import DEFAULT_INPUT_JSON_FILE as DEFAULT_INPUT_JSON_FILE
7
- from .input import INPUTS_KEY as INPUTS_KEY
8
6
  from .input import DataFile as DataFile
9
7
  from .input import Input as Input
10
8
  from .input import InputFormat as InputFormat
@@ -31,13 +29,6 @@ from .model import ModelConfiguration as ModelConfiguration
31
29
  from .options import Option as Option
32
30
  from .options import Options as Options
33
31
  from .options import Parameter as Parameter
34
- from .output import ASSETS_KEY as ASSETS_KEY
35
- from .output import DEFAULT_OUTPUT_JSON_FILE as DEFAULT_OUTPUT_JSON_FILE
36
- from .output import LOGS_FILE as LOGS_FILE
37
- from .output import LOGS_KEY as LOGS_KEY
38
- from .output import OUTPUTS_KEY as OUTPUTS_KEY
39
- from .output import SOLUTIONS_KEY as SOLUTIONS_KEY
40
- from .output import STATISTICS_KEY as STATISTICS_KEY
41
32
  from .output import Asset as Asset
42
33
  from .output import DataPoint as DataPoint
43
34
  from .output import LocalOutputWriter as LocalOutputWriter
@@ -66,13 +57,17 @@ from .run import Format as Format
66
57
  from .run import FormatInput as FormatInput
67
58
  from .run import FormatOutput as FormatOutput
68
59
  from .run import Metadata as Metadata
60
+ from .run import OptionsSummaryItem as OptionsSummaryItem
61
+ from .run import Run as Run
69
62
  from .run import RunConfiguration as RunConfiguration
70
63
  from .run import RunInformation as RunInformation
64
+ from .run import RunInfoStatistics as RunInfoStatistics
71
65
  from .run import RunLog as RunLog
72
66
  from .run import RunQueuing as RunQueuing
73
67
  from .run import RunResult as RunResult
74
68
  from .run import RunType as RunType
75
69
  from .run import RunTypeConfiguration as RunTypeConfiguration
70
+ from .run import StatisticsIndicator as StatisticsIndicator
76
71
  from .run import TrackedRun as TrackedRun
77
72
  from .run import TrackedRunStatus as TrackedRunStatus
78
73
  from .run import run_duration as run_duration
@@ -64,6 +64,7 @@ from nextmv.run import (
64
64
  Format,
65
65
  FormatInput,
66
66
  FormatOutput,
67
+ Run,
67
68
  RunConfiguration,
68
69
  RunInformation,
69
70
  RunLog,
@@ -289,7 +290,8 @@ class Application:
289
290
 
290
291
  def batch_experiment(self, batch_id: str) -> BatchExperiment:
291
292
  """
292
- Get a batch experiment.
293
+ Get a batch experiment. This method also returns the runs of the batch
294
+ experiment under the `.runs` attribute.
293
295
 
294
296
  Parameters
295
297
  ----------
@@ -318,7 +320,17 @@ class Application:
318
320
  endpoint=f"{self.experiments_endpoint}/batch/{batch_id}",
319
321
  )
320
322
 
321
- return BatchExperiment.from_dict(response.json())
323
+ exp = BatchExperiment.from_dict(response.json())
324
+
325
+ runs_response = self.client.request(
326
+ method="GET",
327
+ endpoint=f"{self.experiments_endpoint}/batch/{batch_id}/runs",
328
+ )
329
+
330
+ runs = [Run.from_dict(run) for run in runs_response.json().get("runs", [])]
331
+ exp.runs = runs
332
+
333
+ return exp
322
334
 
323
335
  def batch_experiment_metadata(self, batch_id: str) -> BatchExperimentMetadata:
324
336
  """
@@ -818,6 +830,28 @@ class Application:
818
830
 
819
831
  return [ManagedInput.from_dict(managed_input) for managed_input in response.json()]
820
832
 
833
+ def list_runs(self) -> list[Run]:
834
+ """
835
+ List all runs.
836
+
837
+ Returns
838
+ -------
839
+ list[Run]
840
+ List of runs.
841
+
842
+ Raises
843
+ ------
844
+ requests.HTTPError
845
+ If the response status code is not 2xx.
846
+ """
847
+
848
+ response = self.client.request(
849
+ method="GET",
850
+ endpoint=f"{self.endpoint}/runs",
851
+ )
852
+
853
+ return [Run.from_dict(run) for run in response.json().get("runs", [])]
854
+
821
855
  def list_scenario_tests(self) -> list[BatchExperimentMetadata]:
822
856
  """
823
857
  List all batch scenario tests. Scenario tests are based on the batch
@@ -2759,7 +2793,7 @@ class Application:
2759
2793
  Examples
2760
2794
  --------
2761
2795
  >>> from nextmv.cloud import Application
2762
- >>> from nextmv.cloud.run import TrackedRun
2796
+ >>> from nextmv import TrackedRun
2763
2797
  >>> app = Application(id="app_123")
2764
2798
  >>> tracked_run = TrackedRun(input={"data": [...]}, output={"solution": [...]})
2765
2799
  >>> run_id = app.track_run(tracked_run)
@@ -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):
@@ -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,5 +9,4 @@ python:
9
9
  # (e.g.: configs/*.json) is supported.
10
10
  files:
11
11
  - src/
12
-
13
- entrypoint: src/main.py
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)
nextmv/input.py CHANGED
@@ -21,12 +21,10 @@ Functions
21
21
  load
22
22
  Load input data using a specified loader.
23
23
 
24
- Constants
25
- ---------
24
+ Attributes
25
+ ----------
26
26
  INPUTS_KEY : str
27
27
  Key used for identifying inputs in the run.
28
- DEFAULT_INPUT_JSON_FILE : str
29
- Constant for the default input JSON file name.
30
28
  """
31
29
 
32
30
  import copy
@@ -47,10 +45,6 @@ INPUTS_KEY = "inputs"
47
45
  """
48
46
  Inputs key constant used for identifying inputs in the run.
49
47
  """
50
- DEFAULT_INPUT_JSON_FILE = "input.json"
51
- """
52
- Constant for the default input JSON file name.
53
- """
54
48
 
55
49
 
56
50
  class InputFormat(str, Enum):