Download code/conftest.py from changh95/rdt2-base-p150: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/changh95/rdt2-base-p150/resolve/main/code/conftest.py
- Command line
-
hf download hf://changh95/rdt2-base-p150/code/conftest.py
-
curl -L -o conftest.py https://huggingface.co/changh95/rdt2-base-p150/resolve/main/code/conftest.py
1.68 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| """pytest root of rdt2-base-p150 (no dependency on tt-metal's own conftest). | |
| - Tests marked ``device`` need the chip: they are skipped when ttnn is missing or ``TT_VISIBLE_DEVICES=none`` | |
| (host-only runs). They open the device themselves (ETH dispatch by default; ``RDT2_DISPATCH=worker`` is the A/B); | |
| on a shared box run them through a device lock and name the test file, e.g. | |
| ``python -m pytest -q -s code/tt_rdt2/tests/test_e2e_device.py``. | |
| - Host tests run anywhere (``TT_VISIBLE_DEVICES=none``); in the development workspace they run on a fake ttnn | |
| (``-p fake_ttnn_plugin``). Missing weights / golden data skip, never fail. | |
| """ | |
| from __future__ import annotations | |
| import gc | |
| import importlib.util | |
| import os | |
| import sys | |
| import pytest | |
| _HERE = os.path.dirname(os.path.abspath(__file__)) | |
| if _HERE not in sys.path: # make ``tt_rdt2`` importable when pytest is started from the repo root | |
| sys.path.insert(0, _HERE) | |
| 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() | |