Spaces:
Sleeping
Sleeping
UPDATE: exportToDashboard
Browse files
analyticsHub/routers/reportingTool.py
CHANGED
|
@@ -7,6 +7,7 @@ from fastapi import APIRouter, Depends
|
|
| 7 |
from urllib.request import urlopen
|
| 8 |
from typing import Annotated
|
| 9 |
from . import pipeline
|
|
|
|
| 10 |
import json
|
| 11 |
import os
|
| 12 |
import gc
|
|
@@ -25,6 +26,10 @@ async def generateChart(chartDetails: GenerateChartInput, credentials: Annotated
|
|
| 25 |
metadata = json.loads(urlopen(fileUrl).read())
|
| 26 |
)
|
| 27 |
gc.collect()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
return JSONResponse(status_code = 200, content = response)
|
| 29 |
else:
|
| 30 |
return JSONResponse(status_code = 498, content = {"status": "ERROR", "errorDetail": "Invalid Token"})
|
|
@@ -44,6 +49,10 @@ async def generatePanelChart(panelChartDetails: PanelChartDetails, credentials:
|
|
| 44 |
dataSource = panelChartDetails.dataSource
|
| 45 |
)
|
| 46 |
gc.collect()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
return JSONResponse(status_code = 200, content = response)
|
| 48 |
else:
|
| 49 |
return JSONResponse(status_code = 498, content = {"status": "ERROR", "errorDetail": "Invalid Token"})
|
|
|
|
| 7 |
from urllib.request import urlopen
|
| 8 |
from typing import Annotated
|
| 9 |
from . import pipeline
|
| 10 |
+
import psutil
|
| 11 |
import json
|
| 12 |
import os
|
| 13 |
import gc
|
|
|
|
| 26 |
metadata = json.loads(urlopen(fileUrl).read())
|
| 27 |
)
|
| 28 |
gc.collect()
|
| 29 |
+
memory = psutil.virtual_memory()
|
| 30 |
+
cpuUsage = psutil.cpu_percent(interval=1)
|
| 31 |
+
print(f"RAM Usage Percentage: {memory.percent}%")
|
| 32 |
+
print(f"Total CPU Usage: {cpuUsage}%")
|
| 33 |
return JSONResponse(status_code = 200, content = response)
|
| 34 |
else:
|
| 35 |
return JSONResponse(status_code = 498, content = {"status": "ERROR", "errorDetail": "Invalid Token"})
|
|
|
|
| 49 |
dataSource = panelChartDetails.dataSource
|
| 50 |
)
|
| 51 |
gc.collect()
|
| 52 |
+
memory = psutil.virtual_memory()
|
| 53 |
+
cpuUsage = psutil.cpu_percent(interval=1)
|
| 54 |
+
print(f"RAM Usage Percentage: {memory.percent}%")
|
| 55 |
+
print(f"Total CPU Usage: {cpuUsage}%")
|
| 56 |
return JSONResponse(status_code = 200, content = response)
|
| 57 |
else:
|
| 58 |
return JSONResponse(status_code = 498, content = {"status": "ERROR", "errorDetail": "Invalid Token"})
|
requirements.txt
CHANGED
|
@@ -12,6 +12,7 @@ python-dotenv
|
|
| 12 |
python-jose
|
| 13 |
pydantic
|
| 14 |
pandas
|
|
|
|
| 15 |
uvicorn
|
| 16 |
psycopg2-binary
|
| 17 |
pymongo[srv]
|
|
|
|
| 12 |
python-jose
|
| 13 |
pydantic
|
| 14 |
pandas
|
| 15 |
+
psutil
|
| 16 |
uvicorn
|
| 17 |
psycopg2-binary
|
| 18 |
pymongo[srv]
|