Skip to content

Commit a31bfec

Browse files
committed
Add system check
1 parent 9c74c32 commit a31bfec

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

synalinks/cli/constants.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def get_fake_data(filename):
114114

115115
MAIN_TEMPLATE = """import os
116116
import synalinks
117+
import psutil
117118
from dotenv import load_dotenv
118119
from fastapi import FastAPI
119120
# Uncomment for streaming apps
@@ -161,10 +162,23 @@ async def create_program():
161162
# Setup FastAPI
162163
app = FastAPI()
163164
164-
@app.get("/v1/{{config.package_name}}/health")
165+
@app.get("/health")
165166
def health_check():
166167
return {"status": "healthy"}
167168
169+
170+
@app.get("/system_check")
171+
def system_check():
172+
cpu_usage = psutil.cpu_percent(interval=1)
173+
memory_info = psutil.virtual_memory()
174+
disk_usage = psutil.disk_usage("/")
175+
return {
176+
"cpu_usage": cpu_usage,
177+
"memory_usage": memory_info.percent,
178+
"disk_usage": disk_usage.percent,
179+
}
180+
181+
168182
@app.post("/v1/{{config.package_name}}")
169183
async def {{config.package_name}}(inputs: Query):
170184
result = await program(inputs)
@@ -219,6 +233,7 @@ async def {{config.package_name}}(inputs: Query):
219233
"""
220234

221235
REQUIREMENTS_TEMPLATE = """fastapi[standard]
236+
psutil
222237
synalinks
223238
"""
224239

@@ -277,6 +292,9 @@ async def build(self, inputs):
277292
super().__init__(
278293
inputs=inputs,
279294
outputs=outputs,
295+
name=self.name,
296+
description=self.description,
297+
trainable=self.trainable,
280298
)
281299
"""
282300

synalinks/src/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from synalinks.src.api_export import synalinks_export
44

55
# Unique source of truth for the version number.
6-
__version__ = "0.2.014"
6+
__version__ = "0.2.015"
77

88

99
@synalinks_export("synalinks.version")

0 commit comments

Comments
 (0)