Application Module¶
This section documents the application components of the Nextmv Python SDK - Local experience.
application
¶
Application module for interacting with local Nextmv applications.
This module provides functionality to interact with applications in Nextmv, including application management, running applications, and managing inputs.
| CLASS | DESCRIPTION |
|---|---|
Application |
Class for interacting with local Nextmv applications. |
Application
¶
Bases: BaseModel
A decision model that can be executed.
You can import the Application class directly from local:
This class represents an application in Nextmv, providing methods to interact with the application, run it with different inputs, manage versions, instances, experiments, and more.
| PARAMETER | DESCRIPTION |
|---|---|
|
Source of the application, when initialized locally. An application's
source typically refers to the directory containing the
TYPE:
|
|
Description of the application.
TYPE:
|
Examples:
>>> from nextmv.local import Application
>>> app = Application(src="path/to/app")
>>> # Retrieve an app's run result
>>> result = app.run_result("run-id")
-
nextmv
💻 Local
Reference
Application Module
applicationApplication
app_id
class-attribute
instance-attribute
¶
ID of the application. This ID is auto-generated if not provided.
clone_run
¶
clone_run(
cloned_run_id: str,
input: Input | dict[str, Any] | BaseModel | str = None,
name: str | None = None,
description: str | None = None,
options: Options | dict[str, str] | None = None,
configuration: RunConfiguration
| dict[str, Any]
| None = None,
json_configurations: dict[str, Any] | None = None,
input_dir_path: str | None = None,
) -> str
Clone a run, allowing overrides on various parameters.
This method fetches all the elements of the run identified with
cloned_run_id and creates a new run with the same characteristics.
Specifying different arguments such as input, options, and
more, allows you to override specific attributes of the original
(cloned) run.
Returns the run_id of the new (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 data, use the
TYPE:
|
|
Name of the local run.
TYPE:
|
|
Description of the local run.
TYPE:
|
|
Options to use for the run. This can be a
TYPE:
|
|
Configuration 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. This is useful for
input formats like
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
ID ( |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
FileNotFoundError
|
If the app.yaml file cannot be found in the specified |
Examples:
>>> from nextmv.local import Application
>>> app = Application(id="my-app", src="/path/to/app")
>>> run_id = app.clone_run(cloned_run_id="run-456")
>>> print(f"Local run started with ID: {run_id}")
Source code in nextmv/nextmv/local/application.py
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 | |
clone_run_with_result
¶
clone_run_with_result(
cloned_run_id: str,
input: Input | dict[str, Any] | BaseModel | str = None,
name: str | None = None,
description: str | None = None,
run_options: Options | dict[str, str] | None = None,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
configuration: RunConfiguration
| dict[str, Any]
| None = None,
json_configurations: dict[str, Any] | None = None,
input_dir_path: str | None = None,
output_dir_path: str | None = ".",
) -> RunResult
Clone a run and poll for the result. This is a convenience method that
combines the clone_run and run_result_with_polling methods,
applying polling logic to check when the run succeeded.
This method is the local equivalent to
cloud.Application.clone_run_with_result, which submits the input to
Nextmv Cloud. This method runs the application locally using the src
of the app.
Make sure that the src attribute is set on the Application class
before running locally, as it is required by the method.
| PARAMETER | DESCRIPTION |
|---|---|
|
Input to use for the run. This can be a If If you want to work with When
When working with JSON data, use the
TYPE:
|
|
Name of the local run.
TYPE:
|
|
Description of the local run.
TYPE:
|
|
Options to use for the run. This can be a
|
|
Configuration 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. 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, including output. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
FileNotFoundError
|
If the app.yaml file cannot be found in the specified |
Examples:
>>> from nextmv.local import Application
>>> app = Application(id="my-app", src="/path/to/app")
>>> run_result = app.clone_run_with_result(cloned_run_id="run-456")
>>> print(f"Local run completed with result: {run_result}")
Source code in nextmv/nextmv/local/application.py
562 563 564 565 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 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | |
compare_runs
¶
compare_runs(run_ids: Iterable[str]) -> RunComparison
Compare multiple runs by their IDs.
| PARAMETER | DESCRIPTION |
|---|---|
|
An iterable of run IDs to compare.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ComparedRuns
|
An object containing the comparison of the runs. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the number of provided runs is less than 1 or greater than 20. |
Source code in nextmv/nextmv/local/application.py
content_format
class-attribute
instance-attribute
¶
Warning
InputFormat is deprecated, but kept for backward compatibility. Use
ContentFormat instead.
The content format of the application, which is determined by the manifest.
description
class-attribute
instance-attribute
¶
Description of the application.
from_registry
classmethod
¶
from_registry(
src: str | None = None, app_id: str | None = None
) -> Application
Load an application from the local registry.
The local registry is a YAML file stored at $HOME/.nextmv/registry.yaml
that keeps track of locally registered applications. This method looks
for an entry in the local registry that matches the provided src or
app_id, and loads the application from the corresponding source path.
Specify either the src or the app_id to identify the application to
load. If both are provided, the method will prioritize loading by
app_id.
| PARAMETER | DESCRIPTION |
|---|---|
|
Source path of the application to load. This is typically the path
to the directory containing the application's manifest (
TYPE:
|
|
ID of the application to load. This ID is auto-generated if not provided during registration.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Application
|
The loaded application instance. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither |
Examples:
Assuming an application is registered in the local registry with the following entry:
>>> from nextmv.local import Application
>>> app = Application.from_registry(app_id="app-123")
>>> print(app.src)
/path/to/app
Source code in nextmv/nextmv/local/application.py
get_or_register
classmethod
¶
get_or_register(
app_src: str, app_id: str | None = None
) -> tuple[Application, bool]
Get a local application from the registry or register it if it does not exist.
This function checks if a local application with the given source and
ID is already registered in the local registry. If it is, it retrieves
and returns that application. If it is not registered, it creates a new
Application instance with the provided source and ID, registers it in
the local registry, and then returns it. The boolean in the returned
tuple indicates whether a new application was registered (True) or an
existing one was retrieved (False).
| PARAMETER | DESCRIPTION |
|---|---|
|
The source path of the application to get or register.
TYPE:
|
|
The ID of the application to get or register. If None, the ID will be derived from the application source.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Application, bool]
|
A tuple containing the local application retrieved from the registry or newly registered, and a boolean indicating whether the application was newly registered. |
Source code in nextmv/nextmv/local/application.py
initialize
classmethod
¶
initialize(
src: str | None = None,
description: str | None = None,
destination: str | None = None,
manifest_type: ManifestType = PYTHON,
content_format: ContentFormat = JSON,
example: str | None = "hello-world",
should_register: bool = False,
) -> Application
Initialize a sample Nextmv application, locally.
This method will create a new application from a template in the local
file system. The application is a dir with the name given by src (it
becomes the source of the app), under the location given by
destination. If the destination parameter is not specified, the
current working directory is used as default. This method will scaffold
the application with the necessary files and directories to have an
opinionated structure for your decision model. The template used is
determined by the combination of manifest_type and content_format.
The example parameter further specifies which example within the
template to use when scaffolding the application. Once the application
is initialized, you are encouraged to complete it with the decision
model itself, so that the application can be run locally.
If the src parameter is not provided, a random name will be generated
for the application. If should_register is set to True, the
application will also be registered in the local registry after
initialization.
| PARAMETER | DESCRIPTION |
|---|---|
|
Source (ID, name) of the application. Will be generated if not provided.
TYPE:
|
|
Description of the application.
TYPE:
|
|
Destination directory where the application will be initialized. If not provided, the current working directory will be used.
TYPE:
|
|
Type of manifest to use for the application. Determines the language/runtime template that will be scaffolded.
TYPE:
|
|
Content format of the application's input and output. Determines which template variant is used when scaffolding the application.
TYPE:
|
|
The example template to use when initializing the application.
Valid values depend on the
TYPE:
|
|
Whether to register the application in the local registry after
initialization. If True, the application will be added to
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Application
|
The initialized application instance. |
Source code in nextmv/nextmv/local/application.py
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 416 417 418 | |
is_registered
¶
Check if the local application is registered in the local registry.
This method checks if the application has an entry in the local registry.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the application is registered, False otherwise. |
Source code in nextmv/nextmv/local/application.py
list_runs
¶
list_runs(status: StatusV2 | None = None) -> list[Run]
List all runs for the application.
| PARAMETER | DESCRIPTION |
|---|---|
|
If specified, only runs with the given status will be returned.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Run]
|
A list of all runs associated with the application. |
Source code in nextmv/nextmv/local/application.py
manifest
class-attribute
instance-attribute
¶
Manifest of the application. A manifest is a file named app.yaml that
must be present at the root of the application's src directory. If you
specify this argument when creating the Application, the provided manifest
will be written to the src directory, overriding any existing manifest
file.
model_post_init
¶
Actions taken after the Application model is initialized.
Source code in nextmv/nextmv/local/application.py
new_run
¶
new_run(
input: Input | dict[str, Any] | BaseModel | str = None,
name: str | None = None,
description: str | None = None,
options: Options | dict[str, str] | None = None,
configuration: RunConfiguration
| dict[str, Any]
| None = None,
json_configurations: dict[str, Any] | None = None,
input_dir_path: str | None = None,
) -> str
Run the application locally with the provided input.
This method is the local equivalent to cloud.Application.new_run,
which submits the input to Nextmv Cloud. This method runs the
application locally using the src of the app.
Make sure that the src attribute is set on the Application class
before running locally, as it is required by the method.
| PARAMETER | DESCRIPTION |
|---|---|
|
Input to use for the run. This can be a If If you want to work with When
When working with JSON data, use the
TYPE:
|
|
Name of the local run.
TYPE:
|
|
Description of the local run.
TYPE:
|
|
Options to use for the run. This can be a
TYPE:
|
|
Configuration 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. This is useful for
input formats like
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
ID ( |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
FileNotFoundError
|
If the app.yaml file cannot be found in the specified |
Examples:
>>> from nextmv.local import Application
>>> app = Application(id="my-app", src="/path/to/app")
>>> run_id = app.new_run(
... input={"vehicles": [{"id": "v1"}]},
... options={"duration": "10s"}
... )
>>> print(f"Local run started with ID: {run_id}")
Source code in nextmv/nextmv/local/application.py
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 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 | |
new_run_with_result
¶
new_run_with_result(
input: Input | dict[str, Any] | BaseModel | str = None,
name: str | None = None,
description: str | None = None,
run_options: Options | dict[str, str] | None = None,
polling_options: PollingOptions = DEFAULT_POLLING_OPTIONS,
configuration: RunConfiguration
| 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 local 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 local run succeeded.
This method is the local equivalent to
cloud.Application.new_run_with_result, which submits the input to
Nextmv Cloud. This method runs the application locally using the src
of the app.
Make sure that the src attribute is set on the Application class
before running locally, as it is required by the method.
| PARAMETER | DESCRIPTION |
|---|---|
|
Input to use for the run. This can be a If If you want to work with When
When working with JSON data, use the
TYPE:
|
|
Name of the local run.
TYPE:
|
|
Description of the local run.
TYPE:
|
|
Options to use for the run. This can be a
TYPE:
|
|
Options to use when polling for the run result.
TYPE:
|
|
Configuration 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. 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, including output. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
FileNotFoundError
|
If the app.yaml file cannot be found in the specified |
Examples:
>>> from nextmv.local import Application
>>> app = Application(id="my-app", src="/path/to/app")
>>> run_result = app.new_run_with_result(
... input={"vehicles": [{"id": "v1"}]},
... options={"duration": "10s"}
... )
>>> print(f"Local run completed with ID: {run_result.id}")
Source code in nextmv/nextmv/local/application.py
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 | |
register
¶
Register the local application in the local registry.
This method adds an entry for the application in the local registry,
which is stored as a YAML file at $HOME/.nextmv/registry.yaml. The
registry keeps track of locally registered applications, allowing you
to manage and list them easily.
If the application is already registered, this method does nothing.
Source code in nextmv/nextmv/local/application.py
run_information
¶
run_information(run_id: str) -> RunInformation
Get the information of a local run, including its metadata.
This method is the local equivalent to
cloud.Application.run_information, which retrieves the information of
a remote run in Nextmv Cloud. This method is used to get the
information of a run that was executed locally using the new_run or
new_run_with_result method.
Retrieves information about a run without including the run output. This is useful when you only need the run's status, metadata, and other non-output attributes.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the run to retrieve information for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RunInformation
|
Information of the run, including metadata. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Examples:
Source code in nextmv/nextmv/local/application.py
run_input
¶
run_input(
run_id: str, output_dir_path: str | None = "."
) -> dict[str, Any] | str | None
Get the input of a local run.
This method retrieves the input of a run that was executed locally
using the new_run or new_run_with_result method. This is the local
equivalent to cloud.Application.run_input, which retrieves the input
of a remote run in Nextmv Cloud.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the run to retrieve 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] | str | None
|
The input of the run depending on the input format. If the input
format is JSON, a dict is returned. If the input format is text, a
string is returned. For multi-file and csv-archive, the input files
are saved to the given |
Source code in nextmv/nextmv/local/application.py
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 | |
run_logs
¶
run_logs(run_id: str) -> str
Get the logs of a local run.
If the run does not have any logs, or they are empty, then this method
simply returns a blank string. This method is equivalent to fetching
the content of the .nextmv/runs/{run_id}/logs/logs.log file.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the run to retrieve logs for.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The contents of the logs file for the run. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Source code in nextmv/nextmv/local/application.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,
log_func: Callable[[str], None] | None = None,
) -> list[str]
Get the logs of a local 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 as a list of strings (one per line).
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:
|
|
Optional custom logging function callback. This function is invoked
independently of the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
List of log lines of the run. |
| RAISES | DESCRIPTION |
|---|---|
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 import PollingOptions
>>> polling_opts = PollingOptions(max_tries=50, max_duration=600)
>>> logs = app.run_logs_with_polling("run-123", polling_opts)
>>> for line in logs:
... print(line)
Starting optimization...
Found initial solution
Source code in nextmv/nextmv/local/application.py
1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 | |
run_metadata
¶
run_metadata(run_id: str) -> RunInformation
Warning
run_metadata is deprecated, use run_information instead.
Get the metadata of a local run.
This method is the local equivalent to
cloud.Application.run_metadata, which retrieves the metadata of a
remote run in Nextmv Cloud. This method is used to get the metadata of
a run that was executed locally using the new_run or
new_run_with_result method.
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 |
|---|---|
ValueError
|
If the |
Examples:
>>> metadata = app.run_metadata("run-789")
>>> print(metadata.metadata.status_v2)
StatusV2.succeeded
Source code in nextmv/nextmv/local/application.py
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 | |
run_result
¶
run_result(
run_id: str, output_dir_path: str | None = "."
) -> RunResult
Get the local result of a run.
This method is the local equivalent to cloud.Application.run_result,
which retrieves the result of a remote run in Nextmv Cloud. This method
is used to get the result of a run that was executed locally using the
new_run or new_run_with_result method.
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 |
|---|---|
ValueError
|
If the |
Examples:
Source code in nextmv/nextmv/local/application.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 local run with polling.
This method is the local equivalent to
cloud.Application.run_result_with_polling, which retrieves the result
of a remote run in Nextmv Cloud. This method is used to get the result
of a run that was executed locally using the new_run or
new_run_with_result method.
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 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/local/application.py
1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 | |
run_visuals
¶
run_visuals(run_id: str) -> list[str]
Open the local run visuals in a web browser.
This method opens the visual representation of a locally executed run
in the default web browser. It assumes that the run was executed locally
using the new_run or new_run_with_result method and that
the necessary visualization files are present.
If the run was correctly configured to produce visual assets, then the
run will contain a visuals directory with one or more HTML files.
Each file is opened in a new tab in the default web browser.
| PARAMETER | DESCRIPTION |
|---|---|
|
ID of the local run to visualize.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str]
|
The local URLs of the visual files that were opened in the web browser. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
Source code in nextmv/nextmv/local/application.py
src
instance-attribute
¶
Source of the application, when initialized locally. An application's
source typically refers to the directory containing the app.yaml
manifest.
sync
¶
sync(
target: Application,
run_ids: list[str] | None = None,
instance_id: str | None = None,
verbose: bool | None = False,
rich_print: bool | None = False,
) -> None
Sync the local application to a Nextmv Cloud application target.
The Application class allows you to perform and handle local
application runs with methods such as:
new_runnew_run_with_resultrun_metadatarun_resultrun_result_with_polling
The runs produced locally live under self.src/.nextmv/runs. This
method syncs those runs to a Nextmv Cloud application target, making
them available for remote execution and management.
| PARAMETER | DESCRIPTION |
|---|---|
|
Target Nextmv Cloud application where the local application runs will be synced to.
TYPE:
|
|
List of run IDs to sync. If None, all local runs found under
TYPE:
|
|
Optional instance ID if you want to associate your runs with an instance.
TYPE:
|
|
Whether to print verbose output during the sync process. Useful for debugging a large number of runs being synced.
TYPE:
|
|
Whether to use rich printing for output during the sync process.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the |
ValueError
|
If the |
ValueError
|
If the application does not exist in Nextmv Cloud. |
ValueError
|
If a run does not exist locally. |
HTTPError
|
If the response status code is not 2xx. |
Source code in nextmv/nextmv/local/application.py
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 | |
update
¶
update(
app_id: str | None = None,
description: str | None = None,
content_format: ContentFormat | None = None,
) -> None
Update the local application.
This method allows you to update the local application's metadata, such as its app_id, description and content format. It does not affect the application's source code or runs.
| PARAMETER | DESCRIPTION |
|---|---|
|
New app_id for the application. If None, the app_id is not updated.
TYPE:
|
|
New description for the application. If None, the description is not updated.
TYPE:
|
|
New content format for the application. If None, the content format is not updated.
TYPE:
|