Skip to content

Commit

Permalink
Remove Unnecessary psutil Dependency (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftp authored Nov 11, 2024
1 parent b064b3f commit 0313261
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 63 deletions.
14 changes: 0 additions & 14 deletions dbos/_admin_sever.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from typing import TYPE_CHECKING, Any, List, TypedDict

import psutil

from ._logger import dbos_logger
from ._recovery import recover_pending_workflows

Expand All @@ -16,7 +14,6 @@

_health_check_path = "/dbos-healthz"
_workflow_recovery_path = "/dbos-workflow-recovery"
_perf_path = "/dbos-perf"
_deactivate_path = "/deactivate"


Expand Down Expand Up @@ -55,17 +52,6 @@ def do_GET(self) -> None:
self.send_response(200)
self._end_headers()
self.wfile.write("healthy".encode("utf-8"))
elif self.path == _perf_path:
# Compares system CPU times elapsed since last call or module import, returning immediately (non blocking).
cpu_percent = psutil.cpu_percent(interval=None) / 100.0
perf_util: PerfUtilization = {
"idle": 1.0 - cpu_percent,
"active": cpu_percent,
"utilization": cpu_percent,
}
self.send_response(200)
self._end_headers()
self.wfile.write(json.dumps(perf_util).encode("utf-8"))
elif self.path == _deactivate_path:
dbos_logger.info("Deactivating DBOS")
# Stop all scheduled workflows, queues, and kafka loops
Expand Down
30 changes: 1 addition & 29 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies = [
"opentelemetry-exporter-otlp-proto-http>=1.27.0",
"python-dateutil>=2.9.0.post0",
"fastapi[standard]>=0.115.2",
"psutil>=6.0.0",
"tomlkit>=0.13.2",
"psycopg[binary]>=3.1", # Keep compatibility with 3.1--older Python installations/machines can't always install 3.2
]
Expand Down Expand Up @@ -49,7 +48,6 @@ dev = [
"black>=24.10.0",
"pre-commit>=4.0.1",
"isort>=5.13.2",
"types-psutil>=6.0.0.20240621",
"requests>=2.32.3",
"types-requests>=2.32.0.20240914",
"httpx>=0.27.2",
Expand Down
18 changes: 0 additions & 18 deletions tests/test_admin_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,6 @@ def test_admin_endpoints(dbos: DBOS) -> None:
assert response.status_code == 200
assert response.json() == []

# Test GET /dbos-perf
response = requests.get("http://localhost:3001/dbos-perf", timeout=5)
assert response.status_code == 200
perf_util = response.json()
assert perf_util is not None
assert "idle" in perf_util
assert "active" in perf_util
assert "utilization" in perf_util

# Test GET /dbos-perf again, should be a valid utilization between 0~1
time.sleep(0.2)
response = requests.get("http://localhost:3001/dbos-perf", timeout=5)
assert response.status_code == 200
perf_util = response.json()
assert perf_util["utilization"] >= 0.0
assert perf_util["utilization"] <= 1.0

# Test GET not found
response = requests.get("http://localhost:3001/stuff", timeout=5)
assert response.status_code == 404
Expand All @@ -55,7 +38,6 @@ def test_admin_endpoints(dbos: DBOS) -> None:
assert event.is_set(), "Event is not set!"



def test_admin_recovery(dbos: DBOS) -> None:
os.environ["DBOS__VMID"] = "testexecutor"
os.environ["DBOS__APPVERSION"] = "testversion"
Expand Down

0 comments on commit 0313261

Please sign in to comment.