From a6b0978073ff638334df230692025e03d5260ef5 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sat, 25 Jan 2025 18:21:24 +0100 Subject: [PATCH] debug --- skore/src/skore/project/_launch.py | 17 ++++------------- skore/tests/unit/project/test_launch.py | 4 ++-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/skore/src/skore/project/_launch.py b/skore/src/skore/project/_launch.py index f1e494ec0..ebe819da4 100644 --- a/skore/src/skore/project/_launch.py +++ b/skore/src/skore/project/_launch.py @@ -6,11 +6,11 @@ import multiprocessing import os import socket -import uuid import webbrowser from pathlib import Path from typing import Union +import joblib import platformdirs import psutil import uvicorn @@ -84,18 +84,10 @@ class ServerInfo: def _get_pid_file_path(project: Project) -> Path: """Get the path to the PID file.""" if project.path is not None: - project_identifier = uuid.uuid3(uuid.NAMESPACE_DNS, str(project.path)) + project_identifier = joblib.hash(project.path, hash_name="sha1") else: - project_identifier = uuid.uuid3(uuid.NAMESPACE_DNS, str(project.name)) - - # Print the content of the skore state directory - state_dir = platformdirs.user_state_path(appname="skore") - if state_dir.exists(): - print(f"Content of {state_dir}:") - for path in state_dir.iterdir(): - print(f" {path.name}") - else: - print(f"Directory {state_dir} does not exist") + project_identifier = joblib.hash(project.name, hash_name="sha1") + return ( platformdirs.user_state_path(appname="skore") / f"skore-server-{project_identifier}.json" @@ -121,7 +113,6 @@ def rejoin(cls, project: Project): The server information. """ pid_file = cls._get_pid_file_path(project) - print(pid_file) if not pid_file.exists(): return diff --git a/skore/tests/unit/project/test_launch.py b/skore/tests/unit/project/test_launch.py index a79706ed4..065551bff 100644 --- a/skore/tests/unit/project/test_launch.py +++ b/skore/tests/unit/project/test_launch.py @@ -1,7 +1,7 @@ import os import socket -import uuid +import joblib import psutil import pytest from skore.project._create import _create @@ -57,7 +57,7 @@ def test_launch(capsys, tmp_path): server_info = skore_project._server_info pid_file_content = server_info.load_pid_file() assert server_info.port == pid_file_content["port"] - project_identifier = uuid.uuid3(uuid.NAMESPACE_DNS, str(skore_project.path)) + project_identifier = joblib.hash(skore_project.path, hash_name="sha1") assert server_info.pid_file.name == f"skore-server-{project_identifier}.json" skore_project.shutdown_web_ui()