Upload a module to the Viam Registry
After writing a module, you can upload your module to the Viam Registry to:
- share your module with other Viam users
- deploy your module to a fleet of machines from a central interface
You can choose to upload it to the Viam Registry as a public module that is shared with other Viam users, or as a private module that is shared only within your organization.
To upload your custom module to the Viam Registry, either as a public or private module, use the Viam CLI commands create
and upload
following these instructions.
In this page
Prerequisites
Upload a module
1. Install the CLI
First, install the Viam CLI and authenticate to Viam, from the same machine that you intend to upload your module from.
To download the Viam CLI on a macOS computer, install brew and run the following commands:
brew tap viamrobotics/brews
brew install viam
To download the Viam CLI on a Linux computer with the aarch64
architecture, run the following commands:
sudo curl -o /usr/local/bin/viam https://storage.googleapis.com/packages.viam.com/apps/viam-cli/viam-cli-stable-linux-arm64
sudo chmod a+rx /usr/local/bin/viam
To download the Viam CLI on a Linux computer with the amd64
(Intel x86_64
) architecture, run the following commands:
sudo curl -o /usr/local/bin/viam https://storage.googleapis.com/packages.viam.com/apps/viam-cli/viam-cli-stable-linux-amd64
sudo chmod a+rx /usr/local/bin/viam
You can also install the Viam CLI using brew on Linux amd64
(Intel x86_64
):
brew tap viamrobotics/brews
brew install viam
If you have Go installed, you can build the Viam CLI directly from source using the go install
command:
go install go.viam.com/rdk/cli/viam@latest
To confirm viam
is installed and ready to use, issue the viam command from your terminal.
If you see help instructions, everything is correctly installed.
If you do not see help instructions, add your local PATH
variable.
If you use bash
as your shell, you can use the following command:
echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.bashrc
For more information see install the Viam CLI.
Authenticate your CLI session with Viam using one of the following options:
viam login
This will open a new browser window with a prompt to start the authentication process. If a browser window does not open, the CLI will present a URL for you to manually open in your browser. Follow the instructions to complete the authentication process.
Use your organization, location, or machine part API key and corresponding API key ID in the following command:
viam login api-key --key-id <api-key-id> --key <organization-api-key-secret>
2. Generate a metadata file
Next, run the viam module create
command to choose a custom module name and generate the required metadata for your module.
By default, a new module is created as private, meaning that it is only accessible to members of your organization, but you can choose to set the visibility
of your module to public to make it accessible to all Viam users.
Select the private or public tab for instructions to upload your module with the respective visibility
setting:
Get the org-id
for your organization from your organization’s Settings page in the Viam app and run the following command from the same directory as your custom module to generate metadata for your module:
viam module create --name <your-module-name> --org-id <your-org-id>
If you later wish to make your module public, you can use the viam module update
command.
If you haven’t already, create a new namespace for your organization. If you have already created a namespace, you can find it on your organization’s Settings page in the Viam app, or by running the
viam organizations list
command.To generate metadata for your module using your public namespace, run the following command from the same directory as your custom module:
viam module create --name <your-module-name> --public-namespace <your-unique-namespace>
This command creates a new meta.json
metadata file in your current working directory, which serves as a template.
3. Edit the metadata file
Edit the newly-created meta.json
file, and provide the required configuration information for your custom module by filling in the following fields.
Name | Type | Inclusion | Description |
---|---|---|---|
module_id | string | Required | The module ID, which includes either the module namespace or organization ID, followed by its name (pre-populated using the --name you provided in the viam module create command).CautionThe |
visibility | string | Required | Whether the module is accessible only to members of your organization (private ), or visible to all Viam users (public ). You can later make a private module public using the viam module update command. Once you make a module public, you can change it back to private if it is not configured on any machines outside of your organization.Default: private |
url | string | Optional | The URL of the GitHub repository containing the source code of the module. |
description | string | Required | A description of your module and what it provides. |
models | object | Required | A list of one or more models provided by your custom module. You must provide at least one model, which consists of an For more information, see naming your model. |
entrypoint | string | Required | The name of the file that starts your module program. This can be a compiled executable, a script, or an invocation of another program. If you are providing your module as a single file to the upload command, provide the path to that single file. If you are providing a directory containing your module to the upload command, provide the path to the entry point file contained within that directory. |
build | object | Optional | An object containing the command to run to build your module, as well as optional fields for the path to your dependency setup script, the target architectures to build for, and the path to your built module. Use this with the Viam CLI's build subcommand. |
For example, the following represents the configuration of an example my-module
public module in the acme
namespace:
Important
In the example above, the model namespace is set to acme
to match the owning organization’s namespace.
If the two namespaces do not match, the command will return an error.
For more information, see Name your new resource model.
See meta.json
file for more information.
4. (For Python) Package module as an archive
For modules written in Python, you should package your module files as an archive first, before uploading.
Other languages can proceed to the next step to upload their module directly.
To package a module written in Python, run the following command from the same directory as your meta.json
file:
tar -czvf dist/archive.tar.gz <PATH-TO-EXECUTABLE>
where <PATH-TO-EXECUTABLE>
is the packaged executable that runs the module at the entry point.
If using PyInstaller, by default this would be dist/main
.
For a Python module built using the venv
approach, the command might look like this:
tar -czf module.tar.gz run.sh requirements.txt src
Where run.sh
is your entrypoint file, requirements.txt
is your pip dependency list file, and src
is the directory that contains the source code of your module.
Supply the path to the resulting archive file in the next step.
5. Upload your module
Run viam module upload
to upload your custom module to the Viam Registry.
Specify the path to the file, directory, or compressed archive (with .tar.gz
or .tgz
extension) that contains your custom module code:
viam module upload --version <version> --platform <platform> <module-path> --tags=<tags>
where:
version
: provide a version for your custom module, using semantic versioning (example:1.0.0
). You can later increment this value with subsequentviam module upload
commands. See Using the--version
argument for more information.platform
: provide the system architecture your custom module supports. You can only provide oneplatform
argument at a time to theviam module upload
command. See Using the--platform
argument for the full list of supported architectures.module-path
: provide the path to the file, directory, or compressed archive (with.tar.gz
or.tgz
extension) that contains your custom module code.tags
: provide a comma-separated list of platform tags that determine to which platforms this binary can be deployed. Seeviam module upload
.
Important
The viam module upload
command only supports one platform
argument at a time.
If you would like to upload your module with support for multiple platforms, you must run a separate viam module upload
command for each platform.
Use the same version number when running multiple upload
commands of the same module code if only the platform
support differs.
The Viam Registry page for your module displays the platforms your module supports for each version you have uploaded.
For example:
To upload a module that is defined in a single file named
my-module-file
in a localbin
directory:viam module upload --version 1.0.0 --platform linux/amd64 ./bin/my-module-file
To upload a module that includes multiple files, as well as a separate entry point file, all contained with a local
bin
directory:viam module upload --version 1.0.0 --platform linux/amd64 ./bin
To upload a module that has been compressed as an archive named
packaged-module.tar.gz
:viam module upload --version 1.0.0 --platform linux/amd64 packaged-module.tar.gz
When you upload
a module, the command performs basic validation of your module to check for common errors.
For more information, see the viam module
command.
Next steps
Now that your module is available in the registry, you can configure the components or services it supports just as you would configure other resources: Go to the CONFIGURE tab of a machine, add a component or service (as applicable), and search for the name of your model.
To update, delete, or change the privacy settings of a module you deployed, see Manage Modules.
Have questions, or want to meet other people working on robots? Join our Community Discord.
If you notice any issues with the documentation, feel free to file an issue or edit this file.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!