Skip to content

Commit

Permalink
Feature/remove core api (#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
gecBurton authored Sep 6, 2024
1 parent 096bc35 commit bb3d5cf
Show file tree
Hide file tree
Showing 44 changed files with 280 additions and 4,942 deletions.
2 changes: 0 additions & 2 deletions .env.django
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ POSTGRES_DB=redbox-core
POSTGRES_PASSWORD=insecure
CONTACT_EMAIL=redbox-support@cabinetoffice.gov.uk
POSTGRES_HOST=db
CORE_API_HOST=core-api
CORE_API_PORT=5002
EMAIL_BACKEND_TYPE=CONSOLE
GOV_NOTIFY_API_KEY=f4k3_k3y
FROM_EMAIL=test@example.com
Expand Down
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ POSTGRES_DB=redbox-core
POSTGRES_PASSWORD=insecure
CONTACT_EMAIL=redbox-support@cabinetoffice.gov.uk
POSTGRES_HOST=db
CORE_API_HOST=core-api
CORE_API_PORT=5002
EMAIL_BACKEND_TYPE=CONSOLE
GOV_NOTIFY_API_KEY=f4k3_k3y
FROM_EMAIL=test@example.com
Expand Down
2 changes: 0 additions & 2 deletions .env.integration
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ POSTGRES_DB=redbox-core
POSTGRES_PASSWORD=insecure
CONTACT_EMAIL=redbox-support@cabinetoffice.gov.uk
POSTGRES_HOST=db
CORE_API_HOST=core-api
CORE_API_PORT=5002

EMAIL_BACKEND_TYPE=CONSOLE
GOV_NOTIFY_API_KEY=f4k3_k3y
Expand Down
2 changes: 0 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ POSTGRES_DB=redbox-core
POSTGRES_PASSWORD=insecure
CONTACT_EMAIL=redbox-support@cabinetoffice.gov.uk
POSTGRES_HOST=localhost
CORE_API_HOST=localhost
CORE_API_PORT=5002
EMAIL_BACKEND_TYPE=FILE
GOV_NOTIFY_API_KEY=f4k3_k3y
FROM_EMAIL=test@example.com
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ jobs:
- name: Run DeepEval Unit Tests
run: |
cp .env core-api/.env
cd core-api
poetry install
poetry run deepeval test run tests/test_ai.py --mark ai
Expand Down
18 changes: 1 addition & 17 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@ jobs:
ref: ${{ inputs.COMMIT_HASH }}
path: integration

- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true

- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
Expand All @@ -67,7 +51,7 @@ jobs:
echo AZURE_OPENAI_API_KEY_4O=${{ secrets.AZURE_OPENAI_API_KEY }} >> .env
echo EMBEDDING_AZURE_OPENAI_ENDPOINT=${{ secrets.AZURE_OPENAI_ENDPOINT }} >> .env
echo EMBEDDING_OPENAI_API_KEY=${{ secrets.AZURE_OPENAI_API_KEY }} >> .env
docker compose up -d --wait core-api django-app worker
docker compose up -d --wait django-app worker
docker ps
- name: Test integration with pytest
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,6 @@ permissions:
contents: read

jobs:
test-core-api:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.12"

- name: Set up Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.7.0

- name: Build Containers
run: |
mkdir -p data/elastic/
chmod 777 data/elastic/
cp .env.test .env
docker compose up -d --wait elasticsearch
- name: Test core with pytest
run: |
make test-core-api
test-redbox:

runs-on: ubuntu-latest
Expand Down
27 changes: 9 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ build:
rebuild: stop prune ## Rebuild all images
docker compose build --no-cache

.PHONY: test-core-api
test-core-api: ## Test core-api
cd core-api && poetry install --with dev && poetry run python -m pytest --cov=core_api -v --cov-report=term-missing --cov-fail-under=75

.PHONY: test-ai
test-ai: ## Test code with live LLM
cd redbox-core && poetry install --with dev && poetry run python -m pytest -m "ai" --cov=redbox -v --cov-report=term-missing --cov-fail-under=80
Expand Down Expand Up @@ -131,7 +127,6 @@ AUTO_APPLY_RESOURCES = module.django-app.aws_ecs_task_definition.aws-ecs-task \
module.worker.data.aws_ecs_task_definition.main \
aws_secretsmanager_secret.django-app-secret \
aws_secretsmanager_secret.worker-secret \
aws_secretsmanager_secret.core-api-secret \
module.django-lambda.aws_lambda_function.lambda_function

target_modules = $(foreach resource,$(AUTO_APPLY_RESOURCES),-target $(resource))
Expand All @@ -147,17 +142,13 @@ docker_build: ## Build the docker container
@echo "Services to update: $(DOCKER_SERVICES)"
# Enabling Docker BuildKit for better build performance
export DOCKER_BUILDKIT=1
@for service in $(DOCKER_SERVICES); do \
if grep -A 2 "^\s*$$service:" docker-compose.yml | grep -q 'build:'; then \
echo "Building $$service..."; \
PREV_IMAGE="$(ECR_REPO_URL)-$$service:$(PREV_IMAGE_TAG)"; \
echo "Pulling previous image: $$PREV_IMAGE"; \
docker pull $$PREV_IMAGE; \
docker compose build $$service; \
else \
echo "Skipping $$service uses default image"; \
fi; \
done

echo "Building django-app..."; \
PREV_IMAGE="$(ECR_REPO_URL)-django-app:$(PREV_IMAGE_TAG)"; \
echo "Pulling previous image: $$PREV_IMAGE"; \
docker pull $$PREV_IMAGE; \
docker compose build django-app; \



.PHONY: docker_push
Expand All @@ -178,7 +169,7 @@ docker_push:

.PHONY: docker_update_tag
docker_update_tag:
for service in django-app core-api worker; do \
for service in django-app worker; do \
MANIFEST=$$(aws ecr batch-get-image --repository-name $(ECR_REPO_NAME)-$$service --image-ids imageTag=$(IMAGE_TAG) --query 'images[].imageManifest' --output text) ; \
aws ecr put-image --repository-name $(ECR_REPO_NAME)-$$service --image-tag $(tag) --image-manifest "$$MANIFEST" ; \
done
Expand Down Expand Up @@ -259,7 +250,7 @@ release: ## Deploy app

.PHONY: eval_backend
eval_backend: ## Runs the only the necessary backend for evaluation BUCKET_NAME
docker compose up -d --wait core-api --build
docker compose up -d --wait worker --build
docker exec -it $$(docker ps -q --filter "name=minio") mc mb data/${BUCKET_NAME}

.PHONY: help
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,21 @@ checkout the `main` branch of the following repos:
* https://github.com/i-dot-ai/i-ai-core-infrastructure/
* https://github.com/i-dot-ai/redbox-copilot-infra-config

If, and only if, you want to deploy something other than HEAD then replace `var.image_tag` in `infrastructure/aws/ecs.tf` with the hash of the build you want deployed.
and checkout the `v1.0.0-rds` tag of the following repo:
* https://github.com/i-dot-ai/i-dot-ai-core-terraform-modules

Now run the commands below remembering to replace ENVIRONMENT with `dev`, `preprod` or `prod`
Replace `var.image_tag` in:
* `infrastructure/aws/ecs.tf`
* `infrastructure/aws/lambda.tf`

with the hash of the build you want deployed. Make sure that the hash corresponds to an image that exists in ECR,
if in doubt build it via the [build-action](./.github/workflows/build.yaml).

Login to aws via `aws-vault exec admin-role` and run the commands below from the redbox repo root

```commandline
cd redbox
make tf_init
make tf_init env=<ENVIRONMENT>
make tf_apply env=<ENVIRONMENT>
```

where ENVIRONMENT is one of `dev`, `preprod` or `prod`
27 changes: 0 additions & 27 deletions core-api/.vscode/launch.json

This file was deleted.

17 changes: 0 additions & 17 deletions core-api/.vscode/settings.json

This file was deleted.

17 changes: 0 additions & 17 deletions core-api/Dockerfile

This file was deleted.

Empty file removed core-api/core_api/__init__.py
Empty file.
88 changes: 0 additions & 88 deletions core-api/core_api/app.py

This file was deleted.

33 changes: 0 additions & 33 deletions core-api/core_api/auth.py

This file was deleted.

Loading

0 comments on commit bb3d5cf

Please sign in to comment.