Application

Run an Application

Learn how to run a Nextmv Application.

To run an Application, you can use of the following methods:

  • new_run: creates (submits) a new run and returns the ID (run_id) of the run. With the run_id, you can perform other operations, such as getting the run’s metadata, logs, and result.
  • new_run_with_result: does the same as new_run, but it also polls for the result of the run. This method returns the result of the run, and it is useful for submitting and getting the result in a single call. Using this method is recommended because we have a built-in polling mechanism that handles retries, exponential backoff, jitter, and timeouts.

The following example shows how to make a new run.

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>")

run_id = app.new_run(
    input={"foo": "bar"},
)

print(run_id)
Copy

As mentioned before, you may use the recommended new_run_with_result method and get the results immediately after submitting the run and they become available.

import json
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>")

result = app.new_run_with_result(
    input={...},
)

print(json.dumps(result.to_dict(), indent=2))

Copy

Page last updated