Deployments
Ephemeral runs
An ephemeral run can be used to:
- Create a temporary deployment of a web app backend for development and testing purposes.
- Run a one-off task that requires dynamically-provisioned cloud resources.
An ephemeral run is performed using the multinode run
command. The full syntax is:
multinode run \
--env-file={environment-variables-file} \
--region={cloud-region-name} \
{name-of-main-script}
The lifetime of an ephemeral run is tied to the terminal process. Closing the terminal or pressing CTRL+C
will abort the run immediately, tearing down all provisioned resources.
During an ephemeral run, logs from all workloads will be printed directly to the console terminal.
The requirements file
It is important that the current directory contains all the source code for the project, plus a requirements.txt
file. See the section on dependencies for more flexible dependency management options.
Environment variables
The environment variables file should be structured as follows.
POSTGRES_HOSTNAME=12.34.56.78
POSTGRES_USER=user
POSTGRES_PASSWORD=password
Cloud region
The cloud region name should be a name of an AWS region. Currently, we only host deployments in the following regions:
us-east-1
: North Virginia (Default)us-west-2
: Oregoneu-central-1
: Frankfurtap-southeast-1
: Singapore
The main script
The main script should contain all decorated functions (e.g. mn.function
, mn.service
), or should import the scripts where they are declared.
Coming soon
We are working on extending the library to improve the experience of importing functions from other files.
Behaviour of ephemeral runs
If the code contains a service or daemon, then the run will stay alive until the terminal process is terminated.
import multinode as mn
from fastapi import FastAPI
import uvicorn
app = FastAPI()
@app.get()
def get():
return "Hello"
@mn.service(port=80)
def api()
uvicorn.run(app)
# Runs until you press CTRL+C
If the code does not contain a service or daemon, then the run will terminate when the top-level code in the main script finishes executing. (Terminating the terminal process will abort the run prematurely.)
import multinode as mn
@mn.function()
def square(x):
time.sleep(30)
return x ** 2
answer = square.map(range(10))
print(answer)
# Terminates here, unless CTRL+C has already been pressed