Skip to content

Commit 658b932

Browse files
committed
fix: Network communication between frontend and backend containers
1 parent afc3276 commit 658b932

5 files changed

Lines changed: 11 additions & 8 deletions

File tree

Dockerfile.backend

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ RUN apt-get update && apt-get install -y \
99
&& rm -rf /var/lib/apt/lists/*
1010

1111
# Copy requirements and install Python dependencies
12-
COPY requirements.txt .
13-
RUN pip install --no-cache-dir -r requirements.txt
12+
COPY requirements-light.txt .
13+
RUN pip install --default-timeout=1000 --no-cache-dir -r requirements-light.txt
1414

1515
# Copy backend files
1616
COPY graph_generator.py .

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ services:
77
- "3000:80"
88
environment:
99
- NODE_ENV=production
10-
- REACT_APP_BACKEND_URL=http://backend:5000
10+
- REACT_APP_BACKEND_URL=http://localhost:5000
1111
depends_on:
1212
- backend
1313
container_name: algo-visualize-frontend

requirements-light.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
flask==2.3.3
2+
flask-cors==4.0.0
3+
networkx==3.1
4+
numpy==1.24.3
5+
requests==2.31.0

simple_classifier.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import torch
2-
import numpy as np
31
import networkx as nx
2+
import json
43

54
# Simple graph classifier that uses your PyTorch model directly
65
class SimpleGraphClassifier:
7-
def __init__(self, model_path):
6+
def __init__(self, model_path=None):
87
self.model_path = model_path
9-
self.state_dict = torch.load(model_path, map_location='cpu')
108
self.classes = ['Tree', 'Cycle', 'DAG']
119

1210
def simple_classify(self, edges):

src/hooks/useGraphClassification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const useGraphClassification = () => {
1010
setError(null);
1111

1212
try {
13-
const response = await fetch('http://localhost:5000/classify', {
13+
const response = await fetch(`${process.env.REACT_APP_BACKEND_URL || 'http://localhost:5000'}/classify`, {
1414
method: 'POST',
1515
headers: {
1616
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)