From 5be383071221657cc90f26bf8fba4dc7083b81d3 Mon Sep 17 00:00:00 2001 From: Parmeet Singh Bhatia Date: Tue, 31 May 2022 09:27:14 -0400 Subject: [PATCH] Use _get_torch_home standard utility from torch hub --- torchtext/__init__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/torchtext/__init__.py b/torchtext/__init__.py index 015b51501f..28f8f21c23 100644 --- a/torchtext/__init__.py +++ b/torchtext/__init__.py @@ -1,14 +1,13 @@ import os +from torch.hub import _get_torch_home + # the following import has to happen first in order to load the torchtext C++ library from torchtext import _extension # noqa: F401 _TEXT_BUCKET = "https://download.pytorch.org/models/text/" -_TORCH_HOME = os.getenv("TORCH_HOME") -if _TORCH_HOME is None: - _TORCH_HOME = "~/.cache/torch" # default -_CACHE_DIR = os.path.expanduser(os.path.join(_TORCH_HOME, "text")) +_CACHE_DIR = os.path.expanduser(os.path.join(_get_torch_home(), "text")) from . import data, datasets, experimental, functional, models, nn, transforms, utils, vocab