-
Notifications
You must be signed in to change notification settings - Fork 27
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
Fallback to cwd as a base path for resources_dir & results_dir #134
Fallback to cwd as a base path for resources_dir & results_dir #134
Conversation
First of all, thanks for your contribution 🙌 I think fluster should behave the same way whether it's installed or uninstalled to simplify the logic. For resources, fluster should default to $XDG_DATA_HOME/fluster (or %APPDATA% on Windows), so that regardless of where it's being run, the resources are always downloaded to the same directory and can be reused across executions. For the results dir, I think we can always default to the current working directory. Both paths should be configurable through args to override the defaults: |
Thanks! The reason for opening this PR was to discuss the best possible outcome ;-). |
This will be a breaking change, which brings up the need to start doing releases for fluster if the plan is to package for Debian or pypi. I have opened an issue to discuss that here: #135 |
Any suggestion on how I should go forward here ? Thanks ! |
FYI, You can use next global arguments:
So, this example should work in a read-only file system:
|
Right, but what about when fluster is installed in a system path e.g. |
Fluster defaults to using the script location as a base path for the resources & results. This works fine for local runs of fluster, when one is just calling fluster from a directory (e.g. ./fluster.py) but when fluster is installed in a read-only system directory (e.g. /usr/lib/python3.11/dist-packages/fluster for Debian) then the resources and results cannot be written unless running as superuser. Modify this behavior so that if the resources or results directories cannot be found under the script path, use the current working directory as a base path for these directories to allow fluster to be ran from a system installation. Signed-off-by: Christopher Obbard <[email protected]>
234f805
to
8718caa
Compare
We should default to I way to make it forward compatible and avoid breaking existing workflow is by checking in the uninstalled version if any of the subfolders exists, use them instead of the default In summary:
|
@ylatuya sounds good, I can implement this. But I have two questions:
|
It's easier to check if it's uninstalled:
https://pypi.org/project/xdg-base-dirs/ It doesn't seem to be cross-platform, a cross-platform implementation could be: https://github.com/platformdirs/platformdirs. This would be the first external dependency introduced and I think we could avoid it since the implementation would be trivial for this use case. For the resources cache:
For the results directory, thinking it twice with usability in mind, it's maybe better to use the current directory. What do you think @rgonzalezfluendo? |
Personally, I don't like tools to use the current directory. For instance, getting a fluster folder in my home if a crash... Also, the current directory can not have write perms. I prefer to use always UPDATE: python tempdir can be changed with env vars
|
I implemented #145 with all these ideas. Please let me know your feedback. |
First, I apologize for imposing our solution by creating the PR #145 above yours. We understand this can be frustrating, and there are better ways to operate. Thank you for opening this topic for discussion. We hope you like the final solution. Please do not hesitate to give feedback or request any changes. |
@rgonzalezfluendo it's fine - this PR was just to start the conversation ;-) |
Fluster defaults to using the script location as a base path for the resources & results. This works fine for local runs of fluster, when one is just calling fluster from a directory (e.g. ./fluster.py) but when fluster is installed in a read-only system directory (e.g. /usr/lib/python3.11/dist-packages/fluster for Debian) then the resources and results cannot be written unless running as superuser.
Modify this behavior so that if the resources or results directories cannot be found under the script path, use the current working directory as a base path for these directories to allow fluster to be ran from a system installation.