Skip to content

Commit

Permalink
[PT FE] Use system model cache when running torch hub tests locally (o…
Browse files Browse the repository at this point in the history
…penvinotoolkit#21047)

* Use system model cache when running torch hub tests locally

* Update tests/model_hub_tests/torch_tests/test_torchvision_models.py

* Update tests/model_hub_tests/torch_tests/test_torchvision_models.py
  • Loading branch information
mvafin authored Nov 14, 2023
1 parent 5ef7c02 commit 369831c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ jobs:
env:
TYPE: ${{ github.event_name == 'schedule' && 'nightly' || 'precommit'}}
TEST_DEVICE: CPU
USE_SYSTEM_CACHE: False

- name: Available storage after tests
run: |
Expand Down
6 changes: 3 additions & 3 deletions tests/model_hub_tests/models_hub_common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
os.path.join(tempfile.gettempdir(), "tfhub_modules"))
os.environ['TFHUB_CACHE_DIR'] = tf_hub_cache_dir

hf_hub_cache_dir = os.environ.get('HUGGINGFACE_HUB_CACHE',
tempfile.gettempdir())
os.environ['HUGGINGFACE_HUB_CACHE'] = hf_hub_cache_dir
hf_hub_cache_dir = tempfile.gettempdir()
if os.environ.get('USE_SYSTEM_CACHE', 'True') == 'False':
os.environ['HUGGINGFACE_HUB_CACHE'] = hf_hub_cache_dir

# supported_devices : CPU, GPU, GNA
test_device = os.environ.get('TEST_DEVICE', 'CPU;GPU').split(';')
3 changes: 2 additions & 1 deletion tests/model_hub_tests/torch_tests/test_torchvision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class TestTorchHubConvertModel(TestConvertModel):
def setup_class(self):
self.cache_dir = tempfile.TemporaryDirectory()
# set temp dir for torch cache
torch.hub.set_dir(str(self.cache_dir.name))
if os.environ.get('USE_SYSTEM_CACHE', 'True') == 'False':
torch.hub.set_dir(str(self.cache_dir.name))

def load_model(self, model_name, model_link):
m = torch.hub.load("pytorch/vision", model_name,
Expand Down

0 comments on commit 369831c

Please sign in to comment.