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 Team > 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.
-
In a new directory, create a file called
main.pywith the code for the basic app that echoes the input.import sys import time import nextmv before = time.time() input = nextmv.load() output = nextmv.Output( solution={ "echo": { "data": input.data, "args": sys.argv[1:], }, }, statistics={"run": {"duration": time.time() - before}}, ) nextmv.write(output)Note that the application uses the
nextmvlibrary. This library is a dependency ofnextpipeand should be installed automatically when you installnextpipe.You may run the app locally to test it:
-
Create a
requirements.txtfile with the following requirements for running the app: -
Create an
app.yamlfile (the app manifest) with the following instructions: -
Push the application to your Nextmv account. Create a
push.pyscript in the same directory with the following code: -
Execute the
push.pyscript to push the app to your Nextmv account:$ python push.py 💽 Starting build for Nextmv application. 🐍 Bundling Python dependencies. 📋 Copied files listed in "app.yaml" manifest. 📦 Packaged application (552 files, 5.04 MiB). 🌟 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=devint" }Alternatively, you can use the Nextmv CLI to create and push the app:
Now you are ready to run the examples.