The echo app¶
Several examples assume you have a Nextmv application called echo. This is
just a simple application created for demonstration purposes. It takes the
input and echoes it with some minor modifications.
Let's get set up with the echo application. Before starting:
- Sign up for a Nextmv account.
- Get your API key. Go to Settings > API Key.
Make sure that you have your API key set as an environment variable:
Now that you have a valid Nextmv account and API key, let's create the
echo Nextmv app (start in an empty directory).
First let's create a uv project.
Create a file called main.py with the code for the basic app that echoes the input.
import sys
import time
import nextmv
before = time.time()
input = nextmv.load()
solution = {
"echo": {
"data": input.data,
"args": sys.argv[1:],
},
}
metrics = {
"run_duration": time.time() - before,
}
nextmv.write(solution=solution, metrics=metrics)
Note that the application uses the nextmv Python SDK. This
library is a dependency of Nextpipe and should be installed automatically when
you install Nextpipe. For this simple example, let's add the nextmv
dependency so that we can run the app locally.
Now, add an app.yaml manifest that configures this as a
json application.
type: python
runtime: ghcr.io/nextmv-io/runtime/python:3.11
python:
pip-requirements: pyproject.toml
files:
- main.py
configuration:
content:
format: json
At this point, your project directory should look like this:
We can now run the simple application locally to test it. This app will read the input from stdin, and then write a modified version of the input to stdout.
The last step is to push the application to Nextmv Cloud. We can do
this with the CLI. Before pushing, create an application
with the ID echo.
Lastly, push the application to your Nextmv account.
💿 Starting build for Nextmv application echo.
🐍 Bundling Python dependencies.
⏫ 34/34 compressed dependencies found in cache.
📋 Copying files listed in app.yaml manifest.
💾 Compressing application into tarball.
🛠 Appending application files.
📦 Packaged application (2 app files, 51.27 MiB with dependencies).
🌟 Pushing to application: echo.
💥 Successfully pushed to application: echo.
{
"app_id": "echo",
"endpoint": "https://api.cloud.nextmv.io",
"instance_url": "v1/applications/echo/runs?instance_id=latest"
}
🎉🎉🎉 Congratulations, you are ready to run the examples!