ryanbalch commited on
Commit
07554c9
·
1 Parent(s): d1009a4

first alpha deployed to huggingface

Browse files
Files changed (5) hide show
  1. .gitignore +3 -1
  2. Makefile +13 -1
  3. api/Dockerfile +6 -5
  4. api/server_gradio.py +6 -1
  5. docker-compose.yaml +1 -0
.gitignore CHANGED
@@ -65,4 +65,6 @@ logs/
65
  **/niners_output/schedule_with_result_embedding.gsheet
66
 
67
  # Utility files
68
- z_utils/
 
 
 
65
  **/niners_output/schedule_with_result_embedding.gsheet
66
 
67
  # Utility files
68
+ z_utils/
69
+ # IFX-huge-league
70
+ IFX-huge-league
Makefile CHANGED
@@ -28,4 +28,16 @@ command-raw:
28
 
29
  clean-requirements:
30
  rm -f poetry.lock
31
-
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  clean-requirements:
30
  rm -f poetry.lock
31
+
32
+ # Build the Docker image for the 'runtime' stage in api/Dockerfile, tagged as huge-ifx-api:prod
33
+ build-prod:
34
+ cd api && docker build -f Dockerfile --target runtime -t huge-ifx-api:prod .
35
+
36
+ # Build the prod image and run it locally, mapping ports 7860 and 8000
37
+ up-build-prod: build-prod
38
+ docker run --rm -it -p 7860:7860 -p 8000:8000 --env-file .env -e DEV_MODE=true huge-ifx-api:prod
39
+
40
+ # Push the prod image to GitHub Container Registry
41
+ push-prod-ghcr:
42
+ docker tag huge-ifx-api:prod ghcr.io/rbalch/huge-ifx-api:prod
43
+ docker push ghcr.io/rbalch/huge-ifx-api:prod
api/Dockerfile CHANGED
@@ -14,7 +14,8 @@ WORKDIR /code
14
 
15
  # Set environment variables for Python behavior and module discovery
16
  ENV PYTHONUNBUFFERED=1
17
- ENV PYTHONPATH="$PYTHONPATH:/code"
 
18
 
19
  # Setup history for interactive sessions (ensuring it’s mappable with a volume)
20
  RUN mkdir -p /root/history
@@ -49,7 +50,7 @@ COPY --from=base /usr/local/bin /usr/local/bin
49
 
50
  # Reapply the environment variables for runtime and module resolution
51
  ENV PYTHONUNBUFFERED=1
52
- ENV PYTHONPATH="$PYTHONPATH:/code"
53
 
54
  # Recreate history and Huggingface cache directories (so they can be mapped via Docker Compose)
55
  RUN mkdir -p /root/history
@@ -62,8 +63,8 @@ ENV HF_HOME="/huggingface_cache"
62
  # Copy the rest of your application code
63
  COPY . .
64
 
65
- # Expose your service port
66
- EXPOSE 8000
67
 
68
  # Final command to run your app
69
- CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
 
14
 
15
  # Set environment variables for Python behavior and module discovery
16
  ENV PYTHONUNBUFFERED=1
17
+ # ENV PYTHONPATH="$PYTHONPATH:/code"
18
+ ENV PYTHONPATH="${PYTHONPATH}:/code"
19
 
20
  # Setup history for interactive sessions (ensuring it’s mappable with a volume)
21
  RUN mkdir -p /root/history
 
50
 
51
  # Reapply the environment variables for runtime and module resolution
52
  ENV PYTHONUNBUFFERED=1
53
+ ENV PYTHONPATH="${PYTHONPATH}:/code"
54
 
55
  # Recreate history and Huggingface cache directories (so they can be mapped via Docker Compose)
56
  RUN mkdir -p /root/history
 
63
  # Copy the rest of your application code
64
  COPY . .
65
 
66
+ # Expose gradio port
67
+ EXPOSE 7860
68
 
69
  # Final command to run your app
70
+ CMD ["python", "server_gradio.py"]
api/server_gradio.py CHANGED
@@ -1,6 +1,7 @@
1
  import asyncio
2
  import gradio as gr
3
  import time
 
4
  from pydantic import BaseModel
5
  from threading import Thread
6
  from langchain_core.messages import HumanMessage, AIMessage
@@ -9,6 +10,7 @@ from workflows.base import build_workflow
9
 
10
  lorem_ipsum = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""
11
  show_state = True
 
12
 
13
 
14
  class AppState(BaseModel):
@@ -131,4 +133,7 @@ with gr.Blocks() as demo:
131
 
132
 
133
  if __name__ == "__main__":
134
- demo.launch(server_name="0.0.0.0", server_port=8000)
 
 
 
 
1
  import asyncio
2
  import gradio as gr
3
  import time
4
+ import os
5
  from pydantic import BaseModel
6
  from threading import Thread
7
  from langchain_core.messages import HumanMessage, AIMessage
 
10
 
11
  lorem_ipsum = """Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."""
12
  show_state = True
13
+ dev_mode = os.getenv("DEV_MODE", "").lower() == "true"
14
 
15
 
16
  class AppState(BaseModel):
 
133
 
134
 
135
  if __name__ == "__main__":
136
+ if dev_mode:
137
+ demo.launch(server_name="0.0.0.0", server_port=8000)
138
+ else:
139
+ demo.launch(server_name="0.0.0.0")
docker-compose.yaml CHANGED
@@ -18,6 +18,7 @@ services:
18
  - .env
19
  environment:
20
  DEBUG: false
 
21
  # command: uvicorn server:app --reload --host 0.0.0.0 --port 8000 --reload --log-level debug
22
  command: gradio server_gradio.py
23
 
 
18
  - .env
19
  environment:
20
  DEBUG: false
21
+ DEV_MODE: true
22
  # command: uvicorn server:app --reload --host 0.0.0.0 --port 8000 --reload --log-level debug
23
  command: gradio server_gradio.py
24