Skip to content

Commit

Permalink
Merge pull request #196 from alan-turing-institute/pulumi-reg-2pt0-up…
Browse files Browse the repository at this point in the history
…date

Pulumi 2.0 update
  • Loading branch information
rchan26 authored Jun 13, 2024
2 parents 66e1ae2 + cf48e58 commit 889102a
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 58 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build_docker_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,37 @@ jobs:
fail-fast: false
matrix:
include:
- dockerfile: docker/reginald/Dockerfile
image: ghcr.io/${{ github.repository }}_reginald
- dockerfile: docker/run_all/Dockerfile
image: ghcr.io/${{ github.repository }}_run_all
- dockerfile: docker/slack_bot/Dockerfile
image: ghcr.io/${{ github.repository }}_slackbot
- dockerfile: docker/create_index/Dockerfile
image: ghcr.io/${{ github.repository }}_create_index
- dockerfile: docker/reginald_app/Dockerfile
image: ghcr.io/${{ github.repository }}_app
permissions:
packages: write
contents: read

steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5.5.0
with:
images: ${{ matrix.image }}

- name: Build and push Docker images
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5.4.0
with:
file: ${{ matrix.dockerfile }}
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Lint with pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.11
Expand Down
34 changes: 18 additions & 16 deletions azure/hack_week/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
storage,
)

from reginald.defaults import DEFAULT_ARGS

# Get some configuration variables
stack_name = pulumi.get_stack()
config = pulumi.Config()
Expand Down Expand Up @@ -98,7 +100,7 @@
containers=[
# Reginald chat completion container
containerinstance.ContainerArgs(
image="ghcr.io/alan-turing-institute/reginald_reginald:main",
image="ghcr.io/alan-turing-institute/reginald_run_all:main",
name="reginald-completion", # maximum of 63 characters
environment_variables=[
containerinstance.EnvironmentVariableArgs(
Expand Down Expand Up @@ -141,7 +143,7 @@
),
# Reginald (public) container
containerinstance.ContainerArgs(
image="ghcr.io/alan-turing-institute/reginald_reginald:main",
image="ghcr.io/alan-turing-institute/reginald_run_all:main",
name="reginald-gpt-azure", # maximum of 63 characters
environment_variables=[
containerinstance.EnvironmentVariableArgs(
Expand All @@ -166,23 +168,23 @@
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_MAX_INPUT_SIZE",
value="4096",
value=str(DEFAULT_ARGS["max_input_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_K",
value="3",
value=str(DEFAULT_ARGS["k"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_SIZE",
value="512",
value=str(DEFAULT_ARGS["chunk_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_OVERLAP_RATIO",
value="0.1",
value=str(DEFAULT_ARGS["chunk_overlap_ratio"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_NUM_OUTPUT",
value="512",
value=str(DEFAULT_ARGS["num_output"]),
),
containerinstance.EnvironmentVariableArgs(
name="OPENAI_AZURE_API_BASE",
Expand All @@ -204,8 +206,8 @@
ports=[],
resources=containerinstance.ResourceRequirementsArgs(
requests=containerinstance.ResourceRequestsArgs(
cpu=1,
memory_in_gb=12,
cpu=3,
memory_in_gb=14,
),
),
volume_mounts=[
Expand Down Expand Up @@ -253,30 +255,30 @@
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_MAX_INPUT_SIZE",
value="4096",
value=str(DEFAULT_ARGS["max_input_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_K",
value="3",
value=str(DEFAULT_ARGS["k"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_SIZE",
value="512",
value=str(DEFAULT_ARGS["chunk_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_OVERLAP_RATIO",
value="0.1",
value=str(DEFAULT_ARGS["chunk_overlap_ratio"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_NUM_OUTPUT",
value="512",
value=str(DEFAULT_ARGS["num_output"]),
),
],
ports=[],
resources=containerinstance.ResourceRequirementsArgs(
requests=containerinstance.ResourceRequestsArgs(
cpu=4,
memory_in_gb=16,
cpu=1,
memory_in_gb=8,
),
),
volume_mounts=[
Expand Down
116 changes: 107 additions & 9 deletions azure/production/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
storage,
)

from reginald.defaults import DEFAULT_ARGS

# Get some configuration variables
stack_name = pulumi.get_stack()
config = pulumi.Config()
Expand Down Expand Up @@ -142,7 +144,7 @@
# all_data index creation container
containerinstance.ContainerArgs(
image="ghcr.io/alan-turing-institute/reginald_create_index:main",
name="reginald-create-index", # maximum of 63 characters
name="reginald-create-index-all-data", # maximum of 63 characters
environment_variables=[
containerinstance.EnvironmentVariableArgs(
name="GITHUB_TOKEN",
Expand All @@ -154,30 +156,126 @@
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_MAX_INPUT_SIZE",
value="4096",
value=str(DEFAULT_ARGS["max_input_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_K",
value=str(DEFAULT_ARGS["k"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_SIZE",
value=str(DEFAULT_ARGS["chunk_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_OVERLAP_RATIO",
value=str(DEFAULT_ARGS["chunk_overlap_ratio"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_NUM_OUTPUT",
value=str(DEFAULT_ARGS["num_output"]),
),
],
ports=[],
resources=containerinstance.ResourceRequirementsArgs(
requests=containerinstance.ResourceRequestsArgs(
cpu=2,
memory_in_gb=6,
),
),
volume_mounts=[
containerinstance.VolumeMountArgs(
mount_path="/app/data",
name="llama-data",
),
],
),
# reg index creation container
containerinstance.ContainerArgs(
image="ghcr.io/alan-turing-institute/reginald_create_index:main",
name="reginald-create-index-reg", # maximum of 63 characters
environment_variables=[
containerinstance.EnvironmentVariableArgs(
name="GITHUB_TOKEN",
secure_value=config.get_secret("GITHUB_TOKEN"),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_WHICH_INDEX",
value="reg",
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_MAX_INPUT_SIZE",
value=str(DEFAULT_ARGS["max_input_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_K",
value="3",
value=str(DEFAULT_ARGS["k"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_SIZE",
value="512",
value=str(DEFAULT_ARGS["chunk_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_OVERLAP_RATIO",
value="0.1",
value=str(DEFAULT_ARGS["chunk_overlap_ratio"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_NUM_OUTPUT",
value="512",
value=str(DEFAULT_ARGS["num_output"]),
),
],
ports=[],
resources=containerinstance.ResourceRequirementsArgs(
requests=containerinstance.ResourceRequestsArgs(
cpu=4,
memory_in_gb=16,
cpu=1,
memory_in_gb=5,
),
),
volume_mounts=[
containerinstance.VolumeMountArgs(
mount_path="/app/data",
name="llama-data",
),
],
),
# public index creation container
containerinstance.ContainerArgs(
image="ghcr.io/alan-turing-institute/reginald_create_index:main",
name="reginald-create-index-public", # maximum of 63 characters
environment_variables=[
containerinstance.EnvironmentVariableArgs(
name="GITHUB_TOKEN",
secure_value=config.get_secret("GITHUB_TOKEN"),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_WHICH_INDEX",
value="public",
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_MAX_INPUT_SIZE",
value=str(DEFAULT_ARGS["max_input_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_K",
value=str(DEFAULT_ARGS["k"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_SIZE",
value=str(DEFAULT_ARGS["chunk_size"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_CHUNK_OVERLAP_RATIO",
value=str(DEFAULT_ARGS["chunk_overlap_ratio"]),
),
containerinstance.EnvironmentVariableArgs(
name="LLAMA_INDEX_NUM_OUTPUT",
value=str(DEFAULT_ARGS["num_output"]),
),
],
ports=[],
resources=containerinstance.ResourceRequirementsArgs(
requests=containerinstance.ResourceRequestsArgs(
cpu=1,
memory_in_gb=5,
),
),
volume_mounts=[
Expand All @@ -190,7 +288,7 @@
],
os_type=containerinstance.OperatingSystemTypes.LINUX,
resource_group_name=resource_group.name,
restart_policy=containerinstance.ContainerGroupRestartPolicy.NEVER,
restart_policy=containerinstance.ContainerGroupRestartPolicy.ON_FAILURE,
sku=containerinstance.ContainerGroupSku.STANDARD,
volumes=[
containerinstance.VolumeArgs(
Expand Down
20 changes: 14 additions & 6 deletions docker/create_index/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
FROM python:3.11.4
FROM python:3.11.9

WORKDIR /app

# Setup Python prerequisites
RUN pip3 install --upgrade pip poetry setuptools wheel
RUN pip3 install --upgrade pip poetry==1.8.3 setuptools wheel

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache

# Build Python project
COPY reginald reginald
COPY pyproject.toml .
COPY README.md .
RUN poetry install
RUN touch README.md
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR

COPY reginald reginald

RUN poetry install --without dev

CMD ["poetry", "run", "reginald_create_index"]
CMD ["poetry", "run", "reginald", "create-index"]
14 changes: 0 additions & 14 deletions docker/reginald/Dockerfile

This file was deleted.

22 changes: 22 additions & 0 deletions docker/reginald_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.11.9

WORKDIR /app

# Setup Python prerequisites
RUN pip3 install --upgrade pip poetry setuptools wheel

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache

# Build Python project
COPY pyproject.toml .
RUN touch README.md
RUN poetry install --without dev --no-root && rm -rf $POETRY_CACHE_DIR

COPY reginald reginald

RUN poetry install --extras api_bot --without dev

CMD ["poetry", "run", "reginald", "app"]
Loading

0 comments on commit 889102a

Please sign in to comment.