Download code/conftest.py from changh95/all-MiniLM-L6-v2: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/changh95/all-MiniLM-L6-v2/resolve/main/code/conftest.py
- Command line
-
hf download hf://changh95/all-MiniLM-L6-v2/code/conftest.py
-
curl -L -o conftest.py https://huggingface.co/changh95/all-MiniLM-L6-v2/resolve/main/code/conftest.py
1.65 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| """pytest settings of all-MiniLM-L6-v2 (no dependency on tt-metal's own conftest). | |
| - Tests marked ``device`` are skipped when ttnn is missing or ``TT_VISIBLE_DEVICES=none`` (host-only runs). On the | |
| shared workspace box run device tests through the lock and name the test file: | |
| ``bin/devrun -t 1200 --reset-on-timeout -- python -m pytest -q -s code/tt_minilm/tests/test_device_engines.py``. | |
| - Host tests (``tests/test_host_*.py``) never import ttnn or open a device: | |
| ``TT_VISIBLE_DEVICES=none python -m pytest -q code/tt_minilm/tests/test_host_*.py``. | |
| """ | |
| from __future__ import annotations | |
| import gc | |
| import importlib.util | |
| import os | |
| import pytest | |
| def pytest_addoption(parser): | |
| try: | |
| parser.addoption("--device-id", action="store", default=None, help="chip id (default $TT_DEVICE_ID or 0)") | |
| except ValueError: # already registered by another conftest | |
| pass | |
| def pytest_configure(config): | |
| config.addinivalue_line("markers", "device: needs a Tenstorrent chip (skipped on host-only runs)") | |
| def _no_device_reason(): | |
| if os.environ.get("TT_VISIBLE_DEVICES", "").lower() == "none": | |
| return "TT_VISIBLE_DEVICES=none (host-only run)" | |
| if importlib.util.find_spec("ttnn") is None: | |
| return "ttnn is not installed" | |
| return None | |
| def pytest_collection_modifyitems(config, items): | |
| reason = _no_device_reason() | |
| if reason: | |
| skip = pytest.mark.skip(reason=reason) | |
| for item in items: | |
| if "device" in item.keywords: | |
| item.add_marker(skip) | |
| def _gc_between_tests(): | |
| gc.collect() | |