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

create $XDG_CACHE_HOME for PyTorch tests #2806

Merged
merged 2 commits into from
Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions easybuild/easyblocks/p/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from easybuild.framework.easyconfig import CUSTOM
from easybuild.tools.build_log import EasyBuildError, print_warning
from easybuild.tools.config import build_option
from easybuild.tools.filetools import symlink, apply_regex_substitutions
from easybuild.tools.filetools import apply_regex_substitutions, mkdir, symlink
from easybuild.tools.modules import get_software_root, get_software_version
from easybuild.tools.systemtools import POWER, get_cpu_architecture

Expand Down Expand Up @@ -239,10 +239,16 @@ def configure_step(self):
self.cfg.update('prebuildopts', ' '.join(unique_options) + ' ')
self.cfg.update('preinstallopts', ' '.join(unique_options) + ' ')

def _set_cache_dir(self):
"""Set $XDG_CACHE_HOME to avoid PyTorch defaulting to $HOME"""
cache_dir = os.path.join(self.tmpdir, '.cache')
# The path must exist!
mkdir(cache_dir, parents=True)
env.setvar('XDG_CACHE_HOME', cache_dir)

def test_step(self):
"""Run unit tests"""
# Make PyTorch tests not use the user home
env.setvar('XDG_CACHE_HOME', os.path.join(self.tmpdir, '.cache'))
self._set_cache_dir()
# Pretend to be on FB CI which disables some tests, especially those which download stuff
env.setvar('SANDCASTLE', '1')
# Skip this test(s) which is very flaky
Expand Down Expand Up @@ -350,8 +356,7 @@ def get_count_for_pattern(regex, text):
raise EasyBuildError("Test command had non-zero exit code (%s), but no failed tests found?!", tests_ec)

def test_cases_step(self):
# Make PyTorch tests not use the user home
env.setvar('XDG_CACHE_HOME', os.path.join(self.tmpdir, '.cache'))
self._set_cache_dir()
super(EB_PyTorch, self).test_cases_step()

def sanity_check_step(self, *args, **kwargs):
Expand Down