initialize_platform

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

Bases: SmarterCommand

Django manage.py initialize_platform command.

add_arguments(parser)[source]

Add arguments to the command.

call_command_or_log(failure, name, **options)[source]

Run one step of the initialization that may fail without stopping the others: log its failure.

Parameters:
  • failure (str) – What failed, for the log, e.g. initialize providers.

  • name (str) – The command’s name.

  • options – The command’s options.

Return type:

None

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

Initialize the Smarter platform.

Creates the minimal resources necessary to start using Smarter. This is the one place where the platform’s example resources are created and deployed: the Helm init job and make docker-init run it, and nothing else.

  1. Create the admin user and the example users. The username and password come from --username and --password, or from smarter_settings.platform_admin_username and admin_password, so that the init job passes no password on its command line.

  2. Initialize the Waffle switches, the Smarter project’s index, the built-in Providers, the official extensions and the vector store providers.

  3. Load the example manifests from GitHub, https://github.com/smarter-sh/example-manifests, and deploy their LLMClients. Then delete the example resources whose manifests were removed from it since an earlier initialization, with delete_retired_examples.

  4. Load the Stackademy project from GitHub, deploy its LLMClients, and verify them.

  5. Verify the DNS configuration, and sync the ledger of infrastructure resources with the Kubernetes cluster.

Deploying an LLMClient creates its DNS record and Kubernetes ingress, so the LLMClients are deployed everywhere except in the local environment, where they are only applied.

rename_stackademy_resources(username)[source]

Move every account’s Stackademy plugins to Stackademy’s renamed Secrets and Connections.

After load_from_github, which applies the renamed resources: manage.py rename_stackademy_resources moves the plugins from the old resources to them, and deletes the old ones that nothing uses. A failure is logged, not raised: the old resources keep working until the next deployment tries again.

Parameters:

username (str) – The Smarter admin, who owns the renamed resources.

Return type:

None

upload_static_files()[source]

Upload the static files to the CDN’s bucket with collectstatic, and log what it did.

collectstatic runs silently: at verbosity 1 it prints a line for every unchanged file. It can take minutes, so the log says when it starts, and then how many files it checked, how many of them it uploaded, and how long that took.

Raises:

Exception – Whatever collectstatic raises; the caller decides what a failure means.

Return type:

None