manage.py load_from_github

This module is used to deploy a collection of customer API’s from a GitHub repository containing plugin YAML files organized in directories by customer API name.

class smarter.apps.chatbot.management.commands.load_from_github.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: SmarterCommand

Deploy customer APIs and plugins from a GitHub repository containing YAML manifest files.

This management command automates the deployment of chatbots and plugins for Smarter accounts by processing a public GitHub repository. The repository should contain YAML manifest files organized either by directories representing customer APIs (subdomains) or by separate ‘plugins’ and ‘chatbots’ folders, depending on the selected repo version.

The command supports two repository layouts:

  • Version 1: Each folder in the repository represents a customer API (subdomain), and contains YAML plugin manifests. The command creates a chatbot for each folder and attaches plugins found within.

  • Version 2: The repository contains ‘plugins’ and ‘chatbots’ directories. All plugin manifests are processed first (to satisfy dependencies), followed by chatbot manifests.

The deployment process includes:

  • Cloning the specified GitHub repository to a local directory.

  • Iterating through manifest files and applying them to the Smarter platform.

  • Creating chatbots and associating plugins as defined by the manifests.

  • Deploying chatbots asynchronously using Celery tasks.

  • Outputting progress, error, and completion messages to the console.

Administrators can specify the target account by account number and optionally a username. The command ensures that all required account, user, and profile objects are available before processing manifests. It validates URLs, manages local repository cleanup, and handles errors encountered during manifest application or plugin loading.

This command is useful for bulk provisioning, migration, or onboarding scenarios where multiple chatbots and plugins need to be deployed from a structured repository. It streamlines the process of setting up complex environments and ensures consistent deployment across accounts.

__init__(stdout=None, stderr=None, no_color=False, force_color=False)[source]
account: Account
add_arguments(parser)[source]

Add arguments to the command.

clone_repo()[source]

Synchronously clone a GitHub repository to the local file system.

delete_repo()[source]

Delete a cloned GitHub repository from the local file system.

get_url_filename(url)[source]

Get the filename from a URL. example: https://github.com/smarter-sh/smarter_demo/blob/main/hr/shrm_fmla.yaml returns “shrm_fmla.yaml”

Return type:

str

handle(*args, **options)[source]

Handle the command execution.

load_plugin(filespec)[source]

Load a plugin from a file on the local file system.

property local_path
process_repo_v1()[source]

Process a GitHub repository containing yaml plugin files organized into folders, where each folder name is the subdomain for a customer API.

process_repo_v2()[source]

Process a GitHub repository containing yaml manifest files. Folders are optional and can be used to organize the manifest files, but otherwise do not contain any special meaning.

property url: str
user: User
user_profile: UserProfile