Skip to content

Commit

Permalink
Update service for production (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarquis authored Apr 11, 2024
1 parent daeb9b9 commit 0891450
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 26 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
if: ${{ vars.RUN_CICD == 'true' }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Lint Python app
uses: swiss-ai-center/common-code/.github/actions/lint-python-app@main
Expand All @@ -78,7 +78,7 @@ jobs:
if: ${{ vars.RUN_CICD == 'true' }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Test Python app
uses: swiss-ai-center/common-code/.github/actions/test-python-app@main
Expand All @@ -89,10 +89,10 @@ jobs:
release:
needs: test
runs-on: ubuntu-latest
if: ${{ vars.RUN_CICD == 'true' && success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prod') && (vars.DEPLOY_DEV == 'true' || vars.DEPLOY_PROD == 'true') }}
if: ${{ vars.RUN_CICD == 'true' && success() && github.ref == 'refs/heads/main' && (vars.DEPLOY_DEV == 'true' || vars.DEPLOY_PROD == 'true') }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and push Docker image to GitHub
id: build-and-push-docker-image-to-github
Expand All @@ -111,7 +111,7 @@ jobs:
if: ${{ vars.RUN_CICD == 'true' && success() && github.ref == 'refs/heads/main' && vars.DEPLOY_DEV == 'true' }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get service Docker image SHA tag
shell: bash
Expand All @@ -134,6 +134,11 @@ jobs:
engine-announce-retries: ${{ env.DEV_ENGINE_ANNOUNCE_RETRIES }}
engine-announce-retry-delay: ${{ env.DEV_ENGINE_ANNOUNCE_RETRY_DELAY }}

- name: Remove unnecessary keys from configuration files
uses: swiss-ai-center/common-code/.github/actions/remove-unnecessary-keys-from-kubernetes-configuration-files@main
with:
configuration-files-location: ./kubernetes

- name: Deploy service on the Kubernetes cluster
uses: swiss-ai-center/common-code/.github/actions/execute-command-on-kubernetes-cluster@main
with:
Expand All @@ -150,10 +155,10 @@ jobs:
deploy-prod:
needs: release
runs-on: ubuntu-latest
if: ${{ vars.RUN_CICD == 'true' && success() && github.ref == 'refs/heads/prod' && vars.DEPLOY_PROD == 'true' }}
if: ${{ vars.RUN_CICD == 'true' && success() && github.ref == 'refs/heads/main' && vars.DEPLOY_PROD == 'true' }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get service Docker image SHA tag
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base image
FROM python:3.10
FROM python:3.11

# Install all required packages to run the model
# TODO: 1. Add any additional packages required to run your model
Expand Down
2 changes: 1 addition & 1 deletion development.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Base image
FROM python:3.10
FROM python:3.11

# Install all required packages to run the model
# TODO: 1. Add any additional packages required to run your model
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
echo '.venv exists and is not empty';
else
echo '.venv does not exist or is empty';
python3.10 -m venv .venv;
python3.11 -m venv .venv;
fi &&
# Activate the virtual environment
source .venv/bin/activate &&
Expand All @@ -23,6 +23,8 @@ services:
environment:
- ENGINE_URLS=["http://host.docker.internal:8080"]
- SERVICE_URL=http://host.docker.internal:${SERVICE_PORT}
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- ${SERVICE_PORT}:9090
working_dir: /workspaces/service
Expand Down
25 changes: 14 additions & 11 deletions kubernetes/ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ kind: Ingress
metadata:
name: my-service-ingress
annotations:
cert-manager.io/issuer: "letsencrypt"
nginx.ingress.kubernetes.io/proxy-body-size: "16m"
nginx.org/client-max-body-size: "16m"
spec:
ingressClassName: nginx
rules:
- host: my-service.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service-service
port:
number: 80
- host: my-service.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service-service
port:
number: 80
tls:
- hosts:
- my-service.example.com
- my-service.example.com
secretName: my-service-example-com-tls-cert
53 changes: 50 additions & 3 deletions requirements-all.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,63 @@
aiobotocore==2.12.1
aiofiles==23.2.1
aiohttp==3.9.3
aioitertools==0.11.0
aiosignal==1.3.1
annotated-types==0.6.0
anyio==4.3.0
attrs==23.2.0
botocore==1.34.51
certifi==2024.2.2
click==8.1.7
coverage==7.4.4
dnspython==2.6.1
email_validator==2.1.1
fastapi==0.110.0
flake8==7.0.0
frozenlist==1.4.1
h11==0.14.0
httpcore==1.0.4
httpx==0.27.0
idna==3.6
iniconfig==2.0.0
jmespath==1.0.1
joblib==1.3.2
lazypredict-nightly==0.3.0
lazypredict-nightly==0.3.2
lightgbm==4.3.0
MarkupSafe==2.1.4
mccabe==0.7.0
multidict==6.0.5
numpy==1.26.4
packaging==24.0
pandas==2.2.1
pip==24.0
pluggy==1.4.0
pycodestyle==2.11.1
pydantic==2.6.4
pydantic-settings==2.2.1
pydantic_core==2.16.3
pyflakes==3.2.0
pytest==8.1.1
pytest-asyncio==0.23.5.post1
pytest-cov==4.1.0
pytest_httpserver==1.0.10
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pytz==2024.1
PyYAML==6.0.1
scikit-learn==1.4.1.post1
scipy==1.12.0
setuptools==65.5.0
six==1.16.0
threadpoolctl==3.3.0
sniffio==1.3.1
starlette==0.36.3
threadpoolctl==3.4.0
tqdm==4.66.2
typing_extensions==4.10.0
tzdata==2024.1
urllib3==2.0.7
uvicorn==0.28.0
Werkzeug==3.0.1
wrapt==1.16.0
xgboost==2.0.3
Werkzeug==2.3.6
yarl==1.9.4
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
common-code[test] @ git+https://github.com/swiss-ai-center/common-code.git@main
lazypredict-nightly==0.3.0
lazypredict-nightly==0.3.2
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Imports required by the service's model
import pandas as pd
from lazypredict.Supervised import LazyRegressor
from lazypredict import LazyRegressor
from sklearn.model_selection import train_test_split
import io

Expand Down

0 comments on commit 0891450

Please sign in to comment.