Update app.py
Browse files
app.py
CHANGED
|
@@ -28,7 +28,7 @@ class Settings:
|
|
| 28 |
AGGREGATOR_URL = os.getenv("AGGREGATOR_URL", "http://192.168.1.104:8002")
|
| 29 |
|
| 30 |
# Model settings
|
| 31 |
-
MODEL_REPO = "https://huggingface.co/
|
| 32 |
|
| 33 |
# Server settings
|
| 34 |
TENSOR_SERVER_TIMEOUT = 30 # seconds
|
|
@@ -1119,21 +1119,20 @@ async def startup_event():
|
|
| 1119 |
print("[INFO] Starting chunk distribution...")
|
| 1120 |
distribution_tasks = []
|
| 1121 |
|
| 1122 |
-
#
|
| 1123 |
for chunk_id, chunk in state.model_chunks.items():
|
| 1124 |
-
#
|
| 1125 |
-
|
| 1126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1127 |
|
| 1128 |
-
for
|
| 1129 |
-
|
| 1130 |
-
task = asyncio.create_task(
|
| 1131 |
-
send_chunk_to_server(server_url, chunk_id, chunk)
|
| 1132 |
-
)
|
| 1133 |
-
distribution_tasks.append(task)
|
| 1134 |
-
|
| 1135 |
-
# Track assignments for future reference
|
| 1136 |
-
chunk.server_assignments.append(server_url)
|
| 1137 |
|
| 1138 |
if distribution_tasks:
|
| 1139 |
print(f"[INFO] Distributing {len(distribution_tasks)} chunks...")
|
|
|
|
| 28 |
AGGREGATOR_URL = os.getenv("AGGREGATOR_URL", "http://192.168.1.104:8002")
|
| 29 |
|
| 30 |
# Model settings
|
| 31 |
+
MODEL_REPO = "https://huggingface.co/microsoft/florence-2-large"
|
| 32 |
|
| 33 |
# Server settings
|
| 34 |
TENSOR_SERVER_TIMEOUT = 30 # seconds
|
|
|
|
| 1119 |
print("[INFO] Starting chunk distribution...")
|
| 1120 |
distribution_tasks = []
|
| 1121 |
|
| 1122 |
+
# One chunk per server distribution
|
| 1123 |
for chunk_id, chunk in state.model_chunks.items():
|
| 1124 |
+
# Assign each chunk to exactly one server
|
| 1125 |
+
server_index = chunk_id % len(Settings.TENSOR_SERVER_URLS)
|
| 1126 |
+
server_url = Settings.TENSOR_SERVER_URLS[server_index]
|
| 1127 |
+
# Create task for distributing this chunk to its assigned server
|
| 1128 |
+
task = asyncio.create_task(
|
| 1129 |
+
send_chunk_to_server(server_url, chunk_id, {"chunk_id": chunk_id})
|
| 1130 |
+
)
|
| 1131 |
+
distribution_tasks.append(task)
|
| 1132 |
+
print(f"[INFO] Sending chunk {chunk_id} to {server_url}")
|
| 1133 |
|
| 1134 |
+
# Track assignments for future reference
|
| 1135 |
+
chunk.server_assignments.append(server_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1136 |
|
| 1137 |
if distribution_tasks:
|
| 1138 |
print(f"[INFO] Distributing {len(distribution_tasks)} chunks...")
|