ruff format
This commit is contained in:
parent
7220052ca6
commit
151e5ea6ea
2 changed files with 27 additions and 23 deletions
|
|
@ -23,7 +23,9 @@ def normalize_version_for_comparison(version: str) -> str:
|
||||||
Handles development versions and edge cases.
|
Handles development versions and edge cases.
|
||||||
"""
|
"""
|
||||||
# Remove common development suffixes for comparison
|
# 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()
|
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}")
|
logger.debug(f"Frontend assets already cached for version {current_version}")
|
||||||
return True
|
return True
|
||||||
else:
|
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...")
|
logger.info("Updating frontend cache to match current cognee version...")
|
||||||
# Clear the old cached version
|
# Clear the old cached version
|
||||||
if frontend_dir.exists():
|
if frontend_dir.exists():
|
||||||
|
|
@ -410,7 +414,9 @@ def start_ui(
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
text=True,
|
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
|
# Give it a moment to start up
|
||||||
|
|
@ -463,7 +469,7 @@ def stop_ui(process: subprocess.Popen) -> bool:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Try to terminate the process group (includes child processes like Next.js)
|
# Try to terminate the process group (includes child processes like Next.js)
|
||||||
if hasattr(os, 'killpg'):
|
if hasattr(os, "killpg"):
|
||||||
try:
|
try:
|
||||||
# Kill the entire process group
|
# Kill the entire process group
|
||||||
os.killpg(os.getpgid(process.pid), signal.SIGTERM)
|
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")
|
logger.warning("Process didn't terminate gracefully, forcing kill")
|
||||||
|
|
||||||
# Force kill the process group
|
# Force kill the process group
|
||||||
if hasattr(os, 'killpg'):
|
if hasattr(os, "killpg"):
|
||||||
try:
|
try:
|
||||||
os.killpg(os.getpgid(process.pid), signal.SIGKILL)
|
os.killpg(os.getpgid(process.pid), signal.SIGKILL)
|
||||||
logger.debug("Sent SIGKILL to process group")
|
logger.debug("Sent SIGKILL to process group")
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ def main() -> int:
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Handle UI flag
|
# Handle UI flag
|
||||||
if hasattr(args, 'start_ui') and args.start_ui:
|
if hasattr(args, "start_ui") and args.start_ui:
|
||||||
server_process = None
|
server_process = None
|
||||||
|
|
||||||
def signal_handler(signum, frame):
|
def signal_handler(signum, frame):
|
||||||
|
|
@ -203,12 +203,9 @@ def main() -> int:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from cognee import start_ui
|
from cognee import start_ui
|
||||||
|
|
||||||
fmt.echo("Starting cognee UI...")
|
fmt.echo("Starting cognee UI...")
|
||||||
server_process = start_ui(
|
server_process = start_ui(host="localhost", port=3001, open_browser=True)
|
||||||
host="localhost",
|
|
||||||
port=3001,
|
|
||||||
open_browser=True
|
|
||||||
)
|
|
||||||
|
|
||||||
if server_process:
|
if server_process:
|
||||||
fmt.success("UI server started successfully!")
|
fmt.success("UI server started successfully!")
|
||||||
|
|
@ -218,6 +215,7 @@ def main() -> int:
|
||||||
try:
|
try:
|
||||||
# Keep the server running
|
# Keep the server running
|
||||||
import time
|
import time
|
||||||
|
|
||||||
while server_process.poll() is None: # While process is still running
|
while server_process.poll() is None: # While process is still running
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue