poseidon666 commited on
Commit
fcc79cd
·
verified ·
1 Parent(s): 15aa4ba

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. DEPLOYMENT_GUIDE.md +4 -4
  2. Dockerfile +6 -3
  3. README.md +1 -1
  4. server/app.py +7 -34
DEPLOYMENT_GUIDE.md CHANGED
@@ -20,9 +20,9 @@ docker build -t quantum-circuit-opt:latest .
20
  ### 3. **Test Locally**
21
  ```bash
22
  # Run the container
23
- docker run -p 8000:8000 quantum-circuit-opt:latest
24
 
25
- # Open browser to: http://localhost:8000
26
  # You should see the Gradio UI
27
  ```
28
 
@@ -55,8 +55,8 @@ openenv push
55
  **Cause**: Port mismatch or wrong server configuration
56
 
57
  **Fix**:
58
- - Check README.md has `app_port: 8000`
59
- - Verify Dockerfile exposes port 8000
60
  - Ensure Gradio launches with `server_name="0.0.0.0"`
61
 
62
  ### Issue: Import errors in container
 
20
  ### 3. **Test Locally**
21
  ```bash
22
  # Run the container
23
+ docker run -p 7860:7860 quantum-circuit-opt:latest
24
 
25
+ # Open browser to: http://localhost:7860
26
  # You should see the Gradio UI
27
  ```
28
 
 
55
  **Cause**: Port mismatch or wrong server configuration
56
 
57
  **Fix**:
58
+ - Check README.md has `app_port: 7860`
59
+ - Verify Dockerfile exposes port 7860
60
  - Ensure Gradio launches with `server_name="0.0.0.0"`
61
 
62
  ### Issue: Import errors in container
Dockerfile CHANGED
@@ -71,10 +71,13 @@ ENV PATH="/app/.venv/bin:$PATH"
71
  # Set PYTHONPATH so imports work correctly
72
  ENV PYTHONPATH="/app/env:$PYTHONPATH"
73
 
 
 
 
74
  # Health check
75
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
76
- CMD curl -f http://localhost:8000/health || exit 1
77
 
78
- # Run the app with uvicorn
79
  ENV ENABLE_WEB_INTERFACE=true
80
- CMD ["sh", "-c", "cd /app/env && uvicorn server.app:app --host 0.0.0.0 --port 8000"]
 
71
  # Set PYTHONPATH so imports work correctly
72
  ENV PYTHONPATH="/app/env:$PYTHONPATH"
73
 
74
+ # Expose port
75
+ EXPOSE 7860
76
+
77
  # Health check
78
  HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
79
+ CMD python -c "import requests; requests.get('http://localhost:7860/')" || exit 1
80
 
81
+ # Run the app with python
82
  ENV ENABLE_WEB_INTERFACE=true
83
+ CMD ["sh", "-c", "cd /app/env && python -m server.app"]
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: indigo
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
8
- app_port: 8000
9
  tags:
10
  - openenv
11
  - quantum
 
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
8
+ app_port: 7860
9
  tags:
10
  - openenv
11
  - quantum
server/app.py CHANGED
@@ -1,15 +1,10 @@
1
  # -*- coding: utf-8 -*-
2
  """
3
- Minimal FastAPI + Gradio server for the Quantum Circuit Optimization Environment.
4
 
5
  Deployment spec:
6
- - Root endpoint: GET / → health check JSON
7
- - Gradio UI: mounted at /ui
8
- - Port: 7860 (managed externally by Docker / HF Spaces)
9
- - No uvicorn.run() in this file
10
-
11
- Run locally:
12
- uvicorn server.app:app --host 0.0.0.0 --port 7860
13
  """
14
 
15
  import json
@@ -24,7 +19,6 @@ for _p in (_ROOT, _HERE):
24
  if _p not in sys.path:
25
  sys.path.insert(0, _p)
26
 
27
- from fastapi import FastAPI
28
  import gradio as gr
29
 
30
  from models import ActionType, GateType, QuantumAction, QuantumObservation
@@ -33,23 +27,6 @@ from server.my_env_environment import QuantumCircuitEnvironment
33
  logging.basicConfig(level=logging.INFO)
34
  logger = logging.getLogger(__name__)
35
 
36
- # ---------------------------------------------------------------------------
37
- # FastAPI base app - Simple version for Gradio-first deployment
38
- # ---------------------------------------------------------------------------
39
- fastapi_app = FastAPI(title="Quantum Circuit Optimizer")
40
-
41
- @fastapi_app.get("/health")
42
- def health():
43
- return {"status": "ok", "message": "Quantum Circuit Optimizer is running"}
44
-
45
- @fastapi_app.get("/api/info")
46
- def info():
47
- return {
48
- "name": "Quantum Circuit Optimization Environment",
49
- "version": "1.0.0",
50
- "gradio_ui": "Available at root path /"
51
- }
52
-
53
  # ---------------------------------------------------------------------------
54
  # Global environment instance (for Gradio UI)
55
  # ---------------------------------------------------------------------------
@@ -209,7 +186,7 @@ def do_step(action_type, gate_type, qubit_0, qubit_1, parameter):
209
 
210
 
211
  # ---------------------------------------------------------------------------
212
- # STEP 11: Minimal Gradio UI — no custom CSS, no themes, no animations
213
  # ---------------------------------------------------------------------------
214
 
215
  def create_gradio_app() -> gr.Blocks:
@@ -249,16 +226,12 @@ def create_gradio_app() -> gr.Blocks:
249
 
250
 
251
  # ---------------------------------------------------------------------------
252
- # Create Gradio app and mount to FastAPI
253
  # ---------------------------------------------------------------------------
254
- demo = create_gradio_app()
255
-
256
- # Mount Gradio to FastAPI at root path
257
- app = gr.mount_gradio_app(fastapi_app, demo, path="/")
258
 
259
  # ---------------------------------------------------------------------------
260
  # Entry Point (for local testing only)
261
  # ---------------------------------------------------------------------------
262
  if __name__ == "__main__":
263
- import uvicorn
264
- uvicorn.run(app, host="0.0.0.0", port=8000)
 
1
  # -*- coding: utf-8 -*-
2
  """
3
+ Minimal Gradio server for the Quantum Circuit Optimization Environment.
4
 
5
  Deployment spec:
6
+ - Gradio UI at root
7
+ - Port: 7860 (managed externally by HF Spaces)
 
 
 
 
 
8
  """
9
 
10
  import json
 
19
  if _p not in sys.path:
20
  sys.path.insert(0, _p)
21
 
 
22
  import gradio as gr
23
 
24
  from models import ActionType, GateType, QuantumAction, QuantumObservation
 
27
  logging.basicConfig(level=logging.INFO)
28
  logger = logging.getLogger(__name__)
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  # ---------------------------------------------------------------------------
31
  # Global environment instance (for Gradio UI)
32
  # ---------------------------------------------------------------------------
 
186
 
187
 
188
  # ---------------------------------------------------------------------------
189
+ # Minimal Gradio UI
190
  # ---------------------------------------------------------------------------
191
 
192
  def create_gradio_app() -> gr.Blocks:
 
226
 
227
 
228
  # ---------------------------------------------------------------------------
229
+ # Create Gradio app
230
  # ---------------------------------------------------------------------------
231
+ app = create_gradio_app()
 
 
 
232
 
233
  # ---------------------------------------------------------------------------
234
  # Entry Point (for local testing only)
235
  # ---------------------------------------------------------------------------
236
  if __name__ == "__main__":
237
+ app.launch(server_name="0.0.0.0", server_port=7860)