-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store the state and database files in ~/.conda-store by default #554
Changes from 3 commits
fbe6145
ac5e648
a8d3524
753c49d
cd927e0
861b76d
6b1c97e
066f646
004e533
08cc13b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import datetime | ||
import os | ||
import sys | ||
from pathlib import Path, PosixPath | ||
from typing import Any, Dict | ||
|
||
import pydantic | ||
|
@@ -87,7 +88,7 @@ class CondaStore(LoggingConfigurable): | |
) | ||
|
||
store_directory = Unicode( | ||
"conda-store-state", | ||
str(Path.home() / ".conda-store" / "conda-store-state"), | ||
help="directory for conda-store to build environments and store state", | ||
config=True, | ||
) | ||
|
@@ -200,7 +201,7 @@ class CondaStore(LoggingConfigurable): | |
) | ||
|
||
database_url = Unicode( | ||
"sqlite:///conda-store.sqlite", | ||
"sqlite:///" + str(PosixPath.home()) + "/.conda-store/conda-store.sqlite", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to remove - "sqlite:///" + str(PosixPath.home()) + "/.conda-store/conda-store.sqlite",
+ "sqlite:///" + str(Path.home()) + "/.conda-store/conda-store.sqlite", Tested on Windows: after rebasing on #559 and fixing the Posix thing, the server started ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested on Linux: works without changes.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verified that this env builds on Linux and is available after restart (with the same state dir):
Server was started via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure about that? PosixPath is used for URLs because URLs always use forward slashes, even on Windows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See for instance 80d9ea8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Have you tested on Windows? When I ran it on Windows, it raised an error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently on Windows you have to use pathlib.PurePosixPath instead of pathlib.PosixPath |
||
help="url for the database. e.g. 'sqlite:///conda-store.sqlite' tables will be automatically created if they do not exist", | ||
config=True, | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,8 @@ def initialize(self, *args, **kwargs): | |
|
||
self.conda_store = CondaStore(parent=self, log=self.log) | ||
|
||
self.conda_store.ensure_directories() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for other reviewers: this runs: os.makedirs(self.store_directory, exist_ok=True) because store_directory might not exist. |
||
|
||
if self.conda_store.upgrade_db: | ||
dbutil.upgrade(self.conda_store.database_url) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,13 @@ def conda_store_config(tmp_path, request): | |
|
||
filename = pathlib.Path(tmp_path) / "database.sqlite" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not essential, but needs |
||
|
||
store_directory = tmp_path / ".conda-store" / "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" | ||
) | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a variable for
Path.home() / ".conda-store"
and use it everywhere. For example:CONDA_STORE_DIR
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The location of
CONDA_STORE_DIR
needs to be printed when the server is started.Ideally: you can even print something like "Found existing conda-store.sqlite in
<dirname>
" or "Creating conda-store.sqlite in<dirname>
". Same for the rest of top-level state files/dirs.Otherwise, we'll run into problems when reproducing issues. People will have no idea that some state was created somewhere. Up until now, it hasn't been a problem because files are more visible in the current project dir, since it's tracked by git.