-
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
Store the state and database files in ~/.conda-store by default #554
Conversation
Much saner default considering before how it would just write to your current directory. Agree this is needed. |
Also need to double check that there aren't any places that were relying on the default values without configuring it (e.g., in the Docker setup). |
There is currently an issue where it is not able to access the database file correctly, which I am still figuring out.
0ade4c6
to
fbe6145
Compare
✅ Deploy Preview for kaleidoscopic-dango-0cf31d ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hmm, previously I was having issues where the database file was not being initialized properly, but now I'm not. I'm not sure if something else changed in the interim that changed this, or if I'm just not doing the same steps I was before. It would be helpful if someone else can test this (just run |
@nkaretnikov to test |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Need to remove Posix
, it doesn't work on Windows:
- "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 (python -m conda_store_server.server
) and stored state files in the home 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.
Tested on Linux: works without changes.
% ls -1
conda-store.sqlite
conda-store-state
% pwd
/home/nkaretnikov/.conda-store
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.
Verified that this env builds on Linux and is available after restart (with the same state dir):
channels:
- conda-forge
dependencies:
- python
- pip:
- nothing
- ipykernel
- pytest
- requests
description: ''
name: test-env
prefix: null
variables: null
Server was started via python -m conda_store_server.server --standalone
.
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.
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 comment
The 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 comment
The 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.
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 comment
The 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
@@ -87,7 +88,7 @@ class CondaStore(LoggingConfigurable): | |||
) | |||
|
|||
store_directory = Unicode( | |||
"conda-store-state", | |||
str(Path.home() / ".conda-store" / "conda-store-state"), |
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.
@@ -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 comment
The 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.
conda-store-server/tests/conftest.py
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Not essential, but needs ".conda-store"
here, to be consistent with how we run this outside of tests.
Adding another note here: I think it would be a good idea to rename |
And use PurePosixPath instead of PosixPath, because PosixPath is not present on Windows.
Tested this on Windows by manually merged it with #559 |
I've addressed the review comments. One thing worth being aware of here is that if anyone is running conda-store without configuring database_url or store_directory but just relying on the defaults, their setup will break. All the example configs do configure it, so hopefully that isn't happening. |
Wait, I think it wasn't an issue before, no? Why is this required now? Like, I'm pretty sure I used to be able to just run with |
The point is it will break existing installations if they were relying on the default configuration, because the defaults have changed. |
Ah, OK. How about at least printing an error message and suggesting users move stuff to a new location? |
Hmm, the test failure is because tests conda_store object from the fixture isn't being used for some reason. |
@asmeurer The test failure looks legit. You also need to rebase.
|
Taking over this one. See #639. |
Still some issues that need to be worked out here. Also will need #549 to be merged and rebased first.
This work is part of #513.
Description
This pull request:
Pull request checklist
Additional information