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 = "devint",
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
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
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.
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
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 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
|
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
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 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
|
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.
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
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 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 |
|
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
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 1282 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 |
|
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
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 1375 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 |
|
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
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 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 |
|
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,
) -> 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
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:
|
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
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 1540 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 |
|
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,
) -> 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
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:
|
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
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 1719 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 |
|
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
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 |
|
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(key="API_KEY", value="your-api-key"),
... Secret(key="DATABASE_URL", value="your-database-url")
... ]
>>> 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
1867 1868 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 |
|
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
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 1989 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 |
|
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
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 2052 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 2139 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 |
|
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) -> 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:
|
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,
) -> 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:
|
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
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
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,
) -> 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.
PARAMETER | DESCRIPTION |
---|---|
|
The run to track.
TYPE:
|
|
Optional instance ID if you want to associate your tracked run with an instance.
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
2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 |
|
track_run_with_result
¶
track_run_with_result(
tracked_run: TrackedRun,
polling_options: PollingOptions = _DEFAULT_POLLING_OPTIONS,
instance_id: Optional[str] = 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:
|
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
update_batch_experiment
¶
update_batch_experiment(
batch_experiment_id: str, name: str, description: str
) -> BatchExperimentInformation
Update a batch experiment.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the batch experiment to update.
TYPE:
|
|
Name of the batch experiment.
TYPE:
|
|
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: str,
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:
|
|
Name of the instance.
TYPE:
|
|
ID of the version to associate the instance with.
TYPE:
|
|
Description of the instance.
TYPE:
|
|
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
update_managed_input
¶
update_managed_input(
managed_input_id: str, name: str, description: str
) -> None
Update a managed input.
PARAMETER | DESCRIPTION |
---|---|
|
ID of the managed input to update.
TYPE:
|
|
Name of the managed input.
TYPE:
|
|
Description of the managed input.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
No return value. |
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: str, description: str
) -> 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:
|
|
New name for the scenario test.
TYPE:
|
|
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: str,
description: str,
secrets: list[Secret],
) -> 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:
|
|
New name for the secrets collection.
TYPE:
|
|
New description for the secrets collection.
TYPE:
|
|
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
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 |
|
upload_large_input
¶
upload_large_input(
input: Union[dict[str, Any], str],
upload_url: UploadURL,
json_configurations: Optional[dict[str, Any]] = 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:
|
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
¶
upload_url() -> UploadURL
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.")
Source code in nextmv/nextmv/cloud/application.py
DownloadURL
¶
Bases: BaseModel
Result of getting a download URL.
You can import the DownloadURL
class directly from cloud
:
This class represents a download URL that can be used to fetch content from Nextmv Cloud, typically used for downloading large run results.
ATTRIBUTE | DESCRIPTION |
---|---|
url |
URL to use for downloading the file.
TYPE:
|
Examples:
>>> download_url = DownloadURL(url="https://example.com/download")
>>> response = requests.get(download_url.url)
PollingOptions
dataclass
¶
PollingOptions(
backoff: float = 0.9,
delay: float = 0.1,
initial_delay: float = 1,
max_delay: float = 20,
max_duration: float = -1,
max_tries: int = -1,
jitter: float = 1,
verbose: bool = False,
stop: Optional[Callable[[], bool]] = None,
)
Options to use when polling for a run result.
You can import the PollingOptions
class directly from cloud
:
The Cloud API will be polled for the result. The polling stops if:
- The maximum number of polls (tries) are exhausted. This is specified by
the
max_tries
parameter. - The maximum duration of the polling strategy is reached. This is
specified by the
max_duration
parameter.
Before conducting the first poll, the initial_delay
is used to sleep.
After each poll, a sleep duration is calculated using the following
strategy, based on exponential backoff with jitter:
Where: * i is the retry (poll) number. * Uniform is the uniform distribution.
Note that the sleep duration is capped by the max_delay
parameter.
PARAMETER | DESCRIPTION |
---|---|
|
Exponential backoff factor, in seconds, to use between polls.
TYPE:
|
|
Base delay to use between polls, in seconds.
TYPE:
|
|
Initial delay to use before starting the polling strategy, in seconds.
TYPE:
|
|
Maximum delay to use between polls, in seconds.
TYPE:
|
|
Maximum duration of the polling strategy, in seconds.
TYPE:
|
|
Maximum number of tries to use.
TYPE:
|
|
Jitter to use for the polling strategy. A uniform distribution is sampled between 0 and this number. The resulting random number is added to the delay for each poll, adding a random noise. Set this to 0 to avoid using random jitter.
TYPE:
|
|
Whether to log the polling strategy. This is useful for debugging.
TYPE:
|
|
Function to call to check if the polling should stop. This is useful for stopping the polling based on external conditions. The function should return True to stop the polling and False to continue. The function does not receive any arguments. The function is called before each poll.
TYPE:
|
Examples:
>>> from nextmv.cloud import PollingOptions
>>> # Create polling options with custom settings
>>> polling_options = PollingOptions(
... max_tries=50,
... max_duration=600,
... verbose=True
... )
backoff
class-attribute
instance-attribute
¶
Exponential backoff factor, in seconds, to use between polls.
delay
class-attribute
instance-attribute
¶
Base delay to use between polls, in seconds.
initial_delay
class-attribute
instance-attribute
¶
Initial delay to use before starting the polling strategy, in seconds.
jitter
class-attribute
instance-attribute
¶
Jitter to use for the polling strategy. A uniform distribution is sampled between 0 and this number. The resulting random number is added to the delay for each poll, adding a random noise. Set this to 0 to avoid using random jitter.
max_delay
class-attribute
instance-attribute
¶
Maximum delay to use between polls, in seconds.
max_duration
class-attribute
instance-attribute
¶
Maximum duration of the polling strategy, in seconds. A negative value means no limit.
max_tries
class-attribute
instance-attribute
¶
Maximum number of tries to use. A negative value means no limit.
stop
class-attribute
instance-attribute
¶
Function to call to check if the polling should stop. This is useful for stopping the polling based on external conditions. The function should return True to stop the polling and False to continue. The function does not receive any arguments. The function is called before each poll.
verbose
class-attribute
instance-attribute
¶
Whether to log the polling strategy. This is useful for debugging.
UploadURL
¶
Bases: BaseModel
Result of getting an upload URL.
You can import the UploadURL
class directly from cloud
:
This class represents an upload URL that can be used to send data to Nextmv Cloud, typically used for uploading large inputs for runs.
ATTRIBUTE | DESCRIPTION |
---|---|
upload_id |
ID of the upload, used to reference the uploaded content.
TYPE:
|
upload_url |
URL to use for uploading the file.
TYPE:
|
Examples:
poll
¶
poll(
polling_options: PollingOptions,
polling_func: Callable[[], tuple[Any, bool]],
__sleep_func: Callable[[float], None] = sleep,
) -> Any
Poll a function until it succeeds or the polling strategy is exhausted.
You can import the poll
function directly from cloud
:
This function implements a flexible polling strategy with exponential backoff and jitter. It calls the provided polling function repeatedly until it indicates success, the maximum number of tries is reached, or the maximum duration is exceeded.
The polling_func
is a callable that must return a tuple[Any, bool]
where the first element is the result of the polling and the second
element is a boolean indicating if the polling was successful or should be
retried.
PARAMETER | DESCRIPTION |
---|---|
|
Options for configuring the polling behavior, including retry counts, delays, timeouts, and verbosity settings.
TYPE:
|
|
Function to call to check if the polling was successful. Must return a tuple where the first element is the result value and the second is a boolean indicating success (True) or need to retry (False).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
Result value from the polling function when successful. |
RAISES | DESCRIPTION |
---|---|
TimeoutError
|
If the polling exceeds the maximum duration specified in polling_options. |
RuntimeError
|
If the maximum number of tries is exhausted without success. |
Examples:
>>> from nextmv.cloud import PollingOptions, poll
>>> import time
>>>
>>> # Define a polling function that succeeds after 3 tries
>>> counter = 0
>>> def check_completion() -> tuple[str, bool]:
... global counter
... counter += 1
... if counter >= 3:
... return "Success", True
... return None, False
...
>>> # Configure polling options
>>> options = PollingOptions(
... max_tries=5,
... delay=0.1,
... backoff=0.2,
... verbose=True
... )
>>>
>>> # Poll until the function succeeds
>>> result = poll(options, check_completion)
>>> print(result)
'Success'
Source code in nextmv/nextmv/cloud/application.py
3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 |
|