tutorialsreferenceguide

Running locally

With SPAI you can run your projects locally. This is useful for developing and testing your project before deploying it to the cloud, or if you run your own hardware.

Starter project

You can create a new project from scratch or using the starter project, which will setup a basic project for you.

spai init --help

To create a new project using the starter project, run the following command:

spai init "project-name"

This command will create a new project in the current directory. You can also specify a directory name to create the project in a new directory.

spai init "project-name" -p "path-to-directory"

Installing dependencies

Your SPAI project may have some dependencies that need to be installed.

spai install --help

You can install them using the following command in the project directory:

spai install

If your project is in another directory, you can specify the path to the project directory:

spai install "path-to-directory"

We recommend you create a Python environment for your project using virtualenv or conda to avoid conflicts with other projects.

Running the project

Once you have installed the dependencies, you can run the project with:

spai run

This command will run your scripts and start all the APIs, user interfaces and notebooks that you have defined in your project. User the --help flag to see all the available options:

spai run --help

You can run a project in a different directory using the following command:

spai run "path-to-directory"

And install and run the project in one command:

spai run "path-to-directory" -i

If your project uses global variables that you want to share across services, use -v:

spai run -v A=1 -v B=2

However, we recommend you define them in the spai.vars.json file.

We don’t recommend this mechanism to share environment variables. For that, use the .env file instead.

Troubleshooting

If you encounter any issues during the installation of SPAI, please get in touch with use through our Discord server.

Back to top