Skip to content

Commit 440b04c

Browse files
authored
Merge pull request #12 from InseeFrLab/test-double-images
Create 2 images both API and streamlit
2 parents d040732 + d666537 commit 440b04c

File tree

8 files changed

+66
-43
lines changed

8 files changed

+66
-43
lines changed

.github/workflows/build-image.yaml renamed to .github/workflows/build-images.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
name: Image Build
1+
name: Build Images
22

33
on:
44
push:
55
branches:
6-
- main
7-
6+
- "main"
87
tags:
98
- "*"
9+
paths:
10+
- "pyproject.toml"
11+
- "Dockerfiles/**"
12+
- "src/**"
13+
- ".github/workflows/**"
1014
workflow_dispatch:
1115

1216
jobs:
1317
image-build:
1418
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
include:
23+
- dockerfile: ./Dockerfiles/Dockerfile-streamlit
24+
image: meilametayebjee/codification-ape-graph-rag-streamlit
25+
- dockerfile: ./Dockerfiles/Dockerfile-api
26+
image: meilametayebjee/codification-ape-graph-rag-api
1527
steps:
1628
- name: Checkout
1729
uses: actions/checkout@v4
@@ -22,7 +34,7 @@ jobs:
2234
id: meta
2335
uses: docker/metadata-action@v5
2436
with:
25-
images: meilametayebjee/codification-ape-graph-rag-api
37+
images: ${{ matrix.image }}
2638
tags: |
2739
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
2840
type=ref,event=branch
@@ -45,6 +57,7 @@ jobs:
4557
uses: docker/build-push-action@v5
4658
with:
4759
context: .
60+
file: ${{ matrix.dockerfile }}
4861
push: true
4962
tags: ${{ steps.meta.outputs.tags }}
5063
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

Dockerfiles/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.venv

Dockerfiles/Dockerfile-api

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM inseefrlab/onyxia-vscode-python:py3.12.9
2+
3+
ENV TIMEOUT=3600
4+
5+
# Set working directory
6+
WORKDIR /app
7+
8+
# copy the code in api/
9+
ADD . /app
10+
11+
# Sync dependencies
12+
RUN uv sync --locked
13+
14+
# Expose port 5000
15+
EXPOSE 5000
16+
17+
# Set working directory to run api
18+
WORKDIR /app/src
19+
20+
CMD ["uv", "run", "uvicorn", "api.main:app", "--proxy-headers", "--host", "0.0.0.0", "--port", "5000", "--timeout-graceful-shutdown", "3600"]

Dockerfiles/Dockerfile-streamlit

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM inseefrlab/onyxia-vscode-python:py3.12.9
2+
3+
# Set working directory
4+
WORKDIR /app
5+
6+
# copy the code in streamlit/
7+
ADD . /app
8+
9+
# Sync dependencies
10+
RUN uv sync --locked
11+
12+
# Expose port 8501
13+
EXPOSE 8501
14+
15+
# Set working directory to run streamlit
16+
WORKDIR /app/src
17+
18+
CMD ["uv", "run", "streamlit", "run", "streamlit/main.py"]

src/api/routes/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ClassificationResponse(BaseModel):
1717
code_ape: str
1818

1919
class Config:
20-
json_schema_extra = {"example": {"code_ape": "1071C"}}
20+
json_schema_extra = {"example": {"code_ape": "10.71C"}}
2121

2222
@router.get(
2323
"/classify",

src/constants/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/main.py renamed to src/streamlit/main.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import httpx
2-
import streamlit as st
32

4-
from constants import API_LOCAL_URL
3+
import streamlit as st
54

65
st.set_page_config(page_title="Codif APE Classifier", layout="centered")
76

@@ -26,7 +25,11 @@
2625
else:
2726
with st.spinner("Classifying..."):
2827
try:
29-
response = httpx.get(f"{API_LOCAL_URL}/{classifier}/classify", params={"query": query}, timeout=30)
28+
response = httpx.get(
29+
f"https://codification-ape-graph-rag.lab.sspcloud.fr/{classifier}/classify",
30+
params={"query": query},
31+
timeout=30,
32+
)
3033
response.raise_for_status()
3134
result = response.json()
3235
st.success(f"✅ APE Code: `{result['code_ape']}`")
@@ -45,7 +48,9 @@
4548
else:
4649
with st.spinner("Classifying batch..."):
4750
try:
48-
response = httpx.post(f"{API_LOCAL_URL}/{classifier}/batch", json={"queries": lines}, timeout=60)
51+
response = httpx.post(
52+
f"https://codification-ape-graph-rag.lab.sspcloud.fr/{classifier}/batch", json={"queries": lines}, timeout=60
53+
)
4954
response.raise_for_status()
5055
results = response.json()
5156
st.table(results)

0 commit comments

Comments
 (0)