# Deploying a Channel

Channels can be deployed to the Rendered.ai latform using the _anadeploy_ command. Once deployed, the channel is accessible through the Rendered.ai platform website to create graphs and datasets.

The _anadeploy_ command must be called from within the VSCode Development Container, it requires a valid channel file, access to Docker, and Rendered.ai credentials.

This command simplifies the process of building and deploying a channel by:

1. Specifying which remote channel to deploy the channel or creating a new remote channel
2. Creating the docker context
3. Building the docker image
4. Uploading the docker image to the platform
5. Displaying the status of the channel deployment

Once this process is complete, the channel will be available on the platform to add to workspaces, create graphs and run jobs that create datasets. To run the command, type:

```bash
anadeploy --channel example.yml
```

The anadeploy command has the following parameters:

\--channel (optional)\
If not provided, will attempt to find a valid channel file in the current directory or /workspaces directory.

\--channelId (optional)\
If specified, will deploy the local channel to the remote channel with the given channelId.

\--environment (optional)\
Specifies the environment to deploy the channel to. Defaults to prod.

\--email (optional)\
If not provided, will prompt user for Rendered.ai account email.

\--password (optional)\
If not provided, will prompt user for Rendered.ai account password.

\--verbose (optional)\
If set, will provide more detailed messages during the deployment process.

&#x20;

The following sections will take you through deploying a new channel, deploying over an existing channel and other helpful utilities to have during channel deployment.

* [Deploying to a New Channel](#deploying-to-a-new-channel)
* [Deploying to an Existing Channel](#deploying-to-an-existing-channel)
* [Deployment Utilities](#deployment-utilities)
  * [Generating the Channel Schema](#generating-the-channel-schema)
  * [Generating Starter Documentation](#generating-starter-documentation)

## Deploying to a New Channel <a href="#deploying-to-a-new-channel" id="deploying-to-a-new-channel"></a>

Deploying a new channel will create the backend infrastructure necessary to create new graphs for the channel and to run jobs using the web interface.\
\
**Step 1: Enter Rendered.ai Credentials**\
The first thing you’ll need to enter when running _anadeploy_ is your Rendered.ai credentials. If you do not have Rendered.ai credentials you can get access to an account by filling out the getting started form at [https://rendered.ai/getstarted.html](https://rendered.ai/getstarted.html) .

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
```

**Step 2: Select Create new managed channel**\
To deploy the local channel to a new remote Channel, you need to select the “Create new managed channel“ option when prompted. Your organization may not own any managed channels so your only choice may be to create a new managed channel, as in the case below.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
Enter your choice: 0
```

**Step 3: Select the organization to create the managed channel in**\
The next step is to select the organization that will own the managed channel. Remember that anybody who is a member of that organization has access to the channel and can redeploy over it.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
Enter your choice: 0
Select an organization to create a new managed channel in:
        [0]   default
Enter your choice: 0
```

**Step 4: Confirm your selection**\
The next step is to confirm your selection, this is a chance to back-out of channel deployment if a mistake was made, it gives the user another chance to review that the correct channel file and organization have been selected.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
Enter your choice: 0
Select an organization to create a new managed channel in:
        [0]   default
Enter your choice: 0
Creating a new channel using the ./example.yml channel file in default organization. Continue (y/n)? y
```

**Step 5: Set the channel name**\
Set the name of the remote channel. If the local channel name isn’t taken by a channel in the organization, it will prompt the user to leave blank if they want to use the local channel name.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
Enter your choice: 0
Select an organization to create a new managed channel in:
        [0]   default
Enter your choice: 0
Creating a new channel using the ./example.yml channel file in default organization. Continue (y/n)? y
Please provide a name for the channel or leave blank for 'example': 
```

**Step 6: Build and upload Docker image**\
After confirming your selection, the Docker image will be built and uploaded to the platform automatically. This can take some time if this is the first time you have deployed a channel.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
Enter your choice: 0
Select an organization to create a new managed channel in:
        [0]   default
Enter your choice: 0
Creating a new channel using the ./example.yml channel file in default organization. Continue (y/n)? y
Please provide a name for the channel or leave blank for 'example': 
Docker image "example" will be deployed to the "example" channel.
[66%] Pushing "example" to "example" 
```

**Step 7: Channel Deployment**\
Once the Docker image has been uploaded, the platform will run a process known as Channel Deployment which will do a series of checks of the Docker image to ensure it can be used on the platform. This includes transferring volume data, running interface checks, registering node and channel data, uploading channel documentation and annotation mapping files.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
Enter your choice: 0
Select an organization to create a new managed channel in:
        [0]   default
Enter your choice: 0
Creating a new channel using the ./example.yml channel file in default organization. Continue (y/n)? y
Please provide a name for the channel or leave blank for 'example': 
Step: 6/6
State: Channel Deployment Complete
Message: The channel has been fully deployed and is ready for use.
```

## Deploying to an Existing Channel <a href="#deploying-to-an-existing-channel" id="deploying-to-an-existing-channel"></a>

Sometimes it’s important to push changes to a channel that has already been deployed to add new features or fix bugs. You can deploy over an existing channel using _anadeploy_ by selecting which channel the local image is deployed to.\
\
**Step 1: Enter Rendered.ai Credentials**\
The first thing you’ll need to enter when running _anadeploy_ is your Rendered.ai credentials. If you do not have Rendered.ai credentials you can get access to an account by filling out the waitlist form at [https://rendered.ai/waitlist.html](https://rendered.ai/waitlist.html).

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
```

\
**Step 2: Choose which Channel to deploy to**\
To deploy the local channel to a remote Channel, you need to make selection when prompted.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
        [1]   Deploy to example channel in the default organization.
Enter your choice: 
```

It’s important to note which organization owns the channel you are deploying to. Ensure you are not deploying over another channel unintentionally.\
\
**Step 3: Confirm your selection**\
The next step is to confirm your selection, this is a chance to back-out of channel deployment if a mistake was made, it gives the user another chance to review that the correct channel file and remote channel have been selected.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
        [1]   Deploy to example channel in the default organization.
Enter your choice: 1
Deploying ./example.yml channel to example channel in default organization. Continue (y/n)? y
```

**Step 4: Build and upload Docker image**\
After confirming your selection, the Docker image will be built and uploaded to the platform automatically. This can take some time if this is the first time you have deployed a channel.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
        [1]   Deploy to example channel in the default organization.
Enter your choice: 1
Deploying ./example.yml channel to example channel in default organization. Continue (y/n)? 
Docker image "example" will be deployed to the "example" channel.
[66%] Pushing "example" to "example" 
```

**Step 5: Platform channel deployment checks**\
Once the Docker image has been uploaded, the Platform will run a process known as Channel Deployment which will do a series of checks of the Docker image to ensure it can be used on the Platform. This includes transferring volume data, running interface checks, registering nodes and channel data, uploading channel documentation and annotation mapping files.

```bash
(anatools) anadev@test:/workspaces/example$ anadeploy
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
Enter your credentials for the Rendered.ai Platform.
Email: test@rendered.ai
Password: ********
Please select one of the following options:
        [0]   Create a new managed channel.
        [1]   Deploy to example channel in the default organization.
Enter your choice: 1
Deploying ./example.yml channel to example channel in default organization. Continue (y/n)? 
Step: 6/6
State: Channel Deployment Complete
Message: The channel has been fully deployed and is ready for use.
```

## Deployment Utilities <a href="#deployment-utilities" id="deployment-utilities"></a>

An _anautils_ command is supported in the devcontainers to help the user with additional information that can be used when deploying a channel. An example call for this command is shown below:

```bash
anautils --channel example.yml --mode schema
```

The anautils command has the following parameters:

\--channel (optional)\
If not provided, will attempt to find a valid channel file in the current directory or /workspaces directory.

\--mode (optional)\
If not provided, will run in the “schema“ mode. The modes are:

* schema: generates a schema file and displays node categories, subcategories and colors.
* docs: generates starter documentation for the channel which includes a markdown formatted table of nodes in the channel.

\--output (optional)\
Determines where output files are generated.

### Generating the Channel Schema <a href="#generating-the-channel-schema" id="generating-the-channel-schema"></a>

The _anautils_ schema mode will create two outputs, one that is visible in the terminal that shows the category, subcategory and color of the nodes and a JSON file that defines the schema for each of the nodes for the frontend. The terminal output for the Example channel is shown below:

```bash
(anatools) anadev@test:/workspaces/example$ anautils --mode schema
Using channelfile found at ./example.yml.
If this is the wrong channel, specify a channelfile using the --channel argument.
The Node Menu for this Channel will be as follows on the Rendered.ai Platform:

Objects
  Generators
    - Bubbles
    - Yo-yo
    - Skateboard
    - Playdough
    - Rubik's Cube
    - Mix Cube
    - Container
    - Floor
Modifiers
  Color
    - Color Variation
  Physics
    - Drop Objects
  Placement
    - Random Placement
  Branch
    - Weight
Render
  Image
    - Render
Values
  Generators
    - Random Integer
```

This command is run during Channel Deployment to generate node schemas for the backend databases. It can also be helpful to the user to ensure their nodes are structured as they expect before deployment.

### Generating Starter Documentation <a href="#generating-starter-documentation" id="generating-starter-documentation"></a>

The Rendered.ai platform supports a single Markdown file for channel documentation. This is an opportunity to give channel users an explanation of what use cases the channel is solving, available nodes in the channel and other information such as graph requirements or execution runtimes.

The channel documentation can either be included in the Docker image during channel deployment. To include it in the Docker image, the .md file must be located in a docs/ directory in the channel workspace. In the example channel this would be located at /workspaces/example/docs/.

To generate the channel documentation, run the following _anautils_ command:

```bash
anautils --channel example.yml --mode docs
```
