Spaces:
Runtime error
Runtime error
VenkateshRoshan
commited on
Commit
·
9989061
1
Parent(s):
370afab
dockerfile bug fixed
Browse files- .github/workflows/deploy.yml +11 -3
- app.py +4 -0
- dockerfile +11 -0
.github/workflows/deploy.yml
CHANGED
@@ -37,9 +37,17 @@ jobs:
|
|
37 |
uses: aws-actions/amazon-ecr-login@v1
|
38 |
|
39 |
- name: Build and push Docker image
|
|
|
|
|
|
|
|
|
40 |
run: |
|
41 |
-
docker build
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
|
44 |
- name: Deploy model to SageMaker
|
45 |
run: |
|
@@ -48,4 +56,4 @@ jobs:
|
|
48 |
--region ${{ secrets.AWS_REGION }} \
|
49 |
--role_arn ${{ secrets.SAGEMAKER_ROLE_ARN }} \
|
50 |
--ecr_repo_name "customer-support-chatbot" \
|
51 |
-
--endpoint_name "customer-support-chatbot"
|
|
|
37 |
uses: aws-actions/amazon-ecr-login@v1
|
38 |
|
39 |
- name: Build and push Docker image
|
40 |
+
env:
|
41 |
+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
42 |
+
ECR_REPOSITORY: customer-support-chatbot
|
43 |
+
IMAGE_TAG: latest
|
44 |
run: |
|
45 |
+
docker build \
|
46 |
+
--build-arg AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
|
47 |
+
--build-arg AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
|
48 |
+
--build-arg AWS_DEFAULT_REGION=${{ secrets.AWS_REGION }} \
|
49 |
+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
|
50 |
+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
|
51 |
|
52 |
- name: Deploy model to SageMaker
|
53 |
run: |
|
|
|
56 |
--region ${{ secrets.AWS_REGION }} \
|
57 |
--role_arn ${{ secrets.SAGEMAKER_ROLE_ARN }} \
|
58 |
--ecr_repo_name "customer-support-chatbot" \
|
59 |
+
--endpoint_name "customer-support-chatbot"
|
app.py
CHANGED
@@ -6,6 +6,7 @@ import gradio as gr
|
|
6 |
import os
|
7 |
import tarfile
|
8 |
from typing import List, Tuple
|
|
|
9 |
|
10 |
class CustomerSupportBot:
|
11 |
def __init__(self, model_path="models/customer_support_gpt"):
|
@@ -18,6 +19,9 @@ class CustomerSupportBot:
|
|
18 |
self.process = psutil.Process(os.getpid())
|
19 |
self.model_path = model_path
|
20 |
self.model_file_path = os.path.join(self.model_path, "model.tar.gz")
|
|
|
|
|
|
|
21 |
|
22 |
# Download and load the model
|
23 |
self.download_and_load_model()
|
|
|
6 |
import os
|
7 |
import tarfile
|
8 |
from typing import List, Tuple
|
9 |
+
import boto3
|
10 |
|
11 |
class CustomerSupportBot:
|
12 |
def __init__(self, model_path="models/customer_support_gpt"):
|
|
|
19 |
self.process = psutil.Process(os.getpid())
|
20 |
self.model_path = model_path
|
21 |
self.model_file_path = os.path.join(self.model_path, "model.tar.gz")
|
22 |
+
self.s3 = boto3.client("s3")
|
23 |
+
self.model_key = "models/model.tar.gz"
|
24 |
+
self.bucket_name = "customer-support-gpt"
|
25 |
|
26 |
# Download and load the model
|
27 |
self.download_and_load_model()
|
dockerfile
CHANGED
@@ -39,6 +39,16 @@ ENV PYTHONUNBUFFERED=TRUE
|
|
39 |
ENV PYTHONDONTWRITEBYTECODE=TRUE
|
40 |
ENV PATH="/opt/conda/bin:${PATH}"
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
# Install system dependencies
|
43 |
RUN apt-get update && \
|
44 |
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
@@ -55,6 +65,7 @@ WORKDIR /opt/ml/code
|
|
55 |
|
56 |
# Copy requirements and install dependencies
|
57 |
COPY requirements.txt .
|
|
|
58 |
RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
|
59 |
RUN pip install --no-cache-dir -r requirements.txt
|
60 |
|
|
|
39 |
ENV PYTHONDONTWRITEBYTECODE=TRUE
|
40 |
ENV PATH="/opt/conda/bin:${PATH}"
|
41 |
|
42 |
+
# Get args for AWS credentials
|
43 |
+
ARG AWS_ACCESS_KEY_ID
|
44 |
+
ARG AWS_SECRET_ACCESS_KEY
|
45 |
+
ARG AWS_DEFAULT_REGION
|
46 |
+
|
47 |
+
# get args as env variables
|
48 |
+
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
|
49 |
+
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
|
50 |
+
ENV AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}
|
51 |
+
|
52 |
# Install system dependencies
|
53 |
RUN apt-get update && \
|
54 |
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
|
|
65 |
|
66 |
# Copy requirements and install dependencies
|
67 |
COPY requirements.txt .
|
68 |
+
RUN pip install --no-cache-dir --upgrade pip
|
69 |
RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
|
70 |
RUN pip install --no-cache-dir -r requirements.txt
|
71 |
|