zenotaiz commited on
Commit
d278e8a
·
verified ·
1 Parent(s): df6c506

Matrix Orchestrator: Pushing latest generic heavy engine

Browse files
Files changed (3) hide show
  1. Dockerfile +12 -0
  2. main.py +31 -0
  3. requirements.txt +2 -0
Dockerfile ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install -r requirements.txt
7
+
8
+ COPY . /app
9
+
10
+ EXPOSE 7860
11
+
12
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import math
3
+ import time
4
+
5
+ app = FastAPI()
6
+
7
+ @app.get("/")
8
+ def read_root():
9
+ return {"status": "awake", "message": "The 16GB Engine is hot."}
10
+
11
+ @app.get("/heavy-math")
12
+ def do_heavy_math():
13
+ start_time = time.time()
14
+
15
+ primes = []
16
+ for num in range(2, 50000):
17
+ is_prime = True
18
+ for i in range(2, int(math.sqrt(num)) + 1):
19
+ if (num % i) == 0:
20
+ is_prime = False
21
+ break
22
+ if is_prime:
23
+ primes.append(num)
24
+
25
+ end_time = time.time()
26
+
27
+ return {
28
+ "message": "Heavy job complete in Python",
29
+ "primes_found": len(primes),
30
+ "seconds_taken": round(end_time - start_time, 2)
31
+ }
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastapi
2
+ uvicorn