ruff format

This commit is contained in:
Daulet Amirkhanov 2025-09-11 15:21:41 +01:00
parent 7220052ca6
commit 151e5ea6ea
2 changed files with 27 additions and 23 deletions

View file

@ -23,7 +23,9 @@ def normalize_version_for_comparison(version: str) -> str:
Handles development versions and edge cases.
"""
# Remove common development suffixes for comparison
normalized = version.replace("-local", "").replace("-dev", "").replace("-alpha", "").replace("-beta", "")
normalized = (
version.replace("-local", "").replace("-dev", "").replace("-alpha", "").replace("-beta", "")
)
return normalized.strip()
@ -83,7 +85,9 @@ def download_frontend_assets(force: bool = False) -> bool:
logger.debug(f"Frontend assets already cached for version {current_version}")
return True
else:
logger.info(f"Version mismatch detected: cached={cached_version}, current={current_version}")
logger.info(
f"Version mismatch detected: cached={cached_version}, current={current_version}"
)
logger.info("Updating frontend cache to match current cognee version...")
# Clear the old cached version
if frontend_dir.exists():
@ -410,7 +414,9 @@ def start_ui(
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
preexec_fn=os.setsid if hasattr(os, 'setsid') else None, # Create new process group on Unix
preexec_fn=os.setsid
if hasattr(os, "setsid")
else None, # Create new process group on Unix
)
# Give it a moment to start up
@ -463,7 +469,7 @@ def stop_ui(process: subprocess.Popen) -> bool:
try:
# Try to terminate the process group (includes child processes like Next.js)
if hasattr(os, 'killpg'):
if hasattr(os, "killpg"):
try:
# Kill the entire process group
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
@ -483,7 +489,7 @@ def stop_ui(process: subprocess.Popen) -> bool:
logger.warning("Process didn't terminate gracefully, forcing kill")
# Force kill the process group
if hasattr(os, 'killpg'):
if hasattr(os, "killpg"):
try:
os.killpg(os.getpgid(process.pid), signal.SIGKILL)
logger.debug("Sent SIGKILL to process group")

View file

@ -173,7 +173,7 @@ def main() -> int:
args = parser.parse_args()
# Handle UI flag
if hasattr(args, 'start_ui') and args.start_ui:
if hasattr(args, "start_ui") and args.start_ui:
server_process = None
def signal_handler(signum, frame):
@ -203,12 +203,9 @@ def main() -> int:
try:
from cognee import start_ui
fmt.echo("Starting cognee UI...")
server_process = start_ui(
host="localhost",
port=3001,
open_browser=True
)
server_process = start_ui(host="localhost", port=3001, open_browser=True)
if server_process:
fmt.success("UI server started successfully!")
@ -218,6 +215,7 @@ def main() -> int:
try:
# Keep the server running
import time
while server_process.poll() is None: # While process is still running
time.sleep(1)
except KeyboardInterrupt: