Skip to content

Commit

Permalink
fix(build): supabase bundle deployment order (#635)
Browse files Browse the repository at this point in the history
* fix: re-ordered the packages within the example UDS bundles

---------

Co-authored-by: Jonathan Perry <[email protected]>
  • Loading branch information
justinthelaw and YrrepNoj authored Jun 17, 2024
1 parent 24bad5a commit c1a8294
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Create UDS Cluster
run: |
uds deploy k3d-core-slim-dev:0.22.1 --confirm
uds deploy k3d-core-slim-dev:0.22.2 --confirm
##########
# Supabase
Expand Down
65 changes: 52 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/leapfrogai/badge)](https://api.securityscorecards.dev/projects/github.com/defenseunicorns/leapfrogai)

## Table of Contents

- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [Why Host Your Own LLM?](#why-host-your-own-llm)
Expand Down Expand Up @@ -128,14 +129,14 @@ Make sure your system has the [required dependencies](https://docs.leapfrog.ai/d

For ease, it's best to create a virtual environment:

``` shell
```shell
python -m venv .venv
source .venv/bin/activate
```

Each component is built into its own Zarf package. You can build all of the packages you need at once with the following `Make` targets:

``` shell
```shell
make build-cpu # api, llama-cpp-python, text-embeddings, whisper
make build-gpu # api, vllm, text-embeddings, whisper
make build-all # all of the backends
Expand All @@ -145,7 +146,7 @@ make build-all # all of the backends

You can build components individually using the following `Make` targets:

``` shell
```shell
make build-api
make build-vllm # if you have GPUs
make build-llama-cpp-python # if you have CPU only
Expand All @@ -157,29 +158,64 @@ Once the packages are created, you can deploy either a CPU or GPU-enabled deploy

#### CPU

``` shell
```shell
cd uds-bundles/dev/cpu
uds create .
uds deploy k3d-core-slim-dev:0.18.0
uds deploy k3d-core-slim-dev:0.22.2
uds deploy uds-bundle-leapfrogai*.tar.zst
```

#### GPU

``` shell
```shell
cd uds-bundles/dev/gpu
uds create .
uds deploy k3d-core-slim-dev:0.18.0 --set K3D_EXTRA_ARGS="--gpus=all --image=ghcr.io/justinthelaw/k3d-gpu-support:v1.27.4-k3s1-cuda" # be sure to check if a newer version exists
uds deploy k3d-core-slim-dev:0.22.2 --set K3D_EXTRA_ARGS="--gpus=all --image=ghcr.io/justinthelaw/k3d-gpu-support:v1.27.4-k3s1-cuda" # be sure to check if a newer version exists
uds deploy uds-bundle-leapfrogai-*.tar.zst --confirm
```

### Accessing the UI

LeapfrogAI is integrated with the UDS Core KeyCloak service, which provides authentication via SSO. Below are general instructions for accessing the LeapfrogAI UI after a successful UDS deployment of UDS Core and LeapfrogAI.

1. Connect to the KeyCloak admin panel
a. Run the following to get a port-forwarded tunnel: `uds zarf connect keycloak`
b. Go to the resulting localhost URL and create an admin account
2. Go to ai.uds.dev and press "Login using SSO"
3. Register a new user by pressing "Register Here"
4. Fill-in all of the information
a. The bot detection requires you to scroll and click around in a natural way, so if the Register button is not activated despite correct information, try moving around the page until the bot detection says 100% verified
5. Using an authenticator, follow the MFA steps
6. Go to sso.uds.dev
a. Login using the admin account you created earlier
7. Approve the newly registered user
a. Click on the hamburger menu in the top left to open/close the sidebar
b. Go to the dropdown that likely says "Keycloak" and switch to the "uds" context
c. Click "Users" in the sidebar
d. Click on the newly registered user's username
e. Go to the "Email Verified" switch and toggle it to be "Yes"
f. Scroll to the bottom and press "Save"
8. Go back to ai.uds.dev and login as the registered user to access the UI

### Clean-up

To clean-up or perform a fresh install, run the following commands in the context in which you had previously installed UDS Core and LeapfrogAI:

```bash
k3d cluster delete uds # kills a running uds cluster
uds zarf tools clear-cache # clears the Zarf tool cache
rm -rf ~/.uds-cache # clears the UDS cache
docker system prune -a -f # removes all hanging containers and images
docker volume prune -f # removes all hanging container volumes
```

### Local Dev

The following instructions are for running each of the LFAI components for local development. This is useful when testing changes to a specific component, but will not assist in a full deployment of LeapfrogAI. Please refer to the above sections for deployment instructions.

It is highly recommended to make a virtual environment to keep the development environment clean:

``` shell
```shell
python -m venv .venv
source .venv/bin/activate
```
Expand All @@ -188,7 +224,7 @@ source .venv/bin/activate

To run the LeapfrogAI API locally (starting from the root directory of the repository):

```
```shell
python -m pip install src/leapfrogai_sdk
cd src/leapfrogai_api
python -m pip install .
Expand All @@ -203,7 +239,7 @@ The instructions for running the basic repeater model (used for testing the API)

To run the llama-cpp-python backend locally (starting from the root directory of the repository):

``` shell
```shell
python -m pip install src/leapfrogai_sdk
cd packages/llama-cpp-python
python -m pip install .[dev]
Expand All @@ -214,9 +250,10 @@ lfai-cli --app-dir=. main:Model
```

#### Backend: text-embeddings

To run the text-embeddings backend locally (starting from the root directory of the repository):

``` shell
```shell
python -m pip install src/leapfrogai_sdk
cd packages/text-embeddings
python -m pip install .[dev]
Expand All @@ -225,9 +262,10 @@ python -u main.py
```

#### Backend: vllm

To run the vllm backend locally (starting from the root directory of the repository):

``` shell
```shell
python -m pip install src/leapfrogai_sdk
cd packages/vllm
python -m pip install .[dev]
Expand All @@ -237,9 +275,10 @@ python -u src/main.py
```

#### Backend: whisper

To run the vllm backend locally (starting from the root directory of the repository):

``` shell
```shell
python -m pip install src/leapfrogai_sdk
cd packages/whisper
python -m pip install ".[dev]"
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

This directory holds our e2e tests that we use to verify LFAI-API + various model backend functionality in an environment that replicates a live setting. The tests in this directory are automatically run against a [UDS Core](https://github.com/defenseunicorns/uds-core) cluster whenever a PR is opened or updated.


## Running Tests Locally
The tests in this directory are also able to be run locally! We are currently opinionated towards running on a cluster that is configured with UDS, as we mature out tests & documentations we'll potentially lose some of that opinionation.

The tests in this directory are also able to be run locally! We are currently opinionated towards running on a cluster that is configured with UDS, as we mature out tests & documentations we'll potentially lose some of that opinionation.

### Dependencies

1. Python >= 3.11.6
2. k3d >= v5.6.0
3. uds >= v0.7.0


### Actually Running The Test

There are several ways you can setup and run these tests. Here is one such way:

```bash
# Setup the UDS cluster
# NOTE: This stands up a k3d cluster and installs istio & pepr
# NOTE: Be sure to use the latest released version at the time you're reading this!
uds deploy oci://ghcr.io/defenseunicorns/packages/uds/bundles/k3d-core-slim-dev:0.18.0 --confirm
uds deploy oci://ghcr.io/defenseunicorns/packages/uds/bundles/k3d-core-slim-dev:0.22.2 --confirm

# Build and Deploy the LFAI API
make build-api
Expand Down
34 changes: 17 additions & 17 deletions uds-bundles/dev/cpu/uds-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ metadata:
version: dev

packages:
# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
path: ../../../packages/supabase/
ref: dev
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# API
- name: leapfrogai-api
path: ../../../packages/api/
Expand All @@ -32,23 +49,6 @@ packages:
path: ../../../packages/whisper/
ref: dev

# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
path: ../../../packages/supabase/
ref: dev
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# UI
- name: leapfrogai-ui
path: ../../../packages/ui/
Expand Down
34 changes: 17 additions & 17 deletions uds-bundles/dev/gpu/uds-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ metadata:
version: dev

packages:
# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
path: ../../../packages/supabase/
ref: dev
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# OpenAI-like API
- name: leapfrogai-api
path: ../../../packages/api
Expand All @@ -32,23 +49,6 @@ packages:
path: ../../../packages/whisper
ref: dev

# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
path: ../../../packages/supabase/
ref: dev
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# UI
- name: leapfrogai-ui
path: ../../../packages/ui/
Expand Down
38 changes: 19 additions & 19 deletions uds-bundles/latest/cpu/uds-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ metadata:
# x-release-please-end

packages:
# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
repository: ghcr.io/defenseunicorns/packages/leapfrogai/supabase
# x-release-please-start-version
ref: 0.7.2
# x-release-please-end
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# API
- name: leapfrogai-api
repository: ghcr.io/defenseunicorns/packages/leapfrogai/leapfrogai-api
Expand Down Expand Up @@ -42,25 +61,6 @@ packages:
ref: 0.7.2
# x-release-please-end

# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
repository: ghcr.io/defenseunicorns/packages/leapfrogai/supabase
# x-release-please-start-version
ref: 0.7.2
# x-release-please-end
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# UI - new UI TODO - point to ghcr image after Sprint 0.7.0
- name: leapfrogai-ui
repository: ghcr.io/defenseunicorns/packages/leapfrogai/leapfrogai-ui
Expand Down
38 changes: 19 additions & 19 deletions uds-bundles/latest/gpu/uds-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ metadata:
# x-release-please-end

packages:
# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
repository: ghcr.io/defenseunicorns/packages/leapfrogai/supabase
# x-release-please-start-version
ref: 0.7.2
# x-release-please-end
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# OpenAI-like API
- name: leapfrogai-api
repository: ghcr.io/defenseunicorns/packages/leapfrogai/leapfrogai-api
Expand Down Expand Up @@ -42,25 +61,6 @@ packages:
ref: 0.7.2
# x-release-please-end

# Supabase backend for the UI and API to interface with Postgresql
- name: supabase
repository: ghcr.io/defenseunicorns/packages/leapfrogai/supabase
# x-release-please-start-version
ref: 0.7.2
# x-release-please-end
overrides:
supabase:
supabase-secrets-generator:
variables:
- path: "leapfrogai.sso.redirectUris"
name: "KEYCLOAK_REDIRECT_URIS"
default:
- "https://supabase-kong.uds.dev/auth/v1/callback"
- path: "leapfrogai.sso.webOrigins"
name: KEYCLOAK_WEB_ORIGINS
default:
- "https://ai.uds.dev"

# UI - new UI TODO - point to ghcr image after Sprint 0.7.0
- name: leapfrogai-ui
repository: ghcr.io/defenseunicorns/packages/leapfrogai/leapfrogai-ui
Expand Down
Loading

0 comments on commit c1a8294

Please sign in to comment.