Skip to content

Commit

Permalink
Add back module triplet and org namespace info and fix links (#3821)
Browse files Browse the repository at this point in the history
  • Loading branch information
JessamyT authored Jan 9, 2025
1 parent d258377 commit 3cebf7e
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 7 deletions.
7 changes: 4 additions & 3 deletions docs/dev/tools/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,8 @@ viam module upload --version=1.0.0 --platform=darwin/arm64 packaged-module.tar.g

All of the `module` commands accept either the `--org-id` or `--public-namespace` argument.

- Use the `--public-namespace` argument to supply the namespace of your organization. This will upload your module to the Viam Registry and share it with other users.
- Use the `--public-namespace` argument to supply the [namespace of your organization](/operate/reference/naming-modules/#create-a-namespace-for-your-organization).
This will upload your module to the Viam Registry and share it with other users.
- Use the `--org-id` to provide your organization ID instead, This will upload your module privately within your organization.

You may use either argument for the `viam module create` command, but must use `--public-namespace` for the `update` and `upload` commands when uploading as a public module (`"visibility": "public"`) to the Viam Registry.
Expand Down Expand Up @@ -858,7 +859,7 @@ For example, the following represents the configuration of an example `my-module
```

{{% alert title="Important" color="note" %}}
If you are publishing a public module (`"visibility": "public"`), the namespace of your model match the namespace of your [organization](/dev/reference/glossary/#organization).
If you are publishing a public module (`"visibility": "public"`), the namespace of your model match the [namespace of your organization](/operate/reference/naming-modules/#create-a-namespace-for-your-organization).
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.
{{% /alert %}}
Expand Down Expand Up @@ -1072,7 +1073,7 @@ See [create an organization API key](#create-an-organization-api-key) for more i
<!-- prettier-ignore -->
| Command option | Description | Positional arguments |
| -------------- | ----------- | -------------------- |
| `list` | List all organizations (name, id, and [namespace](/cloud/organizations/#create-a-namespace-for-your-organization)) that the authenticated session has access to. | - |
| `list` | List all organizations (name, id, and [namespace](/operate/reference/naming-modules/#create-a-namespace-for-your-organization)) that the authenticated session has access to. | - |
| `api-key create` | Create a new organization API key. | - |
| `support-email get` | Get the support email for an organization. | - |
| `support-email set` | Set the support email for an organization. | - |
Expand Down
6 changes: 3 additions & 3 deletions docs/operate/get-started/other-hardware/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Authenticate your CLI session with Viam using one of the following options:
| Module name | The module name describes the module or the family of devices it supports. It is generally the same as the name of the GitHub repo where you will put your module code. |
| Language | The language for the module. |
| Visibility | Choose `Private` to share only with your organization, or `Public` to share publicly with all organizations. If you are testing, choose `Private`. |
| Namespace/Organization ID | In the [Viam app](https://app.viam.com), navigate to your organization settings through the menu in upper right corner of the page. Find the **Public namespace** and copy that string. |
| Namespace/Organization ID | In the [Viam app](https://app.viam.com), navigate to your organization settings through the menu in upper right corner of the page. Find the **Public namespace** (or create one if you haven't already) and copy that string. |
| Resource to add to the module (API) | The [component API](/dev/reference/apis/#component-apis) your module will implement. |
| Model name | Name your component model based on what it supports, for example, if it supports a model of ultrasonic sensor called “XYZ Sensor 1234” you could call your model `xyz_1234` or similar. Must be all-lowercase and use only alphanumeric characters (`a-z` and `0-9`), hyphens (`-`), and underscores (`_`). |
| Enable cloud build | If you select `Yes` (recommended) and push the generated files (including the <file>.github</file> folder) and create a release of the format `vX.X.X`, the module will build and upload to the Viam registry and be available for all Viam-supported architectures without you needing to build for each architecture. `Yes` also makes it easier to [upload](#upload-your-module) using PyInstaller by creating a build entrypoint script. You can select `No` if you will always build the module yourself before uploading it. |
Expand Down Expand Up @@ -755,7 +755,7 @@ Click below for information about the available fields.
<td><code>module_id</code></td>
<td>string</td>
<td><strong>Required</strong></td>
<td>The module ID, which includes either the module <a href="/cloud/organizations/#create-a-namespace-for-your-organization">namespace</a> or <a href="/cloud/organizations/">organization ID</a>, followed by its name.
<td>The module ID, which includes either the module <a href="/operate/reference/naming-modules/#create-a-namespace-for-your-organization">namespace</a> or organization ID, followed by its name.
<div class="alert alert-caution" role="alert">
<h4 class="alert-heading">Caution</h4>

Expand Down Expand Up @@ -788,7 +788,7 @@ Do not change the <code>module_id</code>.</p>
<td><code>models</code></td>
<td>object</td>
<td><strong>Required</strong></td>
<td><p>A list of one or more {{< glossary_tooltip term_id="model" text="models" >}} provided by your custom module. You must provide at least one model, which consists of an <code>api</code> and <code>model</code> key pair. If you are publishing a public module (<code>"visibility": "public"</code>), the namespace of your model must match the <a href="/cloud/organizations/#create-a-namespace-for-your-organization">namespace of your organization</a>.</p></td>
<td><p>A list of one or more {{< glossary_tooltip term_id="model" text="models" >}} provided by your custom module. You must provide at least one model, which consists of an <code>api</code> and <code>model</code> key pair. If you are publishing a public module (<code>"visibility": "public"</code>), the namespace of your model must match the <a href="/operate/reference/naming-modules/#create-a-namespace-for-your-organization">namespace of your organization</a>.</p></td>
</tr>
<tr>
<td><code>entrypoint</code></td>
Expand Down
2 changes: 1 addition & 1 deletion docs/operate/get-started/other-hardware/cpp-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ The models implement the `rdk:component:arm` and the `rdk:component:gripper` API

A resource model is identified by a unique name, called the {{< glossary_tooltip term_id="model-namespace-triplet" text="model namespace triplet" >}}, using the format: `namespace:module-name:model-name`, where:

- `namespace` is the [namespace of your organization](/dev/reference/glossary/#organization#create-a-namespace-for-your-organization).
- `namespace` is the [namespace of your organization](/operate/reference/naming-modules/#create-a-namespace-for-your-organization).
- For example, if your organization uses the `acme` namespace, your models must all begin with `acme`, like `acme:module-name:mybase`.
If you do not intend to [upload your module](#upload-your-module-to-the-modular-resource-registry) to the [Viam Registry](https://app.viam.com/registry), you do not need to use your organization's namespace as your model's namespace.
- The `viam` namespace is reserved for models provided by Viam.
Expand Down
104 changes: 104 additions & 0 deletions docs/operate/reference/naming-modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: "Valid Module Identifiers"
linkTitle: "Module Naming"
type: "docs"
weight: 25
images: ["/registry/module-puzzle-piece.svg"]
tags: ["modular resources", "components", "services", "registry"]
description: "Add support for a new component or service model by writing a module in C++."
languages: ["c++"]
viamresources: []
platformarea: ["registry"]
toc_hide: true
---

Each modular resource has two associated triplets: an API namespace triplet to indicate which [API](/dev/reference/apis/) it implements, and a model namespace triplet to uniquely identify the modular resource {{< glossary_tooltip term_id="model" text="model" >}}.

## Valid API identifiers

Each existing component or service API has a unique identifier in the form of a colon-delimited triplet.
You will use this {{< glossary_tooltip term_id="api-namespace-triplet" text="API namespace triplet" >}} when creating your new model, to indicate which API it uses.

The API namespace triplet is the same for all built-in and modular models that implement a given API.
For example, every model of motor built into Viam, as well as every custom model of motor provided by a module, all use the same API namespace triplet `rdk:component:motor` to indicate that they implement the [motor API](/operate/reference/components/motor/#api).

The three pieces of the API namespace triplet are as follows:

{{< tabs >}}
{{% tab name="Component" %}}

- `namespace`: `rdk`
- `type`: `component`
- `subtype`: any one of [these component proto files](https://github.com/viamrobotics/api/tree/main/proto/viam/component), for example `motor` if you are creating a new model of motor

{{% /tab %}}
{{% tab name="Service" %}}

- `namespace`: `rdk`
- `type`: `service`
- `subtype`: any one of [these service proto files](https://github.com/viamrobotics/api/tree/main/proto/viam/service), for example `vision` if you are creating a new model of vision service

{{% /tab %}}
{{< /tabs >}}

## Valid model identifiers

In addition to determining which existing API namespace triplet to use when creating your module, you need to decide on a separate triplet unique to your model.

{{< expand "API namespace triplet and model namespace triplet examples" >}}

- The `rand:yahboom:arm` model and the `rand:yahboom:gripper` model use the module name (and matching repo name) [yahboom](https://github.com/viam-labs/yahboom).
The models implement the `rdk:component:arm` and the `rdk:component:gripper` API to support the Yahboom DOFBOT arm and gripper, respectively:

```json
{
"api": "rdk:component:arm",
"model": "rand:yahboom:arm"
},
{
"api": "rdk:component:gripper",
"model": "rand:yahboom:gripper"
}
```

- The `viam-labs:audioout:pygame` model uses the repository name [audioout](https://github.com/viam-labs/audioout).
It implements the custom API `viam-labs:service:audioout`:

```json
{
"api": "viam-labs:service:audioout",
"model": "viam-labs:audioout:pygame"
}
```

{{< /expand >}}

The `viam` namespace is reserved for models provided by Viam.

A resource model is identified by a unique name, called the {{< glossary_tooltip term_id="model-namespace-triplet" text="model namespace triplet" >}}, using the format: `namespace:module-name:model-name`, where:

- `namespace` is the namespace of your organization, which you can find or [create](#create-a-namespace-for-your-organization) in your organization settings page in the [Viam app](https://app.viam.com).
- For example, if your organization uses the `acme` namespace, your models must all begin with `acme`, like `acme:module-name:mybase`.
If you do not intend to [upload your module](/operate/get-started/other-hardware/#upload-your-module) to the [Viam Registry](https://app.viam.com/registry), you do not need to use your organization's namespace as your model's namespace.
- The `viam` namespace is reserved for models provided by Viam.
- `module-name` is the name of your module.
Your `module-name` should describe the common functionality provided across the model or models provided by that module.
- Many people also choose to use the module name as the name of the code repository (GitHub repo) that houses the module code.
- `model-name` is the name of the new resource model that your module will provide.

For example, if your organization namespace is `acme`, and you have written a new base implementation named `mybase` which you have supported with a module named `my-custom-base-module`, you would use the namespace `acme:my-custom-base-module:mybase` for your model.

More requirements:

- Your model triplet must be all-lowercase.
- Your model triplet may only use alphanumeric (`a-z` and `0-9`), hyphen (`-`), and underscore (`_`) characters.

Determine the model name you want to use based on these requirements, then proceed to the next section.

## Create a namespace for your organization

When uploading modules to the Viam Registry, you must set a unique namespace for your organization to associate your module with.

To create a new namespace for your organization, click on the org's **Settings** in the top right of the navigation bar, then click the **Set a public namespace** button.
Enter a name or use the suggested name for your namespace, and then click **Set namespace**.
A namespace may only contain letters, numbers, and the dash (`-`) character.

0 comments on commit 3cebf7e

Please sign in to comment.