Application Module¶
This section documents the application components of the Nextmv Cloud API.
The application module is organized with the main Application class and
several mixin classes that provide specialized functionality. Every method
belonging to a mixin class can be accessed through an instance of the Application.
Main Class¶
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 |
|---|---|
ApplicationType |
Enumeration of application types in Nextmv Cloud. |
Application |
Class for interacting with applications in Nextmv Cloud. |
| FUNCTION | DESCRIPTION |
|---|---|
list_application |
Function to list applications in Nextmv Cloud. |
Application
¶
Bases: BaseModel, ApplicationAcceptanceMixin, ApplicationBatchMixin, ApplicationRunMixin, ApplicationEnsembleMixin, ApplicationInstanceMixin, ApplicationSecretsMixin, ApplicationVersionMixin, ApplicationInputSetMixin, ApplicationManagedInputMixin, ApplicationShadowMixin, ApplicationSwitchbackMixin
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.
Note: It is recommended to use Application.get() or Application.new()
instead of direct initialization to ensure proper setup.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
ID of the application.
TYPE:
|
name |
Name of the application.
TYPE:
|
description |
Description of the application.
TYPE:
|
type |
Type of the application (CUSTOM, SUBSCRIPTION, or PIPELINE).
TYPE:
|
default_instance_id |
Default instance ID to use for submitting runs.
TYPE:
|
default_experiment_instance |
Default experiment instance ID to use for experiments.
TYPE:
|
subscription_id |
Subscription ID if the application is a subscription type.
TYPE:
|
locked |
Whether the application is locked.
TYPE:
|
created_at |
Creation timestamp of the application.
TYPE:
|
updated_at |
Last update timestamp of the application.
TYPE:
|
client |
Client to use for interacting with the Nextmv Cloud API. This is an SDK-specific attribute and it is not part of the API representation of an application.
TYPE:
|
endpoint |
Base endpoint for the application. This is an SDK-specific attribute and it is not part of the API representation of an application.
TYPE:
|
experiments_endpoint |
Base endpoint for experiments. This is an SDK-specific attribute and it is not part of the API representation of an application.
TYPE:
|
ensembles_endpoint |
Base endpoint for ensembles. This is an SDK-specific attribute and it is not part of the API representation of an application.
TYPE:
|
Examples:
>>> from nextmv.cloud import Client, Application
>>> client = Client(api_key="your-api-key")
>>> # Retrieve an existing application
>>> app = Application.get(client=client, id="your-app-id")
>>> print(f"Application name: {app.name}")
Application name: My Application
>>> # Create a new application
>>> new_app = Application.new(client=client, name="My New App", id="my-new-app")
>>> # List application instances
>>> instances = app.list_instances()
-
nextmv
☁️ Cloud
Reference
Application Module
application
client
class-attribute
instance-attribute
¶
Client to use for interacting with the Nextmv Cloud API.
created_at
class-attribute
instance-attribute
¶
Creation timestamp of the application.
default_experiment_instance
class-attribute
instance-attribute
¶
Default experiment instance ID to use for experiments.
default_instance_id
class-attribute
instance-attribute
¶
default_instance_id: str | None = Field(
serialization_alias="default_instance",
validation_alias=AliasChoices(
"default_instance", "default_instance_id"
),
default=None,
)
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/__init__.py
description
class-attribute
instance-attribute
¶
Description of the application.
endpoint
class-attribute
instance-attribute
¶
Base endpoint for the application.
ensembles_endpoint
class-attribute
instance-attribute
¶
Base endpoint for managing the ensemble definitions in 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/__init__.py
experiments_endpoint
class-attribute
instance-attribute
¶
Base endpoint for the experiments in the application.
get
classmethod
¶
get(client: Client, id: str) -> Application
Retrieve an application directly from Nextmv Cloud.
This function is useful if you want to populate an Application class
by fetching the attributes directly from Nextmv Cloud.
| PARAMETER | DESCRIPTION |
|---|---|
|
Client to use for interacting with the Nextmv Cloud API.
TYPE:
|
|
ID of the application to retrieve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Application
|
The requested application. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/__init__.py
model_post_init
¶
Initialize the endpoint and experiments_endpoint attributes.
This method is automatically called after class initialization to format the endpoint and experiments_endpoint URLs with the application ID.
Source code in nextmv/nextmv/cloud/application/__init__.py
new
classmethod
¶
new(
client: Client,
name: str | None = None,
id: str | None = None,
description: str | None = None,
is_workflow: bool | None = None,
exist_ok: bool = False,
default_instance_id: str | None = None,
default_experiment_instance: str | None = None,
) -> 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. Uses the ID as the name if not provided.
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:
|
|
Default instance ID to use for submitting runs.
TYPE:
|
|
Default experiment instance ID to use for experiments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Application
|
The newly created (or existing) application. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
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/__init__.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
push
¶
push(
manifest: Manifest | None = None,
app_dir: str | None = None,
verbose: bool = False,
model: Model | None = None,
model_configuration: ModelConfiguration | None = None,
rich_print: bool = False,
) -> 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:
|
|
Whether to use rich printing when verbose output is enabled.
TYPE:
|
| 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/__init__.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | |
subscription_id
class-attribute
instance-attribute
¶
Subscription ID if the application is a subscription type.
type
class-attribute
instance-attribute
¶
type: ApplicationType | None = None
Type of the application.
update
¶
update(
name: str | None = None,
description: str | None = None,
default_instance_id: str | None = None,
default_experiment_instance: str | None = None,
) -> Application
Update the application.
| PARAMETER | DESCRIPTION |
|---|---|
|
Optional name of the application.
TYPE:
|
|
Optional description of the application.
TYPE:
|
|
Optional default instance ID for the application.
TYPE:
|
|
Optional default experiment instance ID for the application.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Application
|
The updated application. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/__init__.py
updated_at
class-attribute
instance-attribute
¶
Last update timestamp of the application.
upload_data
¶
upload_data(
upload_url: UploadURL | str,
data: dict[str, Any] | str | None = None,
json_configurations: dict[str, Any] | None = None,
tar_file: str | None = None,
) -> None
Upload data to the provided upload URL.
This method allows uploading data (either a dictionary or string) to a pre-signed URL. If the data is a dictionary, it will be converted to a JSON string before upload.
| PARAMETER | DESCRIPTION |
|---|---|
|
Upload URL object containing the pre-signed URL to use for uploading. If it is a string, it will be used directly as the pre-signed URL.
TYPE:
|
|
Data to upload. Can be either a dictionary that will be converted to JSON, or a pre-formatted JSON string.
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_data(data=data, upload_url=url)
>>>
>>> # Upload a pre-formatted JSON string
>>> json_str = '{"locations": [...], "vehicles": [...]}'
>>> app.upload_data(data=json_str, upload_url=url)
Source code in nextmv/nextmv/cloud/application/__init__.py
upload_large_input
¶
upload_large_input(
input: dict[str, Any] | str | None,
upload_url: UploadURL,
json_configurations: dict[str, Any] | None = None,
tar_file: str | None = None,
) -> None
Warning
upload_large_input is deprecated, use upload_data instead.
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/__init__.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_data(data=large_input, upload_url=upload_url)
Source code in nextmv/nextmv/cloud/application/__init__.py
ApplicationType
¶
Bases: str, Enum
Enumeration of application types in Nextmv Cloud.
You can import the ApplicationType class directly from cloud:
| ATTRIBUTE | DESCRIPTION |
|---|---|
CUSTOM |
Custom application type, which is the most common. Represents a standard application that you can push code to.
TYPE:
|
SUBSCRIPTION |
Subscription application type. You cannot push code to subscription applications, but only subscribe to them through the marketplace.
TYPE:
|
PIPELINE |
Pipeline application type that refers to workflows.
TYPE:
|
-
nextmv
☁️ Cloud
Reference
Application Module
applicationApplicationtype
CUSTOM
class-attribute
instance-attribute
¶
Custom application type, which is the most common. Represents a standard application that you can push code to.
PIPELINE
class-attribute
instance-attribute
¶
Pipeline application type that refers to workflows.
SUBSCRIPTION
class-attribute
instance-attribute
¶
Subscription application type. You cannot push code to subscription applications, but only subscribe to them through the marketplace.
list_applications
¶
list_applications(client: Client) -> list[Application]
List all Nextmv Cloud applications.
You can import the list_applications function directly from cloud:
| PARAMETER | DESCRIPTION |
|---|---|
|
The Nextmv Cloud client used to make API requests.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Application]
|
A list of Nextmv Cloud applications. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/__init__.py
Mixin Classes¶
These mixins extend the Application class with specific capabilities.
Acceptance Testing¶
_acceptance
¶
Application mixin for managing acceptance tests.
ApplicationAcceptanceMixin
¶
Mixin class providing acceptance test methods for Application.
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/_acceptance.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/_acceptance.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/_acceptance.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/_acceptance.py
new_acceptance_test
¶
new_acceptance_test(
candidate_instance_id: str,
baseline_instance_id: str,
metrics: list[Metric | dict[str, Any]],
id: str | None = None,
name: str | None = None,
input_set_id: str | None = None,
description: str | None = 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. Will be generated if not provided.
TYPE:
|
|
List of metrics to use for the acceptance test.
TYPE:
|
|
Name of the acceptance test. If not provided, the ID will be used as the name.
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/_acceptance.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
new_acceptance_test_with_result
¶
new_acceptance_test_with_result(
candidate_instance_id: str,
baseline_instance_id: str,
metrics: list[Metric | dict[str, Any]],
id: str | None = None,
name: str | None = None,
input_set_id: str | None = None,
description: str | None = 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. Will be generated if not provided.
TYPE:
|
|
List of metrics to use for the acceptance test.
TYPE:
|
|
Name of the acceptance test. If not provided, the ID will be used as the name.
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/_acceptance.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
update_acceptance_test
¶
update_acceptance_test(
acceptance_test_id: str,
name: str | None = None,
description: str | None = None,
) -> AcceptanceTest
Update an acceptance test.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the acceptance test to update.
TYPE:
|
|
Optional name of the acceptance test.
TYPE:
|
|
Optional description of the acceptance test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AcceptanceTest
|
The updated acceptance test. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> test = app.update_acceptance_test(
... acceptance_test_id="test-123",
... name="Updated Test Name",
... description="Updated description"
... )
>>> print(test.name)
'Updated Test Name'
Source code in nextmv/nextmv/cloud/application/_acceptance.py
Batch Scenarios¶
_batch_scenario
¶
Application mixin for managing batch experiments.
ApplicationBatchMixin
¶
Mixin class for managing batch experiments within an application.
batch_experiment
¶
batch_experiment(batch_id: str) -> BatchExperiment
Get a batch experiment. This method also returns the runs of the batch
experiment under the .runs attribute.
| 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/_batch_scenario.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/_batch_scenario.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/_batch_scenario.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/_batch_scenario.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/_batch_scenario.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/_batch_scenario.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/_batch_scenario.py
new_batch_experiment
¶
new_batch_experiment(
name: str | None = None,
input_set_id: str | None = None,
description: str | None = None,
id: str | None = None,
option_sets: dict[str, dict[str, str]] | None = None,
runs: list[BatchExperimentRun | dict[str, Any]]
| None = None,
type: str | None = "batch",
) -> str
Create a new batch experiment.
| PARAMETER | DESCRIPTION |
|---|---|
|
Name of the batch experiment. If not provided, the ID will be used as the name.
TYPE:
|
|
ID of the input set 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/_batch_scenario.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | |
new_batch_experiment_with_result
¶
new_batch_experiment_with_result(
name: str | None = None,
input_set_id: str | None = None,
description: str | None = None,
id: str | None = None,
option_sets: dict[str, dict[str, str]] | None = None,
runs: list[BatchExperimentRun | dict[str, Any]]
| None = None,
type: str | None = "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. If not provided, the ID will be used as the name.
TYPE:
|
|
ID of the input set 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:
|
|
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/_batch_scenario.py
new_scenario_test
¶
new_scenario_test(
scenarios: list[Scenario],
id: str | None = None,
name: str | None = None,
description: str | None = None,
repetitions: int | None = 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 |
|---|---|
|
List of scenarios to use for the scenario test. At least one scenario should be provided.
TYPE:
|
|
ID of the scenario test. Will be generated if not provided.
TYPE:
|
|
Name of the scenario test. If not provided, the ID will be used as the name.
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/_batch_scenario.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
new_scenario_test_with_result
¶
new_scenario_test_with_result(
scenarios: list[Scenario],
id: str | None = None,
name: str | None = None,
description: str | None = None,
repetitions: int | None = 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 |
|---|---|
|
List of scenarios to use for the scenario test. At least one scenario should be provided.
TYPE:
|
|
ID of the scenario test. Will be generated if not provided.
TYPE:
|
|
Name of the scenario test. If not provided, the ID will be used as the name.
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:
|
|
Options to use when polling for the scenario test result.
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/_batch_scenario.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/_batch_scenario.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/_batch_scenario.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/_batch_scenario.py
update_batch_experiment
¶
update_batch_experiment(
batch_experiment_id: str,
name: str | None = None,
description: str | None = 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/_batch_scenario.py
update_scenario_test
¶
update_scenario_test(
scenario_test_id: str,
name: str | None = None,
description: str | None = 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/_batch_scenario.py
Ensemble Management¶
_ensemble
¶
Application mixin for managing app ensembles.
ApplicationEnsembleMixin
¶
Mixin class for managing app ensembles within an application.
delete_ensemble_definition
¶
delete_ensemble_definition(
ensemble_definition_id: str,
) -> None
Delete an ensemble definition.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the ensemble definition to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_ensemble.py
ensemble_definition
¶
ensemble_definition(
ensemble_definition_id: str,
) -> EnsembleDefinition
Get an ensemble definition.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the ensemble definition to retrieve.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EnsembleDefintion
|
The requested ensemble definition details. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> ensemble_definition = app.ensemble_definition("instance-123")
>>> print(ensemble_definition.name)
'Production Ensemble Definition'
Source code in nextmv/nextmv/cloud/application/_ensemble.py
list_ensemble_definitions
¶
List all ensemble_definitions.
| RETURNS | DESCRIPTION |
|---|---|
list[EnsembleDefinition]
|
List of all ensemble definitions associated with this application. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> ensemble_definitions = app.list_ensemble_definitions()
>>> for ensemble_definition in ensemble_definitions:
... print(ensemble_definition.name)
'Development Ensemble Definition'
'Production Ensemble Definition'
Source code in nextmv/nextmv/cloud/application/_ensemble.py
new_ensemble_definition
¶
new_ensemble_definition(
run_groups: list[RunGroup],
rules: list[EvaluationRule],
id: str | None = None,
name: str | None = None,
description: str | None = None,
) -> EnsembleDefinition
Create a new ensemble definition.
| PARAMETER | DESCRIPTION |
|---|---|
|
Information to facilitate the execution of child runs.
TYPE:
|
|
Information to facilitate the selection of a result for the ensemble run from child runs.
TYPE:
|
|
ID of the ensemble definition. If not provided, a unique ID will be generated with the prefix 'ensemble-'.
TYPE:
|
|
Name of the ensemble definition. If not provided, the ID will be used.
TYPE:
|
|
Description of the ensemble definition. If not provided, the name will be used.
TYPE:
|
Source code in nextmv/nextmv/cloud/application/_ensemble.py
new_ensemble_defintion
¶
new_ensemble_defintion(
id: str,
run_groups: list[RunGroup],
rules: list[EvaluationRule],
name: str | None = None,
description: str | None = None,
) -> EnsembleDefinition
Warning
new_ensemble_defintion is deprecated, use new_ensemble_definition instead.
Create a new ensemble definition.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the ensemble defintion.
TYPE:
|
|
Information to facilitate the execution of child runs.
TYPE:
|
|
Information to facilitate the selection of a result for the ensemble run from child runs.
TYPE:
|
|
Name of the ensemble definition.
TYPE:
|
|
Description of the ensemble definition.
TYPE:
|
Source code in nextmv/nextmv/cloud/application/_ensemble.py
update_ensemble_definition
¶
update_ensemble_definition(
id: str,
name: str | None = None,
description: str | None = None,
) -> EnsembleDefinition
Update an ensemble definition.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the ensemble definition to update.
TYPE:
|
|
Optional name of the ensemble definition.
TYPE:
|
|
Optional description of the ensemble definition.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
EnsembleDefinition
|
The updated ensemble definition. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither name nor description is updated |
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_ensemble.py
Input Sets¶
_input_set
¶
Application mixin for managing app input sets.
ApplicationInputSetMixin
¶
Mixin class for managing app input sets within an application.
delete_input_set
¶
delete_input_set(input_set_id: str) -> None
Delete an input set.
Deletes an input set along with all the associated information.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the input set to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_input_set.py
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/_input_set.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/_input_set.py
new_input_set
¶
new_input_set(
id: str | None = None,
name: str | None = None,
description: str | None = None,
end_time: datetime | None = None,
instance_id: str | None = None,
maximum_runs: int | None = None,
run_ids: list[str] | None = None,
start_time: datetime | None = None,
inputs: list[ManagedInput] | None = None,
) -> InputSet
Create a new input set. You can create an input set from three different methodologies:
- Using
instance_id,start_time,end_timeandmaximum_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, will be generated if not provided.
TYPE:
|
|
Name of the input set. If not provided, the ID will be used as the name.
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/_input_set.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
update_input_set
¶
update_input_set(
id: str,
name: str | None = None,
description: str | None = None,
inputs: list[ManagedInput] | None = None,
) -> InputSet
Update an input set.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the input set to update.
TYPE:
|
|
Optional name of the input set.
TYPE:
|
|
Optional description of 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 |
|---|---|
Instance
|
The updated instance. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_input_set.py
Instance Management¶
_instance
¶
Application mixin for managing app instances.
ApplicationInstanceMixin
¶
Mixin class for managing app instances within an application.
delete_instance
¶
delete_instance(instance_id: str) -> None
Delete an instance.
Permanently removes the specified instance from the application.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the instance to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_instance.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/_instance.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/_instance.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/_instance.py
new_instance
¶
new_instance(
version_id: str,
id: str | None = None,
name: str | None = None,
description: str | None = None,
configuration: InstanceConfiguration | None = 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/_instance.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
update_instance
¶
update_instance(
id: str,
name: str | None = None,
version_id: str | None = None,
description: str | None = None,
configuration: InstanceConfiguration
| dict[str, Any]
| None = None,
locked: bool | None = 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:
|
|
Optional locked status of the instance. If True, the instance will be locked. If False, the instance will be unlocked. If None, the locked status will not be updated.
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/_instance.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
Managed Inputs¶
_managed_input
¶
Application mixin for handling app managed inputs.
ApplicationManagedInputMixin
¶
Mixin class for handling app managed inputs within an application.
delete_managed_input
¶
delete_managed_input(managed_input_id: str) -> None
Delete a managed input.
Permanently removes the specified managed input from the application.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the managed input to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_managed_input.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/_managed_input.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/_managed_input.py
new_managed_input
¶
new_managed_input(
id: str | None = None,
name: str | None = None,
description: str | None = None,
upload_id: str | None = None,
run_id: str | None = None,
format: Format | dict[str, Any] | None = None,
) -> ManagedInput
Create a new managed input. There are two methods for creating a managed input:
- Specifying the
upload_idparameter. You may use theupload_urlmethod to obtain the upload ID and theupload_datamethod to upload the data to it. - Specifying the
run_idparameter. The managed input will be created from the run specified by therun_idparameter.
Either the upload_id or the run_id parameter must be specified.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the managed input. Will be generated if not provided.
TYPE:
|
|
Name of the managed input. Will be generated if not provided.
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/_managed_input.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
update_managed_input
¶
update_managed_input(
managed_input_id: str,
name: str | None = None,
description: str | None = 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/_managed_input.py
Run Management¶
_run
¶
Application mixin for managing app runs.
ApplicationRunMixin
¶
Mixin class for managing app runs within an application.
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/_run.py
download_asset_content
¶
download_asset_content(
asset: RunAsset,
destination: str | Path | BytesIO | None = None,
) -> Any | None
Downloads an asset's content to a specified destination.
| PARAMETER | DESCRIPTION |
|---|---|
|
The asset to be downloaded.
TYPE:
|
|
The destination where the asset will be saved. This can be a file path (as a string or pathlib.Path) or an io.BytesIO object. If None, the asset content will not be saved to a file, but returned immediately. If the asset type is JSON, the content will be returned as a dict.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any or None
|
If |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> assets = app.list_assets("run-123")
>>> asset = assets[0] # Assume we want to download the first asset
>>> # Download to a file path
>>> app.download_asset_content(asset, "polygons.geojson")
>>> # Download to an in-memory bytes buffer
>>> import io
>>> buffer = io.BytesIO()
>>> app.download_asset_content(asset, buffer)
>>> # Download and get content directly (for JSON assets)
>>> content = app.download_asset_content(asset)
>>> print(content)
{'type': 'FeatureCollection', 'features': [...]}
Source code in nextmv/nextmv/cloud/application/_run.py
list_assets
¶
list_assets(run_id: str) -> list[RunAsset]
List the assets of a run.
Retrieves a list of assets associated with a specific run. This method ONLY
returns the asset metadata, the content needs to be fetched via the
download_asset_content method.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the run to list assets for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[RunAsset]
|
List of assets associated with the run. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> assets = app.list_assets("run-123")
>>> for asset in assets:
... print(asset.id, asset.name)
b459daa6-1c13-48c6-b4c3-a262ea94cd04 clustering_polygons
a1234567-89ab-cdef-0123-456789abcdef histogram
Source code in nextmv/nextmv/cloud/application/_run.py
list_runs
¶
list_runs(status: StatusV2 | None = None) -> list[Run]
List all runs.
You can use the optional status parameter to filter runs by their
status. Is not provided, all runs are returned.
| PARAMETER | DESCRIPTION |
|---|---|
|
Optional status to filter runs by.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Run]
|
List of runs. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_run.py
new_run
¶
new_run(
input: Input | dict[str, Any] | BaseModel | str = None,
instance_id: str | None = None,
name: str | None = None,
description: str | None = None,
upload_id: str | None = None,
options: Options | dict[str, str] | None = None,
configuration: RunConfiguration
| dict[str, Any]
| None = None,
batch_experiment_id: str | None = None,
external_result: ExternalRunResult
| dict[str, Any]
| None = None,
json_configurations: dict[str, Any] | None = None,
input_dir_path: str | None = 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/_run.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | |
new_run_with_result
¶
new_run_with_result(
input: Input | dict[str, Any] | BaseModel | str = None,
instance_id: str | None = None,
name: str | None = None,
description: str | None = None,
upload_id: str | None = None,
run_options: Options | dict[str, str] | None = None,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
configuration: RunConfiguration
| dict[str, Any]
| None = None,
batch_experiment_id: str | None = None,
external_result: ExternalRunResult
| dict[str, Any]
| None = None,
json_configurations: dict[str, Any] | None = None,
input_dir_path: str | None = None,
output_dir_path: str | 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 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/_run.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
run_input
¶
run_input(
run_id: str, output_dir_path: str | None = "."
) -> dict[str, Any] | None
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. If the content format of the run is csv-archive or
multi-file, then the output_dir_path parameter must be specified.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the run to retrieve the input for.
TYPE:
|
|
Path to a directory where non-JSON input files will be saved. This is required if the input is non-JSON. If the directory does not exist, it will be created. Uses the current directory by default.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any] | None
|
Input data of the run as a dictionary. If the input format is
non-JSON (e.g., csv-archive or multi-file), the method returns None
after saving the input files to the specified |
| 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/_run.py
566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | |
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/_run.py
run_logs_with_polling
¶
run_logs_with_polling(
run_id: str,
verbose: bool = False,
rich_print: bool = False,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
) -> list[TimestampedRunLog]
Get the logs of a run with polling.
Retrieves the logs of a run. This method polls for the logs until the
run finishes executing or the polling strategy is exhausted. It is the
"real-time" equivalent of the run_logs method. After the polling is
done, all the logs are returned sorted by timestamp. You can use the
verbose parameter to print the logs as they are obtained during the
polling process. You can also use the rich_print parameter to enable
rich printing for better formatting of the logs.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the run to retrieve the logs for.
TYPE:
|
|
Whether to print the logs as they are obtained during the polling process.
TYPE:
|
|
Whether to use rich printing for better formatting of the logs.
TYPE:
|
|
Options to use when polling for the run logs.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[TimestampedRunLog]
|
List of timestamped logs of the run. |
| 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 logs with polling
>>> logs = app.run_logs_with_polling("run-123", polling_opts)
>>> for log in logs:
... print(f"[{log.timestamp}] {log.log}")
[2024-01-01T12:00:00Z] Starting optimization...
[2024-01-01T12:00:05Z] Found initial solution
...
Source code in nextmv/nextmv/cloud/application/_run.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | |
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/_run.py
run_result
¶
run_result(
run_id: str, output_dir_path: str | None = "."
) -> 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/_run.py
run_result_with_polling
¶
run_result_with_polling(
run_id: str,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
output_dir_path: str | None = ".",
) -> 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/_run.py
track_run
¶
track_run(
tracked_run: TrackedRun,
instance_id: str | None = None,
configuration: RunConfiguration
| dict[str, Any]
| None = 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 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/_run.py
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 | |
track_run_with_result
¶
track_run_with_result(
tracked_run: TrackedRun,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
instance_id: str | None = None,
output_dir_path: str | None = ".",
configuration: RunConfiguration
| dict[str, Any]
| None = 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/_run.py
1043 1044 1045 1046 1047 1048 1049 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 | |
Secrets Management¶
_secrets
¶
Application mixin for managing app secrets.
ApplicationSecretsMixin
¶
Mixin class for managing app secrets within an application.
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/_secrets.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/_secrets.py
new_secrets_collection
¶
new_secrets_collection(
secrets: list[Secret],
id: str | None = None,
name: str | None = None,
description: str | None = 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. If the id or name parameters are
not provided, they will be generated based on a unique ID.
| 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. If not provided, a unique ID will be generated.
TYPE:
|
|
Name of the secrets collection. If not provided, the ID will be used.
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/_secrets.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
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/_secrets.py
update_secrets_collection
¶
update_secrets_collection(
secrets_collection_id: str,
name: str | None = None,
description: str | None = None,
secrets: list[Secret | dict[str, Any]] | None = 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/_secrets.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
Shadow Test Management¶
_shadow
¶
Application mixin for managing shadow tests.
ApplicationShadowMixin
¶
Mixin class for managing shadow tests within an application.
delete_shadow_test
¶
delete_shadow_test(shadow_test_id: str) -> None
Delete a shadow test.
Deletes a shadow test along with all the associated information, such as its runs.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the shadow test to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_shadow.py
list_shadow_tests
¶
List all shadow tests.
| RETURNS | DESCRIPTION |
|---|---|
list[ShadowTest]
|
List of shadow tests. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_shadow.py
new_shadow_test
¶
new_shadow_test(
comparisons: dict[str, list[str]],
termination_events: TerminationEvents,
shadow_test_id: str | None = None,
name: str | None = None,
description: str | None = None,
start_events: StartEvents | None = None,
) -> ShadowTest
Create a new shadow test in draft mode. Shadow tests are experiments that run instances in parallel to compare their results.
Use the comparisons parameter to define how to set up instance
comparisons. The keys of the comparisons dictionary are the baseline
instance IDs, and the values are the candidate lists of instance IDs to
compare against the respective baseline.
You may specify start_events to make the shadow test start at a
specific time. Alternatively, you may use the start_shadow_test
method to start the test.
The termination_events parameter is required and provides control
over when the shadow test should terminate. Alternatively, you may use
the stop_shadow_test method to stop the test.
| PARAMETER | DESCRIPTION |
|---|---|
|
Dictionary defining the baseline and candidate instance IDs for comparison. The keys are baseline instance IDs, and the values are lists of candidate instance IDs to compare against the respective baseline.
TYPE:
|
|
Termination events for the shadow test.
TYPE:
|
|
ID of the shadow test. Will be generated if not provided.
TYPE:
|
|
Name of the shadow test. If not provided, the ID will be used as the name.
TYPE:
|
|
Optional description of the shadow test.
TYPE:
|
|
Start events for the shadow test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ShadowTest
|
The created shadow test. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_shadow.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
shadow_test
¶
shadow_test(shadow_test_id: str) -> ShadowTest
Get a shadow test. This method also returns the runs of the shadow
test under the .runs attribute.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the shadow test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ShadowTest
|
The requested shadow test details. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_shadow.py
shadow_test_metadata
¶
shadow_test_metadata(
shadow_test_id: str,
) -> ShadowTestMetadata
Get metadata for a shadow test.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the shadow test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ShadowTestMetadata
|
The requested shadow test metadata. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_shadow.py
start_shadow_test
¶
start_shadow_test(shadow_test_id: str) -> None
Start a shadow test. Create a shadow test in draft mode using the
new_shadow_test method, then use this method to start the test.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the shadow test to start.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_shadow.py
stop_shadow_test
¶
stop_shadow_test(
shadow_test_id: str, intent: StopIntent
) -> None
Stop a shadow test. The test should already have started before using this method.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the shadow test to stop.
TYPE:
|
|
Intent for stopping the shadow test.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_shadow.py
update_shadow_test
¶
update_shadow_test(
shadow_test_id: str,
name: str | None = None,
description: str | None = None,
) -> ShadowTest
Update a shadow test.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the shadow test to update.
TYPE:
|
|
Optional name of the shadow test.
TYPE:
|
|
Optional description of the shadow test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ShadowTest
|
The information with the updated shadow test. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_shadow.py
Switchback Test Management¶
_switchback
¶
Application mixin for managing switchback tests.
ApplicationSwitchbackMixin
¶
Mixin class for managing switchback tests within an application.
delete_switchback_test
¶
delete_switchback_test(switchback_test_id: str) -> None
Delete a switchback test.
Deletes a switchback test along with all the associated information, such as its runs.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the switchback test to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_switchback.py
list_switchback_tests
¶
List all switchback tests.
| RETURNS | DESCRIPTION |
|---|---|
list[SwitchbackTest]
|
List of switchback tests. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_switchback.py
new_switchback_test
¶
new_switchback_test(
comparison: TestComparisonSingle,
unit_duration_minutes: float,
units: int,
switchback_test_id: str | None = None,
name: str | None = None,
description: str | None = None,
start: datetime | None = None,
) -> SwitchbackTest
Create a new switchback test in draft mode. Switchback tests are experiments that alternate between different instances over specified time intervals.
Use the comparison parameter to define how to set up the instance
comparison. The test will alternate between the baseline and candidate
instances defined in the comparison.
You may specify start to make the switchback test start at a
specific time. Alternatively, you may use the start_switchback_test
method to start the test.
| PARAMETER | DESCRIPTION |
|---|---|
|
Comparison defining the baseline and candidate instances.
TYPE:
|
|
Duration of each interval in minutes. The value must be between 1 and 10080.
TYPE:
|
|
Total number of intervals in the switchback test. The value must be between 1 and 1000.
TYPE:
|
|
Optional ID for the switchback test. Will be generated if not provided.
TYPE:
|
|
Optional name of the switchback test. If not provided, the ID will be used as the name.
TYPE:
|
|
Optional description of the switchback test.
TYPE:
|
|
Optional scheduled start time for the switchback test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SwitchbackTest
|
The created switchback test. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_switchback.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
start_switchback_test
¶
start_switchback_test(switchback_test_id: str) -> None
Start a switchback test. Create a switchback test in draft mode using the
new_switchback_test method, then use this method to start the test.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the switchback test to start.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_switchback.py
stop_switchback_test
¶
stop_switchback_test(
switchback_test_id: str, intent: StopIntent
) -> None
Stop a switchback test. The test should already have started before using this method.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the switchback test to stop.
TYPE:
|
|
Intent for stopping the switchback test.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_switchback.py
switchback_test
¶
switchback_test(switchback_test_id: str) -> SwitchbackTest
Get a switchback test. This method also returns the runs of the switchback
test under the .runs attribute.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the switchback test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SwitchbackTest
|
The requested switchback test details. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> switchback_test = app.switchback_test("switchback-123")
>>> print(switchback_test.name)
'My Switchback Test'
Source code in nextmv/nextmv/cloud/application/_switchback.py
switchback_test_metadata
¶
switchback_test_metadata(
switchback_test_id: str,
) -> SwitchbackTestMetadata
Get metadata for a switchback test.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the switchback test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SwitchbackTestMetadata
|
The requested switchback test metadata. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> metadata = app.switchback_test_metadata("switchback-123")
>>> print(metadata.name)
'My Switchback Test'
Source code in nextmv/nextmv/cloud/application/_switchback.py
update_switchback_test
¶
update_switchback_test(
switchback_test_id: str,
name: str | None = None,
description: str | None = None,
) -> SwitchbackTest
Update a switchback test.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the switchback test to update.
TYPE:
|
|
Optional name of the switchback test.
TYPE:
|
|
Optional description of the switchback test.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SwitchbackTest
|
The information with the updated switchback test. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/cloud/application/_switchback.py
Version Management¶
_version
¶
Application mixin for managing app versions.
ApplicationVersionMixin
¶
Mixin class for managing app versions within an application.
delete_version
¶
delete_version(version_id: str) -> None
Delete a version.
Permanently removes the specified version from the application.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the version to delete.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
Source code in nextmv/nextmv/cloud/application/_version.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/_version.py
new_version
¶
new_version(
id: str | None = None,
name: str | None = None,
description: str | None = None,
exist_ok: bool = False,
) -> Version
Create a new version using the latest pushed executable.
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/_version.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
update_version
¶
update_version(
version_id: str,
name: str | None = None,
description: str | None = None,
) -> Version
Update a version.
This method updates a specific version of the application. It mimics a PATCH operation by allowing you to update only the name and/or description fields while preserving all other fields.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the version to update.
TYPE:
|
|
Optional new name for the version.
TYPE:
|
|
Optional new description for the version.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Version
|
The updated version object. |
| RAISES | DESCRIPTION |
|---|---|
HTTPError
|
If the response status code is not 2xx. |
Examples:
>>> # Update a version's name
>>> updated = app.update_version("v1.0.0", name="Version 1.0")
>>> print(updated.name)
'Version 1.0'
>>> # Update a version's description
>>> updated = app.update_version("v1.0.0", description="Initial release")
>>> print(updated.description)
'Initial release'
Source code in nextmv/nextmv/cloud/application/_version.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/_version.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.")