ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
20 stars 33 forks source link

Use OS specific application directories instead of ~/omero #242

Closed manics closed 4 years ago

manics commented 4 years ago

This is https://github.com/ome/omero-py/pull/233 rebased and modified to only use the user_cache_dir property. get_omero_userdir() is unchanged (still returns ~/omero) but this can be changed to user_data_dir in 6.0.0 when breaking changes are allowed.

You can enable the new behaviour for get_omero_userdir() by setting OMERO_USERDIR="" (empty string, as opposed to not setting it).

Related to https://github.com/ome/omero-py/issues/210 but does not fully resolve it- need to wait until the new behaviour is the default

No migration options are supported since the cache dir has not yet been released. Longer term I'm inclined not to, AFAIK at the moment sessions are the only meaningful state stored under ~/omero, and since a major release probably implies a major release of the server and therefore a restart there's no point migrating an old session.

Decisions:

jburel commented 4 years ago

if the user wants to test the new feature, anything stores in the current selected location will be not be moved since there is no migration is offered, maybe the doc should indicate that. Insight is in maintenance mode, but we should probably unify that cc @dominikl

manics commented 4 years ago

Done.

A bit of googling found https://github.com/harawata/appdirs

jburel commented 4 years ago

insight issue created https://github.com/ome/omero-insight/issues/160

Thanks for the change.

ehrenfeu commented 2 years ago

Hi all, especially @manics and @sbesson

I'd like to point out that (if I understood correctly) with the changes planned for 6.0.0 in get_omero_userdir() it will be difficult to e.g. run an omero import if the system user doesn't have write permissions to its $HOME directory.

At least I haven't found a way to influence appdirs choice on the path, e.g. through an environment variable.

This might sound esoteric, but it's affecting me in hrm-omero as the way the code usually gets called on an HRM installation is through the system user running the web server (e.g. www-data) and quite often (e.g. on CentOS 7) that one is not allowed to write to /var/www/ or similar. In that case the download and extraction of OMERO.java.zip fails (silently) and the import process breaks.

Would it be possible to have an optional way to influence where that stuff ends up in the file system?

Cheers, Niko

ehrenfeu commented 2 years ago

Me again...

Maybe I misunderstood the intention / plan of @manics - in case the idea is to retain the possibility of influencing the cache path by setting OMERO_USERDIR then everything is fine. What I'd like to avoid is having to monkeypatch the HOME environment variable as this is guaranteed to have a rat-tail of unforeseen side-effects (I have some history of shooting myself in the foot with runtime-patching code...).

❤️ Niko

will-moore commented 2 years ago

I don't see any other changes planned for 6.0.0 that corresponds to what's in the docstring In 6.0.0 the default will change to use appdirs.user_data_dir, so maybe we should open a PR to do that?

But even in that case, you can still override by setting OMERO_USERDIR.

ehrenfeu commented 2 years ago

Thanks @will-moore - if setting OMERO_USERDIR will continue to work I am all fine.

It's just that I read the "In 6.0.0 the default will change to use appdirs.user_data_dir" that the appdirs.user_data_dir will have priority over the OMERO_USERDIR variable. That's what got me worried.