Application Module¶
This section documents the application components of the Nextmv Cloud API.
application
¶
Application module for interacting with Nextmv Cloud applications.
This module provides functionality to interact with applications in Nextmv Cloud, including application management, running applications, and managing experiments and inputs.
CLASS | DESCRIPTION |
---|---|
DownloadURL |
Result of getting a download URL. |
PollingOptions |
Options for polling when waiting for run results. |
UploadURL |
Result of getting an upload URL. |
Application |
Class for interacting with applications in Nextmv Cloud. |
FUNCTION | DESCRIPTION |
---|---|
poll |
Function to poll for results with configurable options. |
Application
dataclass
¶
Application(
client: Client,
id: str,
default_instance_id: str = None,
endpoint: str = "v1/applications/{id}",
experiments_endpoint: str = "{base}/experiments",
)
A published decision model that can be executed.
You can import the Application
class directly from cloud
:
This class represents an application in Nextmv Cloud, providing methods to interact with the application, run it with different inputs, manage versions, instances, experiments, and more.
PARAMETER | DESCRIPTION |
---|---|
|
Client to use for interacting with the Nextmv Cloud API.
TYPE:
|
|
ID of the application.
TYPE:
|
|
Default instance ID to use for submitting runs.
TYPE:
|
|
Base endpoint for the application.
TYPE:
|
|
Base endpoint for the experiments in the application.
TYPE:
|
Examples:
>>> from nextmv.cloud import Client, Application
>>> client = Client(api_key="your-api-key")
>>> app = Application(client=client, id="your-app-id")
>>> # Retrieve app information
>>> instances = app.list_instances()
acceptance_test
¶
acceptance_test(acceptance_test_id: str) -> AcceptanceTest
Retrieve details of an acceptance test.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the acceptance test to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AcceptanceTest
|
The requested acceptance test details. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
acceptance_test_with_polling
¶
acceptance_test_with_polling(
acceptance_test_id: str,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
) -> AcceptanceTest
Retrieve details of an acceptance test using polling.
Retrieves the result of an acceptance test. This method polls for the result until the test finishes executing or the polling strategy is exhausted.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the acceptance test to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AcceptanceTest
|
The requested acceptance test details. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
batch_experiment
¶
batch_experiment(batch_id: str) -> BatchExperiment
Get a batch experiment.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the batch experiment.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperiment
|
The requested batch experiment details. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
batch_experiment_metadata
¶
batch_experiment_metadata(
batch_id: str,
) -> BatchExperimentMetadata
Get metadata for a batch experiment.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the batch experiment.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperimentMetadata
|
The requested batch experiment metadata. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> metadata = app.batch_experiment_metadata("batch-123")
>>> print(metadata.name)
'My Batch Experiment'
Source code in nextmv/nextmv/cloud/application.py
batch_experiment_with_polling
¶
batch_experiment_with_polling(
batch_id: str,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
) -> BatchExperiment
Get a batch experiment with polling.
Retrieves the result of an experiment. This method polls for the result until the experiment finishes executing or the polling strategy is exhausted.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the batch experiment.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperiment
|
The requested batch experiment details. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> batch_exp = app.batch_experiment_with_polling("batch-123")
>>> print(batch_exp.name)
'My Batch Experiment'
Source code in nextmv/nextmv/cloud/application.py
cancel_run
¶
cancel_run(run_id: str) -> None
Cancel a run.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the run to cancel.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
default_instance_id
class-attribute
instance-attribute
¶
Default instance ID to use for submitting runs.
delete
¶
Delete the application.
Permanently removes the application from Nextmv Cloud.
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
delete_acceptance_test
¶
delete_acceptance_test(acceptance_test_id: str) -> None
Delete an acceptance test.
Deletes an acceptance test along with all the associated information such as the underlying batch experiment.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the acceptance test to delete.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
delete_batch_experiment
¶
delete_batch_experiment(batch_id: str) -> None
Delete a batch experiment.
Deletes a batch experiment along with all the associated information, such as its runs.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the batch experiment to delete.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
delete_scenario_test
¶
delete_scenario_test(scenario_test_id: str) -> None
Delete a scenario test.
Deletes a scenario test. Scenario tests are based on the batch
experiments API, so this function summons delete_batch_experiment
.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the scenario test to delete.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
delete_secrets_collection
¶
delete_secrets_collection(
secrets_collection_id: str,
) -> None
Delete a secrets collection.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the secrets collection to delete.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
endpoint
class-attribute
instance-attribute
¶
Base endpoint for the application.
exists
staticmethod
¶
Check if an application exists.
PARAMETER | DESCRIPTION |
---|---|
|
Client to use for interacting with the Nextmv Cloud API.
TYPE:
|
|
ID of the application to check.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the application exists, False otherwise. |
Examples:
>>> from nextmv.cloud import Client
>>> client = Client(api_key="your-api-key")
>>> Application.exists(client, "app-123")
True
Source code in nextmv/nextmv/cloud/application.py
experiments_endpoint
class-attribute
instance-attribute
¶
Base endpoint for the experiments in the application.
input_set
¶
input_set(input_set_id: str) -> InputSet
Get an input set.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the input set to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
InputSet
|
The requested input set. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
instance
¶
instance(instance_id: str) -> Instance
Get an instance.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the instance to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Instance
|
The requested instance details. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
instance_exists
¶
instance_exists(instance_id: str) -> bool
Check if an instance exists.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the instance to check.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the instance exists, False otherwise. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
list_acceptance_tests
¶
List all acceptance tests.
RETURNS | DESCRIPTION |
---|---|
list[AcceptanceTest]
|
List of all acceptance tests associated with this application. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> tests = app.list_acceptance_tests()
>>> for test in tests:
... print(test.name)
'Test 1'
'Test 2'
Source code in nextmv/nextmv/cloud/application.py
list_batch_experiments
¶
List all batch experiments.
RETURNS | DESCRIPTION |
---|---|
list[BatchExperimentMetadata]
|
List of batch experiments. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
list_input_sets
¶
List all input sets.
RETURNS | DESCRIPTION |
---|---|
list[InputSet]
|
List of all input sets associated with this application. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> input_sets = app.list_input_sets()
>>> for input_set in input_sets:
... print(input_set.name)
'Input Set 1'
'Input Set 2'
Source code in nextmv/nextmv/cloud/application.py
list_instances
¶
List all instances.
RETURNS | DESCRIPTION |
---|---|
list[Instance]
|
List of all instances associated with this application. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> instances = app.list_instances()
>>> for instance in instances:
... print(instance.name)
'Development Instance'
'Production Instance'
Source code in nextmv/nextmv/cloud/application.py
list_managed_inputs
¶
List all managed inputs.
RETURNS | DESCRIPTION |
---|---|
list[ManagedInput]
|
List of managed inputs. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
list_scenario_tests
¶
List all batch scenario tests. Scenario tests are based on the batch
experiments API, so this function returns the same information as
list_batch_experiments
, albeit using a different query parameter.
RETURNS | DESCRIPTION |
---|---|
list[BatchExperimentMetadata]
|
List of scenario tests. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
list_secrets_collections
¶
List all secrets collections.
RETURNS | DESCRIPTION |
---|---|
list[SecretsCollectionSummary]
|
List of all secrets collections associated with this application. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> collections = app.list_secrets_collections()
>>> for collection in collections:
... print(collection.name)
'API Keys'
'Database Credentials'
Source code in nextmv/nextmv/cloud/application.py
list_versions
¶
List all versions.
RETURNS | DESCRIPTION |
---|---|
list[Version]
|
List of all versions associated with this application. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> versions = app.list_versions()
>>> for version in versions:
... print(version.name)
'v1.0.0'
'v1.1.0'
Source code in nextmv/nextmv/cloud/application.py
managed_input
¶
managed_input(managed_input_id: str) -> ManagedInput
Get a managed input.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the managed input.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ManagedInput
|
The managed input. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
new
classmethod
¶
new(
client: Client,
name: str,
id: Optional[str] = None,
description: Optional[str] = None,
is_workflow: Optional[bool] = None,
exist_ok: bool = False,
) -> Application
Create a new application directly in Nextmv Cloud.
The application is created as an empty shell, and executable code must be pushed to the app before running it remotely.
PARAMETER | DESCRIPTION |
---|---|
|
Client to use for interacting with the Nextmv Cloud API.
TYPE:
|
|
Name of the application.
TYPE:
|
|
ID of the application. Will be generated if not provided.
TYPE:
|
|
Description of the application.
TYPE:
|
|
Whether the application is a Decision Workflow.
TYPE:
|
|
If True and an application with the same ID already exists, return the existing application instead of creating a new one.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Application
|
The newly created (or existing) application. |
Examples:
>>> from nextmv.cloud import Client
>>> client = Client(api_key="your-api-key")
>>> app = Application.new(client=client, name="My New App", id="my-app")
Source code in nextmv/nextmv/cloud/application.py
new_acceptance_test
¶
new_acceptance_test(
candidate_instance_id: str,
baseline_instance_id: str,
id: str,
metrics: list[Union[Metric, dict[str, Any]]],
name: str,
input_set_id: Optional[str] = None,
description: Optional[str] = None,
) -> AcceptanceTest
Create a new acceptance test.
The acceptance test is based on a batch experiment. If you already started a batch experiment, you don't need to provide the input_set_id parameter. In that case, the ID of the acceptance test and the batch experiment must be the same. If the batch experiment does not exist, you can provide the input_set_id parameter and a new batch experiment will be created for you.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the candidate instance.
TYPE:
|
|
ID of the baseline instance.
TYPE:
|
|
ID of the acceptance test.
TYPE:
|
|
List of metrics to use for the acceptance test.
TYPE:
|
|
Name of the acceptance test.
TYPE:
|
|
ID of the input set to use for the underlying batch experiment, in case it hasn't been started.
TYPE:
|
|
Description of the acceptance test.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AcceptanceTest
|
The created acceptance test. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If the batch experiment ID does not match the acceptance test ID. |
Source code in nextmv/nextmv/cloud/application.py
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 |
|
new_acceptance_test_with_result
¶
new_acceptance_test_with_result(
candidate_instance_id: str,
baseline_instance_id: str,
id: str,
metrics: list[Union[Metric, dict[str, Any]]],
name: str,
input_set_id: Optional[str] = None,
description: Optional[str] = None,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
) -> AcceptanceTest
Create a new acceptance test and poll for the result.
This is a convenience method that combines the new_acceptance_test with polling logic to check when the acceptance test is done.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the candidate instance.
TYPE:
|
|
ID of the baseline instance.
TYPE:
|
|
ID of the acceptance test.
TYPE:
|
|
List of metrics to use for the acceptance test.
TYPE:
|
|
Name of the acceptance test.
TYPE:
|
|
ID of the input set to use for the underlying batch experiment, in case it hasn't been started.
TYPE:
|
|
Description of the acceptance test.
TYPE:
|
|
Options to use when polling for the acceptance test result.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AcceptanceTest
|
The completed acceptance test with results. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
TimeoutError
|
If the acceptance test does not succeed after the polling strategy is exhausted based on time duration. |
RuntimeError
|
If the acceptance test does not succeed after the polling strategy is exhausted based on number of tries. |
Examples:
>>> test = app.new_acceptance_test_with_result(
... candidate_instance_id="candidate-123",
... baseline_instance_id="baseline-456",
... id="test-789",
... metrics=[Metric(name="objective", type="numeric")],
... name="Performance Test",
... input_set_id="input-set-123"
... )
>>> print(test.status)
'completed'
Source code in nextmv/nextmv/cloud/application.py
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
|
new_batch_experiment
¶
new_batch_experiment(
name: str,
input_set_id: Optional[str] = None,
instance_ids: Optional[list[str]] = None,
description: Optional[str] = None,
id: Optional[str] = None,
option_sets: Optional[dict[str, dict[str, str]]] = None,
runs: Optional[
list[Union[BatchExperimentRun, dict[str, Any]]]
] = None,
type: Optional[str] = "batch",
) -> str
Create a new batch experiment.
PARAMETER | DESCRIPTION |
---|---|
|
Name of the batch experiment.
TYPE:
|
|
ID of the input set to use for the batch experiment.
TYPE:
|
|
List of instance IDs to use for the batch experiment.
This argument is deprecated, use
TYPE:
|
|
Optional description of the batch experiment.
TYPE:
|
|
ID of the batch experiment. Will be generated if not provided.
TYPE:
|
|
Option sets to use for the batch experiment. This is a dictionary where the keys are option set IDs and the values are dictionaries with the actual options.
TYPE:
|
|
List of runs to use for the batch experiment.
TYPE:
|
|
Type of the batch experiment. This is used to determine the experiment type. The default value is "batch". If you want to create a scenario test, set this to "scenario".
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
ID of the batch experiment. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 |
|
new_batch_experiment_with_result
¶
new_batch_experiment_with_result(
name: str,
input_set_id: Optional[str] = None,
instance_ids: Optional[list[str]] = None,
description: Optional[str] = None,
id: Optional[str] = None,
option_sets: Optional[dict[str, dict[str, str]]] = None,
runs: Optional[
list[Union[BatchExperimentRun, dict[str, Any]]]
] = None,
type: Optional[str] = "batch",
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
) -> BatchExperiment
Convenience method to create a new batch experiment and poll for the result.
This method combines the new_batch_experiment
and
batch_experiment_with_polling
methods, applying polling logic to
check when the experiment succeeded.
PARAMETER | DESCRIPTION |
---|---|
|
Name of the batch experiment.
TYPE:
|
|
ID of the input set to use for the batch experiment.
TYPE:
|
|
List of instance IDs to use for the batch experiment. This argument
is deprecated, use
TYPE:
|
|
Optional description of the batch experiment.
TYPE:
|
|
ID of the batch experiment. Will be generated if not provided.
TYPE:
|
|
Option sets to use for the batch experiment. This is a dictionary where the keys are option set IDs and the values are dictionaries with the actual options.
TYPE:
|
|
List of runs to use for the batch experiment.
TYPE:
|
|
Type of the batch experiment. This is used to determine the experiment type. The default value is "batch". If you want to create a scenario test, set this to "scenario".
TYPE:
|
|
Options to use when polling for the batch experiment result.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperiment
|
The completed batch experiment with results. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 |
|
new_input_set
¶
new_input_set(
id: str,
name: str,
description: Optional[str] = None,
end_time: Optional[datetime] = None,
instance_id: Optional[str] = None,
maximum_runs: Optional[int] = None,
run_ids: Optional[list[str]] = None,
start_time: Optional[datetime] = None,
inputs: Optional[list[ManagedInput]] = None,
) -> InputSet
Create a new input set. You can create an input set from three different methodologies:
- Using
instance_id
,start_time
,end_time
andmaximum_runs
. Instance runs will be obtained from the application matching the criteria of dates and maximum number of runs. - Using
run_ids
. The input set will be created using the list of runs specified by the user. - Using
inputs
. The input set will be created using the list of inputs specified by the user. This is useful for creating an input set from a list of inputs that are already available in the application.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the input set
TYPE:
|
|
Name of the input set.
TYPE:
|
|
Optional description of the input set.
TYPE:
|
|
End time of the input set. This is used to filter the runs associated with the input set.
TYPE:
|
|
ID of the instance to use for the input set. This is used to
filter the runs associated with the input set. If not provided,
the application's
TYPE:
|
|
Maximum number of runs to use for the input set. This is used to filter the runs associated with the input set. If not provided, all runs are used.
TYPE:
|
|
List of run IDs to use for the input set.
TYPE:
|
|
Start time of the input set. This is used to filter the runs associated with the input set.
TYPE:
|
|
List of inputs to use for the input set. This is used to create the input set from a list of inputs that are already available in the application.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
InputSet
|
The new input set. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 |
|
new_instance
¶
new_instance(
version_id: str,
id: str,
name: str,
description: Optional[str] = None,
configuration: Optional[InstanceConfiguration] = None,
exist_ok: bool = False,
) -> Instance
Create a new instance and associate it with a version.
This method creates a new instance associated with a specific version of the application. Instances are configurations of an application version that can be executed.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the version to associate the instance with.
TYPE:
|
|
ID of the instance. Will be generated if not provided.
TYPE:
|
|
Name of the instance. Will be generated if not provided.
TYPE:
|
|
Description of the instance.
TYPE:
|
|
Configuration to use for the instance. This can include resources, timeouts, and other execution parameters.
TYPE:
|
|
If True and an instance with the same ID already exists, return the existing instance instead of creating a new one.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Instance
|
The newly created (or existing) instance. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If exist_ok is True and id is None. |
Examples:
>>> # Create a new instance for a specific version
>>> instance = app.new_instance(
... version_id="version-123",
... id="prod-instance",
... name="Production Instance",
... description="Instance for production use"
... )
>>> print(instance.name)
'Production Instance'
Source code in nextmv/nextmv/cloud/application.py
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 |
|
new_managed_input
¶
new_managed_input(
id: str,
name: str,
description: Optional[str] = None,
upload_id: Optional[str] = None,
run_id: Optional[str] = None,
format: Optional[Union[Format, dict[str, Any]]] = None,
) -> ManagedInput
Create a new managed input. There are two methods for creating a managed input:
- Specifying the
upload_id
parameter. You may use theupload_url
method to obtain the upload ID and theupload_large_input
method to upload the data to it. - Specifying the
run_id
parameter. The managed input will be created from the run specified by therun_id
parameter.
Either the upload_id
or the run_id
parameter must be specified.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the managed input.
TYPE:
|
|
Name of the managed input.
TYPE:
|
|
Optional description of the managed input.
TYPE:
|
|
ID of the upload to use for the managed input.
TYPE:
|
|
ID of the run to use for the managed input.
TYPE:
|
|
Format of the managed input. Default will be formatted as
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ManagedInput
|
The new managed input. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If neither the |
Source code in nextmv/nextmv/cloud/application.py
1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 |
|
new_run
¶
new_run(
input: Union[
Input, dict[str, Any], BaseModel, str
] = None,
instance_id: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
upload_id: Optional[str] = None,
options: Optional[
Union[Options, dict[str, str]]
] = None,
configuration: Optional[
Union[RunConfiguration, dict[str, Any]]
] = None,
batch_experiment_id: Optional[str] = None,
external_result: Optional[
Union[ExternalRunResult, dict[str, Any]]
] = None,
json_configurations: Optional[dict[str, Any]] = None,
input_dir_path: Optional[str] = None,
) -> str
Submit an input to start a new run of the application. Returns the
run_id
of the submitted run.
PARAMETER | DESCRIPTION |
---|---|
|
Input to use for the run. This can be a If If you want to work with When
When working with JSON or text data, use the In general, if an input is too large, it will be uploaded with the
TYPE:
|
|
ID of the instance to use for the run. If not provided, the default
instance ID associated to the Class (
TYPE:
|
|
Name of the run.
TYPE:
|
|
Description of the run.
TYPE:
|
|
ID to use when running a large input. If the
TYPE:
|
|
Options to use for the run. This can be a
TYPE:
|
|
Configuration to use for the run. This can be a
TYPE:
|
|
ID of a batch experiment to associate the run with. This is used when the run is part of a batch experiment.
TYPE:
|
|
External result to use for the run. This can be a
TYPE:
|
|
Optional configurations for JSON serialization. This is used to customize the serialization before data is sent.
TYPE:
|
|
Path to a directory containing input files. If specified, the
function will package the files in the directory into a tar file
and upload it as a large input. This is useful for input formats
like
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
ID ( |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If the |
Source code in nextmv/nextmv/cloud/application.py
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 |
|
new_run_with_result
¶
new_run_with_result(
input: Union[
Input, dict[str, Any], BaseModel, str
] = None,
instance_id: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
upload_id: Optional[str] = None,
run_options: Optional[
Union[Options, dict[str, str]]
] = None,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
configuration: Optional[
Union[RunConfiguration, dict[str, Any]]
] = None,
batch_experiment_id: Optional[str] = None,
external_result: Optional[
Union[ExternalRunResult, dict[str, Any]]
] = None,
json_configurations: Optional[dict[str, Any]] = None,
input_dir_path: Optional[str] = None,
output_dir_path: Optional[str] = ".",
) -> RunResult
Submit an input to start a new run of the application and poll for the
result. This is a convenience method that combines the new_run
and
run_result_with_polling
methods, applying polling logic to check when
the run succeeded.
PARAMETER | DESCRIPTION |
---|---|
|
Input to use for the run. This can be a If If you want to work with When
When working with JSON or text data, use the In general, if an input is too large, it will be uploaded with the
TYPE:
|
|
ID of the instance to use for the run. If not provided, the default
instance ID associated to the Class (
TYPE:
|
|
Name of the run.
TYPE:
|
|
Description of the run.
TYPE:
|
|
ID to use when running a large input. If the
TYPE:
|
|
Options to use for the run. This can be a
TYPE:
|
|
Options to use when polling for the run result. This is a
convenience method that combines the
TYPE:
|
|
Configuration to use for the run. This can be a
TYPE:
|
|
ID of a batch experiment to associate the run with. This is used when the run is part of a batch experiment.
TYPE:
|
|
External result to use for the run. This can be a
TYPE:
|
|
Optional configurations for JSON serialization. This is used to customize the serialization before data is sent.
TYPE:
|
|
Path to a directory containing input files. If specified, the
function will package the files in the directory into a tar file
and upload it as a large input. This is useful for input formats
like
TYPE:
|
|
Path to a directory where non-JSON output files will be saved. This is required if the output is non-JSON. If the directory does not exist, it will be created. Uses the current directory by default.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RunResult
|
Result of the run. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If the |
HTTPError
|
If the response status code is not 2xx. |
TimeoutError
|
If the run does not succeed after the polling strategy is exhausted based on time duration. |
RuntimeError
|
If the run does not succeed after the polling strategy is exhausted based on number of tries. |
Source code in nextmv/nextmv/cloud/application.py
1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 |
|
new_scenario_test
¶
new_scenario_test(
id: str,
name: str,
scenarios: list[Scenario],
description: Optional[str] = None,
repetitions: Optional[int] = 0,
) -> str
Create a new scenario test. The test is based on scenarios
and you
may specify repetitions
to run the test multiple times. 0 repetitions
means that the tests will be executed once. 1 repetition means that the
test will be repeated once, i.e.: it will be executed twice. 2
repetitions equals 3 executions, so on, and so forth.
For each scenario, consider the scenario_input
and configuration
.
The scenario_input.scenario_input_type
allows you to specify the data
that will be used for that scenario.
ScenarioInputType.INPUT_SET
: the data should be taken from an existing input set.ScenarioInputType.INPUT
: the data should be taken from a list of existing inputs. When using this type, an input set will be created from this set of managed inputs.ScenarioInputType.New
: a new set of data will be uploaded as a set of managed inputs. A new input set will be created from this set of managed inputs.
On the other hand, the configuration
allows you to specify multiple
option variations for the scenario. Please see the
ScenarioConfiguration
class for more information.
The scenario tests uses the batch experiments API under the hood.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the scenario test.
TYPE:
|
|
Name of the scenario test.
TYPE:
|
|
List of scenarios to use for the scenario test. At least one scenario should be provided.
TYPE:
|
|
Optional description of the scenario test.
TYPE:
|
|
Number of repetitions to use for the scenario test. 0 repetitions means that the tests will be executed once. 1 repetition means that the test will be repeated once, i.e.: it will be executed twice. 2 repetitions equals 3 executions, so on, and so forth.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
ID of the scenario test. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If no scenarios are provided. |
Source code in nextmv/nextmv/cloud/application.py
1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 |
|
new_scenario_test_with_result
¶
new_scenario_test_with_result(
id: str,
name: str,
scenarios: list[Scenario],
description: Optional[str] = None,
repetitions: Optional[int] = 0,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
) -> BatchExperiment
Convenience method to create a new scenario test and poll for the result.
This method combines the new_scenario_test
and
scenario_test_with_polling
methods, applying polling logic to
check when the test succeeded.
The scenario tests uses the batch experiments API under the hood.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the scenario test.
TYPE:
|
|
Name of the scenario test.
TYPE:
|
|
List of scenarios to use for the scenario test. At least one scenario should be provided.
TYPE:
|
|
Optional description of the scenario test.
TYPE:
|
|
Number of repetitions to use for the scenario test. 0 repetitions means that the tests will be executed once. 1 repetition means that the test will be repeated once, i.e.: it will be executed twice. 2 repetitions equals 3 executions, so on, and so forth.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperiment
|
The completed scenario test as a BatchExperiment. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If no scenarios are provided. |
Source code in nextmv/nextmv/cloud/application.py
1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 |
|
new_secrets_collection
¶
new_secrets_collection(
secrets: list[Secret],
id: str,
name: str,
description: Optional[str] = None,
) -> SecretsCollectionSummary
Create a new secrets collection.
This method creates a new secrets collection with the provided secrets. A secrets collection is a group of key-value pairs that can be used by your application instances during execution. If no secrets are provided, a ValueError is raised.
PARAMETER | DESCRIPTION |
---|---|
|
List of secrets to use for the secrets collection. Each secret should be an instance of the Secret class containing a key and value.
TYPE:
|
|
ID of the secrets collection.
TYPE:
|
|
Name of the secrets collection.
TYPE:
|
|
Description of the secrets collection.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SecretsCollectionSummary
|
Summary of the secrets collection including its metadata. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If no secrets are provided. |
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Create a new secrets collection with API keys
>>> from nextmv.cloud import Secret
>>> secrets = [
... Secret(
... location="API_KEY",
... value="your-api-key",
... secret_type=SecretType.ENV,
... ),
... Secret(
... location="DATABASE_URL",
... value="your-database-url",
... secret_type=SecretType.ENV,
... ),
... ]
>>> collection = app.new_secrets_collection(
... secrets=secrets,
... id="api-secrets",
... name="API Secrets",
... description="Collection of API secrets for external services"
... )
>>> print(collection.id)
'api-secrets'
Source code in nextmv/nextmv/cloud/application.py
2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 |
|
new_version
¶
new_version(
id: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
exist_ok: bool = False,
) -> Version
Create a new version using the current dev binary.
This method creates a new version of the application using the current development binary. Application versions represent different iterations of your application's code and configuration that can be deployed.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the version. If not provided, a unique ID will be generated.
TYPE:
|
|
Name of the version. If not provided, a name will be generated.
TYPE:
|
|
Description of the version. If not provided, a description will be generated.
TYPE:
|
|
If True and a version with the same ID already exists, return the existing version instead of creating a new one. If True, the 'id' parameter must be provided.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Version
|
The newly created (or existing) version. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If exist_ok is True and id is None. |
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Create a new version
>>> version = app.new_version(
... id="v1.0.0",
... name="Initial Release",
... description="First stable version"
... )
>>> print(version.id)
'v1.0.0'
>>> # Get or create a version with exist_ok
>>> version = app.new_version(
... id="v1.0.0",
... exist_ok=True
... )
Source code in nextmv/nextmv/cloud/application.py
2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 |
|
push
¶
push(
manifest: Optional[Manifest] = None,
app_dir: Optional[str] = None,
verbose: bool = False,
model: Optional[Model] = None,
model_configuration: Optional[
ModelConfiguration
] = None,
) -> None
Push an app to Nextmv Cloud.
If the manifest is not provided, an app.yaml
file will be searched
for in the provided path. If there is no manifest file found, an
exception will be raised.
There are two ways to push an app to Nextmv Cloud:
1. Specifying app_dir
, which is the path to an app's root directory.
This acts as an external strategy, where the app is composed of files
in a directory and those apps are packaged and pushed to Nextmv Cloud.
2. Specifying a model
and model_configuration
. This acts as an
internal (or Python-native) strategy, where the app is actually a
nextmv.Model
. The model is encoded, some dependencies and
accompanying files are packaged, and the app is pushed to Nextmv Cloud.
PARAMETER | DESCRIPTION |
---|---|
|
The manifest for the app. If None, an
TYPE:
|
|
The path to the app's root directory. If None, the current directory will be used. This is for the external strategy approach.
TYPE:
|
|
Whether to print verbose output during the push process.
TYPE:
|
|
The Python-native model to push. Must be specified together with
TYPE:
|
|
Configuration for the Python-native model. Must be specified together
with
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If neither app_dir nor model/model_configuration is provided correctly, or if only one of model and model_configuration is provided. |
TypeError
|
If model is not an instance of nextmv.Model or if model_configuration is not an instance of nextmv.ModelConfiguration. |
Exception
|
If there's an error in the build, packaging, or cleanup process. |
Examples:
- Push an app using an external strategy (directory-based):
>>> import os
>>> from nextmv import cloud
>>> client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
>>> app = cloud.Application(client=client, id="<YOUR-APP-ID>")
>>> app.push() # Use verbose=True for step-by-step output.
- Push an app using an internal strategy (Python-native model):
>>> import os
>>> import nextroute
>>> import nextmv
>>> import nextmv.cloud
>>>
>>> # Define the model that makes decisions
>>> class DecisionModel(nextmv.Model):
... def solve(self, input: nextmv.Input) -> nextmv.Output:
... nextroute_input = nextroute.schema.Input.from_dict(input.data)
... nextroute_options = nextroute.Options.extract_from_dict(input.options.to_dict())
... nextroute_output = nextroute.solve(nextroute_input, nextroute_options)
...
... return nextmv.Output(
... options=input.options,
... solution=nextroute_output.solutions[0].to_dict(),
... statistics=nextroute_output.statistics.to_dict(),
... )
>>>
>>> # Define the options that the model needs
>>> opt = []
>>> default_options = nextroute.Options()
>>> for name, default_value in default_options.to_dict().items():
... opt.append(nextmv.Option(name.lower(), type(default_value), default_value, name, False))
>>> options = nextmv.Options(*opt)
>>>
>>> # Instantiate the model and model configuration
>>> model = DecisionModel()
>>> model_configuration = nextmv.ModelConfiguration(
... name="python_nextroute_model",
... requirements=[
... "nextroute==1.8.1",
... "nextmv==0.14.0.dev1",
... ],
... options=options,
... )
>>>
>>> # Push the model to Nextmv Cloud
>>> client = cloud.Client(api_key=os.getenv("NEXTMV_API_KEY"))
>>> app = cloud.Application(client=client, id="<YOUR-APP-ID>")
>>> manifest = nextmv.cloud.default_python_manifest()
>>> app.push(
... manifest=manifest,
... verbose=True,
... model=model,
... model_configuration=model_configuration,
... )
Source code in nextmv/nextmv/cloud/application.py
2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 |
|
run_input
¶
run_input(run_id: str) -> dict[str, Any]
Get the input of a run.
Retrieves the input data that was used for a specific run. This method handles both small and large inputs automatically - if the input size exceeds the maximum allowed size, it will fetch the input from a download URL.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the run to retrieve the input for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
Input data of the run as a dictionary. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> input_data = app.run_input("run-123")
>>> print(input_data)
{'locations': [...], 'vehicles': [...]}
Source code in nextmv/nextmv/cloud/application.py
run_logs
¶
run_logs(run_id: str) -> RunLog
Get the logs of a run.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the run to get logs for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RunLog
|
Logs of the run. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
run_metadata
¶
run_metadata(run_id: str) -> RunInformation
Get the metadata of a run.
Retrieves information about a run without including the run output. This is useful when you only need the run's status and metadata.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the run to retrieve metadata for.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RunInformation
|
Metadata of the run (run information without output). |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> metadata = app.run_metadata("run-123")
>>> print(metadata.metadata.status_v2)
StatusV2.succeeded
Source code in nextmv/nextmv/cloud/application.py
run_result
¶
run_result(
run_id: str, output_dir_path: Optional[str] = "."
) -> RunResult
Get the result of a run.
Retrieves the complete result of a run, including the run output.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the run to get results for.
TYPE:
|
|
Path to a directory where non-JSON output files will be saved. This is required if the output is non-JSON. If the directory does not exist, it will be created. Uses the current directory by default.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RunResult
|
Result of the run, including output. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application.py
run_result_with_polling
¶
run_result_with_polling(
run_id: str,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
output_dir_path: Optional[str] = ".",
) -> RunResult
Get the result of a run with polling.
Retrieves the result of a run including the run output. This method polls for the result until the run finishes executing or the polling strategy is exhausted.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the run to retrieve the result for.
TYPE:
|
|
Options to use when polling for the run result.
TYPE:
|
|
Path to a directory where non-JSON output files will be saved. This is required if the output is non-JSON. If the directory does not exist, it will be created. Uses the current directory by default.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RunResult
|
Complete result of the run including output data. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
TimeoutError
|
If the run does not complete after the polling strategy is exhausted based on time duration. |
RuntimeError
|
If the run does not complete after the polling strategy is exhausted based on number of tries. |
Examples:
>>> from nextmv.cloud import PollingOptions
>>> # Create custom polling options
>>> polling_opts = PollingOptions(max_tries=50, max_duration=600)
>>> # Get run result with polling
>>> result = app.run_result_with_polling("run-123", polling_opts)
>>> print(result.output)
{'solution': {...}}
Source code in nextmv/nextmv/cloud/application.py
2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 |
|
scenario_test
¶
scenario_test(scenario_test_id: str) -> BatchExperiment
Get a scenario test.
Retrieves a scenario test by ID. Scenario tests are based on batch experiments, so this function returns the corresponding batch experiment associated with the scenario test.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the scenario test to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperiment
|
The scenario test details as a batch experiment. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> test = app.scenario_test("scenario-123")
>>> print(test.name)
'My Scenario Test'
>>> print(test.type)
'scenario'
Source code in nextmv/nextmv/cloud/application.py
scenario_test_metadata
¶
scenario_test_metadata(
scenario_test_id: str,
) -> BatchExperimentMetadata
Get the metadata for a scenario test, given its ID.
Scenario tests are based on batch experiments, so this function returns the corresponding batch experiment metadata associated with the scenario test.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the scenario test to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperimentMetadata
|
The scenario test metadata as a batch experiment. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> metadata = app.scenario_test_metadata("scenario-123")
>>> print(metadata.name)
'My Scenario Test'
>>> print(metadata.type)
'scenario'
Source code in nextmv/nextmv/cloud/application.py
scenario_test_with_polling
¶
scenario_test_with_polling(
scenario_test_id: str,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
) -> BatchExperiment
Get a scenario test with polling.
Retrieves the result of a scenario test. This method polls for the result until the test finishes executing or the polling strategy is exhausted.
The scenario tests uses the batch experiments API under the hood.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the scenario test to retrieve.
TYPE:
|
|
Options to use when polling for the scenario test result.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperiment
|
The scenario test details as a batch experiment. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> test = app.scenario_test_with_polling("scenario-123")
>>> print(test.name)
'My Scenario Test'
>>> print(test.type)
'scenario'
Source code in nextmv/nextmv/cloud/application.py
secrets_collection
¶
secrets_collection(
secrets_collection_id: str,
) -> SecretsCollection
Get a secrets collection.
This method retrieves a secrets collection by its ID. A secrets collection is a group of key-value pairs that can be used by your application instances during execution.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the secrets collection to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SecretsCollection
|
The requested secrets collection, including all secret values and metadata. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Retrieve a secrets collection
>>> collection = app.secrets_collection("api-secrets")
>>> print(collection.name)
'API Secrets'
>>> print(len(collection.secrets))
2
>>> for secret in collection.secrets:
... print(secret.location)
'API_KEY'
'DATABASE_URL'
Source code in nextmv/nextmv/cloud/application.py
track_run
¶
track_run(
tracked_run: TrackedRun,
instance_id: Optional[str] = None,
configuration: Optional[
Union[RunConfiguration, dict[str, Any]]
] = None,
) -> str
Track an external run.
This method allows you to register in Nextmv a run that happened elsewhere, as though it were executed in the Nextmv platform. Having information about a run in Nextmv is useful for things like experimenting and testing.
Please read the documentation on the TrackedRun
class carefully, as
there are important considerations to take into account when using this
method. For example, if you intend to upload JSON input/output, use the
input
/output
attributes of the TrackedRun
class. On the other
hand, if you intend to track files-based input/output, use the
input_dir_path
/output_dir_path
attributes of the TrackedRun
class.
PARAMETER | DESCRIPTION |
---|---|
|
The run to track.
TYPE:
|
|
Optional instance ID if you want to associate your tracked run with an instance.
TYPE:
|
|
Configuration to use for the run. This can be a
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
The ID of the run that was tracked. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If the tracked run does not have an input or output. |
Examples:
>>> from nextmv.cloud import Application
>>> from nextmv.cloud.run import TrackedRun
>>> app = Application(id="app_123")
>>> tracked_run = TrackedRun(input={"data": [...]}, output={"solution": [...]})
>>> run_id = app.track_run(tracked_run)
Source code in nextmv/nextmv/cloud/application.py
2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 |
|
track_run_with_result
¶
track_run_with_result(
tracked_run: TrackedRun,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
instance_id: Optional[str] = None,
output_dir_path: Optional[str] = ".",
configuration: Optional[
Union[RunConfiguration, dict[str, Any]]
] = None,
) -> RunResult
Track an external run and poll for the result. This is a convenience
method that combines the track_run
and run_result_with_polling
methods. It applies polling logic to check when the run was
successfully registered.
PARAMETER | DESCRIPTION |
---|---|
|
The run to track.
TYPE:
|
|
Options to use when polling for the run result.
TYPE:
|
|
Optional instance ID if you want to associate your tracked run with an instance.
TYPE:
|
|
Path to a directory where non-JSON output files will be saved. This is required if the output is non-JSON. If the directory does not exist, it will be created. Uses the current directory by default.
TYPE:
|
|
Configuration to use for the run. This can be a
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RunResult
|
Result of the run. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
ValueError
|
If the tracked run does not have an input or output. |
TimeoutError
|
If the run does not succeed after the polling strategy is exhausted based on time duration. |
RuntimeError
|
If the run does not succeed after the polling strategy is exhausted based on number of tries. |
Source code in nextmv/nextmv/cloud/application.py
2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 |
|
update_batch_experiment
¶
update_batch_experiment(
batch_experiment_id: str,
name: Optional[str] = None,
description: Optional[str] = None,
) -> BatchExperimentInformation
Update a batch experiment.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the batch experiment to update.
TYPE:
|
|
Optional name of the batch experiment.
TYPE:
|
|
Optional description of the batch experiment.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperimentInformation
|
The information with the updated batch experiment. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
update_instance
¶
update_instance(
id: str,
name: Optional[str] = None,
version_id: Optional[str] = None,
description: Optional[str] = None,
configuration: Optional[InstanceConfiguration] = None,
) -> Instance
Update an instance.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the instance to update.
TYPE:
|
|
Optional name of the instance.
TYPE:
|
|
Optional ID of the version to associate the instance with.
TYPE:
|
|
Optional description of the instance.
TYPE:
|
|
Optional configuration to use for the instance.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Instance
|
The updated instance. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 |
|
update_managed_input
¶
update_managed_input(
managed_input_id: str,
name: Optional[str] = None,
description: Optional[str] = None,
) -> ManagedInput
Update a managed input.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the managed input to update.
TYPE:
|
|
Optional new name for the managed input.
TYPE:
|
|
Optional new description for the managed input.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ManagedInput
|
The updated managed input. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application.py
update_scenario_test
¶
update_scenario_test(
scenario_test_id: str,
name: Optional[str] = None,
description: Optional[str] = None,
) -> BatchExperimentInformation
Update a scenario test.
Updates a scenario test with new name and description. Scenario tests
use the batch experiments API, so this method calls the
update_batch_experiment
method, and thus the return type is the same.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the scenario test to update.
TYPE:
|
|
Optional new name for the scenario test.
TYPE:
|
|
Optional new description for the scenario test.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchExperimentInformation
|
The information about the updated scenario test. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> info = app.update_scenario_test(
... scenario_test_id="scenario-123",
... name="Updated Test Name",
... description="Updated description for this test"
... )
>>> print(info.name)
'Updated Test Name'
Source code in nextmv/nextmv/cloud/application.py
update_secrets_collection
¶
update_secrets_collection(
secrets_collection_id: str,
name: Optional[str] = None,
description: Optional[str] = None,
secrets: Optional[list[Secret]] = None,
) -> SecretsCollectionSummary
Update a secrets collection.
This method updates an existing secrets collection with new values for name, description, and secrets. A secrets collection is a group of key-value pairs that can be used by your application instances during execution.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the secrets collection to update.
TYPE:
|
|
Optional new name for the secrets collection.
TYPE:
|
|
Optional new description for the secrets collection.
TYPE:
|
|
Optional list of secrets to update. Each secret should be an instance of the Secret class containing a key and value.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SecretsCollectionSummary
|
Summary of the updated secrets collection including its metadata. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If no secrets are provided. |
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Update an existing secrets collection
>>> from nextmv.cloud import Secret
>>> updated_secrets = [
... Secret(key="API_KEY", value="new-api-key"),
... Secret(key="DATABASE_URL", value="new-database-url")
... ]
>>> updated_collection = app.update_secrets_collection(
... secrets_collection_id="api-secrets",
... name="Updated API Secrets",
... description="Updated collection of API secrets",
... secrets=updated_secrets
... )
>>> print(updated_collection.id)
'api-secrets'
Source code in nextmv/nextmv/cloud/application.py
3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 |
|
upload_large_input
¶
upload_large_input(
input: Optional[Union[dict[str, Any], str]],
upload_url: UploadURL,
json_configurations: Optional[dict[str, Any]] = None,
tar_file: Optional[str] = None,
) -> None
Upload large input data to the provided upload URL.
This method allows uploading large input data (either a dictionary or string) to a pre-signed URL. If the input is a dictionary, it will be converted to a JSON string before upload.
PARAMETER | DESCRIPTION |
---|---|
|
Input data to upload. Can be either a dictionary that will be converted to JSON, or a pre-formatted JSON string.
TYPE:
|
|
Upload URL object containing the pre-signed URL to use for uploading.
TYPE:
|
|
Optional configurations for JSON serialization. If provided, these
configurations will be used when serializing the data via
TYPE:
|
|
If provided, this will be used to upload a tar file instead of a JSON string or dictionary. This is useful for uploading large files that are already packaged as a tarball.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
This method doesn't return anything. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Upload a dictionary as JSON
>>> data = {"locations": [...], "vehicles": [...]}
>>> url = app.upload_url()
>>> app.upload_large_input(input=data, upload_url=url)
>>>
>>> # Upload a pre-formatted JSON string
>>> json_str = '{"locations": [...], "vehicles": [...]}'
>>> app.upload_large_input(input=json_str, upload_url=url)
Source code in nextmv/nextmv/cloud/application.py
upload_url
¶
Get an upload URL to use for uploading a file.
This method generates a pre-signed URL that can be used to upload large files to Nextmv Cloud. It's primarily used for uploading large input data, output results, or log files that exceed the size limits for direct API calls.
RETURNS | DESCRIPTION |
---|---|
UploadURL
|
An object containing both the upload URL and an upload ID for reference. The upload URL is a pre-signed URL that allows temporary write access. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Get an upload URL and upload large input data
>>> upload_url = app.upload_url()
>>> large_input = {"locations": [...], "vehicles": [...]}
>>> app.upload_large_input(input=large_input, upload_url=upload_url)
Source code in nextmv/nextmv/cloud/application.py
version
¶
version(version_id: str) -> Version
Get a version.
Retrieves a specific version of the application by its ID. Application versions represent different iterations of your application's code and configuration.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the version to retrieve.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Version
|
The version object containing details about the requested application version. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Retrieve a specific version
>>> version = app.version("v1.0.0")
>>> print(version.id)
'v1.0.0'
>>> print(version.name)
'Initial Release'
Source code in nextmv/nextmv/cloud/application.py
version_exists
¶
version_exists(version_id: str) -> bool
Check if a version exists.
This method checks if a specific version of the application exists by attempting to retrieve it. It handles HTTP errors for non-existent versions and returns a boolean indicating existence.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the version to check for existence.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
True if the version exists, False otherwise. |
RAISES | DESCRIPTION |
---|---|
HTTPError
|
If an HTTP error occurs that is not related to the non-existence of the version. |
Examples:
>>> # Check if a version exists
>>> exists = app.version_exists("v1.0.0")
>>> if exists:
... print("Version exists!")
... else:
... print("Version does not exist.")