Skip to content

Latest commit

 

History

History
175 lines (114 loc) · 5.3 KB

File metadata and controls

175 lines (114 loc) · 5.3 KB

Function registration and lifecycle management: The CLI tool

Once you have defined your project's asynchronous tasks as Python functions, you must register these functions with the Multinode control plane before you can invoke them.

This section describes how to register a project's function definitions and manage the lifecycle of a project using the multinode CLI.

Authenticating with the control plane

Logging in

To use the multinode CLI, you must first authenticate with the control plane using the multinode login command.

multinode login

You will be prompted to enter your Multinode control plane URL and API key, which you should have noted down from when you installed multinode into your AWS account.

Logging out

The multinode logout command terminates an authenticated session.

multinode logout

Function lifecycle management

Registering project function definitions

The multinode deploy command is used to register project function definitions with the Multinode control plane. You must run multinode deploy before you can invoke your project functions.

multinode deploy {CODE_PATH} --project-name={PROJECT_NAME}

Under the hood, this command:

  • Builds a Docker image containing the function definitions in {CODE_PATH}.
  • Uploads the Docker image to a private Docker repository in your AWS account.
  • Registers the Docker image URI with the Multinode control plane, associating it with the project name {PROJECT_NAME}.

When complete, the command returns a version ID for the project.

{CODE_PATH} is the folder containing the main.py file that contains the functions defining your asynchronous tasks (i.e. the functions with the @mn.function() decorator).

For example, if your project folder structure is...

[CURRENT PATH]
└── tasks/
    ├── .env
    ├── requirements.txt
    ├── main.py
    └── submodule/
        ├── __init__.py
        ├── file_1.py
        └── file_2.py

... then {CODE_PATH} should be tasks/.

Updating project function definitions

The multinode upgrade command is used to register a new version of your project function definitions with the Multinode control plane. You must run this command every time you make changes to the function definitions in your project.

multinode upgrade {CODE_PATH} --project-name={PROJECT_NAME}

When complete, this command returns a new version ID for the project.

In-flight function invocations will continue to run using the old version of the function definitions, but future function invocations will use the new version of the code (unless a historical version ID is explicitly specified in the codebase where the invocation is made).

Deleting a project

The multinode undeploy command aborts all in-flight invocations associated with a project, and deletes the project from the Multinode control plane.

multinode undeploy --project-name={PROJECT_NAME}

Listing existing projects

The multinode list command lists all projects currently registered with the control plane.

multinode list

Printing information about projects, functions and invocations

The multinode describe command prints information about projects, functions and invocations. Exactly what is printed can be controlled by flags.

Printing information about a project

multinode describe --project-name={PROJECT_NAME}

This command prints:

  • the IDs of all versions of the project
  • the names of all functions associated with the latest version of the project

To see the names of functions associated with a historical version of the project, use the following command.

multinode describe --project-name={PROJECT_NAME} --version-id={VERSION_ID}

(The --version-id={VERSION_ID} flag can be used in a similar manner with the remaining multinode describe commands, as well as with the multinode logs command, which is covered below.)

Printing information about a function

multinode describe --project-name={PROJECT_NAME} --function-name={FUNCTION_NAME}

This command prints:

  • Information about the function - for example, its CPU and memory requirements, concurrency quota, timeout limit and retry policy
  • the IDs of recent invocations of this function

Printing information about a function invocation

multinode describe --project-name={PROJECT_NAME} --function-name={FUNCTION_NAME} \\
  --invocation-id={INVOCATION_ID}

This command prints:

  • The status of the function invocation, and its creation time
  • The ID, status and timestamps for every execution associated with this function invocation.

(An invocation may have multiple executions associated with it if it has been retried due to failures.)

Viewing logs for a function execution

The multinode logs command prints the logs from a function execution.

multinode logs --project-name={PROJECT_NAME} --function-name={FUNCTION_NAME} \\
  --invocation-id={INVOCATION_ID} --execution-id={EXECUTION_ID}

Next: Function invocations