diff --git a/conda-store-server/conda_store_server/app.py b/conda-store-server/conda_store_server/app.py index aa97ac179..fe3a2f8de 100644 --- a/conda-store-server/conda_store_server/app.py +++ b/conda-store-server/conda_store_server/app.py @@ -1,6 +1,7 @@ import datetime import os import sys +from pathlib import Path, PurePosixPath from typing import Any, Dict import pydantic @@ -71,6 +72,9 @@ def conda_store_validate_action( ) +CONDA_STORE_DIR = Path.home() / ".conda-store" + + class CondaStore(LoggingConfigurable): storage_class = Type( default_value=storage.LocalStorage, @@ -87,7 +91,7 @@ class CondaStore(LoggingConfigurable): ) store_directory = Unicode( - "conda-store-state", + str(CONDA_STORE_DIR / "state"), help="directory for conda-store to build environments and store state", config=True, ) @@ -200,7 +204,7 @@ class CondaStore(LoggingConfigurable): ) database_url = Unicode( - "sqlite:///conda-store.sqlite", + "sqlite:///" + str(PurePosixPath(CONDA_STORE_DIR) / "conda-store.sqlite"), help="url for the database. e.g. 'sqlite:///conda-store.sqlite' tables will be automatically created if they do not exist", config=True, ) diff --git a/conda-store-server/conda_store_server/server/app.py b/conda-store-server/conda_store_server/server/app.py index a96857b28..f45198005 100644 --- a/conda-store-server/conda_store_server/server/app.py +++ b/conda-store-server/conda_store_server/server/app.py @@ -179,6 +179,14 @@ def initialize(self, *args, **kwargs): self.conda_store = CondaStore(parent=self, log=self.log) + self.conda_store.ensure_directories() + self.log.info( + f"Running conda-store with database: {self.conda_store.database_url}" + ) + self.log.info( + f"Running conda-store with storage: {self.conda_store.store_directory}" + ) + if self.conda_store.upgrade_db: dbutil.upgrade(self.conda_store.database_url) diff --git a/conda-store-server/tests/conftest.py b/conda-store-server/tests/conftest.py index 4cf9e2bff..927714ac7 100644 --- a/conda-store-server/tests/conftest.py +++ b/conda-store-server/tests/conftest.py @@ -22,11 +22,15 @@ def celery_config(conda_store): def conda_store_config(tmp_path, request): from traitlets.config import Config - filename = pathlib.Path(tmp_path) / "database.sqlite" + filename = pathlib.Path(tmp_path) / ".conda-store" / "database.sqlite" + + store_directory = tmp_path / ".conda-store" / "state" + store_directory.mkdir(parents=True) with utils.chdir(tmp_path): yield Config( CondaStore=dict( + store_directory=str(store_directory), database_url=f"sqlite:///{filename}?check_same_thread=False" ) )