Skip to content

Configuring the Development Environment

Mark Harrison edited this page Apr 10, 2025 · 21 revisions

Install Python3

Install Python3 3.12 from the Python downloads page.

Important

Python 3.13 has an issue with some of the dependencies (see here). You must use Python 3.12.

Linux users should install Python using their distribution's package manager.

Windows users need to enable some optional settings:

image

image

You need to turn off App Installer from App execution aliases:

image

Windows users will also need to install the Visual Studio build tools from here, selecting Desktop development with C++:

image

Clone the repo

git clone https://github.com/OctopusSolutionsEngineering/OctopusCopilot.git
cd OctopusCopilot

Create a virtual environment

Virtual environments provide an isolated space for project dependencies.

python3 -m venv .venv

Enter the virtual environment

Linux and macOS

source .venv/bin/activate

Windows

.venv/Scripts/Activate.ps1

Install the dependencies

pip3 install -r requirements.txt

Download Octoterra

Octoterra is a service used to convert Octopus resources to HCL. The HCL is then passed to an LLM as context to describe the configuration of the Octopus instance.

  • Download the latest release from GitHub for your operating system, choosing the artifact that includes _azure in the name. For example, if your operating system is Windows, download the octoterra_windows_amd64_azure.exe version.
  • Extract the zip file

Run Octoterra

Octoterra must be run listening on port 8081. The port is determined by the environment variable FUNCTIONS_CUSTOMHANDLER_PORT.

Linux

FUNCTIONS_CUSTOMHANDLER_PORT=8081 ./octoterra_linux_amd64_azure

macOS

FUNCTIONS_CUSTOMHANDLER_PORT=8081 ./octoterra_macos_arm64_azure

Windows

$env:FUNCTIONS_CUSTOMHANDLER_PORT=8081
./octoterra_windows_amd64_azure.exe

Download Octolint

Octolint may also be required, depending on the prompts you create or test. Octolint is a service used to run checks against an Octopus instance. The service runs in a separate Azure function that Octopus Copilot calls when needed.

  • Download the latest release from GitHub for your operating system, choosing the artifact that includes _azure in the name. For example, if your operating system is Windows, download the octolint_windows_amd64_azure.exe version.
  • Extract the zip file

Run Octolint

Octoterra must be run listening on port 8082, which is determined by the environment variable FUNCTIONS_CUSTOMHANDLER_PORT.

Linux

FUNCTIONS_CUSTOMHANDLER_PORT=8082 ./octolint_linux_amd64_azure

macOS

FUNCTIONS_CUSTOMHANDLER_PORT=8082 ./octolint_macos_arm64_azure

Windows

$env:FUNCTIONS_CUSTOMHANDLER_PORT=8082
./octolint_windows_amd64_azure.exe

Configure environment variables

There are a number of environment variables capturing secrets required to run the Copilot backend.

Octonaughts can ping @matthew.casperson in #project-github-copilot to access the shared password containing the values for these variables.

The shared password is called Octopus Copilot OpenAI.

Linux and macOS

Linux users can place the following code snippet into /etc/environment or ~/.profile. macOS users can place the code in ~/.zshenv':

export OCTOPUS_CLI_API_KEY=API-xxxx
export OCTOPUS_CLI_SERVER=https://yourinstance.octopus.app
export OPENAI_ENDPOINT=https://xxx.openai.azure.com/
export OPENAI_API_KEY=xxx
export OPENAI_API_DEPLOYMENT=gpt4o
export APPLICATION_OCTOTERRA_URL=http://localhost:8081
export APPLICATION_OCTOLINT_URL=http://localhost:8082

Windows

Windows users should define the environment variables in System Properties.

Do a query

The CLI interface is for local testing. We don't distribute the CLI for any production usage.

Linux and macOS

python3 main.py --query "Show the projects from the Default space"

Windows

python main.py --query "Show the projects from the Default space"

IDE Config

Enable the Black tool in Pycharm and configure it to run on save and reformat:

image

Run azure-storage azurite for tests

If you are running end-to-end tests, in addition to Octoterra above, you also need to run the Azure storage container in docker:

docker run -d -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite