Skip to content
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

Fix leftover directories after tests #2360

Merged
merged 2 commits into from
May 16, 2024

Conversation

matrss
Copy link
Collaborator

@matrss matrss commented May 16, 2024

Purpose of PR?:

  • Fix osfs:/ directory leftover in CWD after tests

  • Fix leftover directories in /tmp after tests

    The way wms_cache was set previously made it so that after each tests
    run there would be one or more directories leftover in /tmp. This also
    happened for each start of MSUI. This change makes MSUI use the
    platform-specific cache directory of the user instead and sets
    XDG_CACHE_HOME to isolate those between test runs.

Fixes #2148.

Does this PR introduce a breaking change?

If the changes in this PR are manually verified, list down the scenarios covered::

Additional information for reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Does this PR results in some Documentation changes?
If yes, include the list of Documentation changes

Checklist:

  • Bug fix. Fixes #
  • New feature (Non-API breaking changes that adds functionality)
  • PR Title follows the convention of <type>: <subject>
  • Commit has unit tests

matrss added 2 commits May 16, 2024 15:08
The way wms_cache was set previously made it so that after each tests
run there would be one or more directories leftover in /tmp. This also
happened for each start of MSUI. This change makes MSUI use the
platform-specific cache directory of the user instead and sets
XDG_CACHE_HOME to isolate those between test runs.
@matrss matrss force-pushed the fix-leftover-directories branch from 31e1765 to 5ec6983 Compare May 16, 2024 13:11
@matrss matrss requested a review from ReimarBauer May 16, 2024 13:18
@@ -151,8 +148,7 @@ class MSUIDefaultConfig:
WMS_preload = []

# WMS image cache settings:
# this changes on any start of msui, use ths msui_settings.json when you want a persistent path
wms_cache = os.path.join(tempfile.TemporaryDirectory().name, "msui_wms_cache")
wms_cache = str(constants.MSUI_CACHE_PATH / "wms_cache")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

# MSUI does not actually support any PyFilesystem2 fs that is not available as a local path
MSUI_CONFIG_SYSPATH = _fs.getsyspath("")

MSUI_CACHE_PATH = platformdirs.user_cache_path("msui", "mss")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the tutorials I have to remove these data too. There it would be easier to remove only the MSUI_CONFIG_PATH, which I can do by using a config, which I also clear.

Because it wasn't the same dir on a new tutorial I didn't care.

It might easier to have a cache dir below the MSUI_CONFIG_PATH so all is on one place.

Copy link
Member

@ReimarBauer ReimarBauer May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also before we run tests the platformdirs cache needs to be cleared, or stored randomized.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might easier to have a cache dir below the MSUI_CONFIG_PATH so all is on one place.

Cache files don't belong into the configuration directory. There is a reason those are separate XDG directories. As a user I should be able to remove XDG_CACHE_HOME without any issue and be confident that this has cleared all application caches.

Copy link
Collaborator Author

@matrss matrss May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also before we run tests the platformdirs cache needs to be cleared, or stored randomized.

That happens by setting XDG_CACHE_HOME to a temporary directory in tests.constants.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on my KDE that is empty.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the tutorials I have to remove these data too. There it would be easier to remove only the MSUI_CONFIG_PATH, which I can do by using a config, which I also clear.

The cache should behave in a way that it doesn't matter if it exists already or not (just speeding things up if it does), so there should not necessarily be a need to remove it. Nonetheless, the tutorials could also just set XDG_CACHE_HOME (or a MSUI_CACHE_PATH, if we want to additionally introduce that).

Because it wasn't the same dir on a new tutorial I didn't care.

It still left trash in /tmp though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on my KDE that is empty.

image

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html:

$XDG_CACHE_HOME defines the base directory relative to which user-specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will see next days when I recreate the tutorials if we have to adopt something.

@matrss matrss merged commit 027cff4 into Open-MSS:develop May 16, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The test suite leaves a lot of trash in /tmp and CWD
2 participants