forked from graphcore/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
30 lines (23 loc) · 812 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
from pathlib import Path
from subprocess import run
import nltk
def rebuild_custom_ops():
"""The objective of this script is to:
1.) Delete the existing custom ops if it exists
2.) Perform the make command
3.) Validate a custom_ops.so now does exist"""
model_path = Path(__file__).resolve().parent
custom_ops_path = Path(model_path, "custom_ops.so")
if custom_ops_path.exists():
print(f"\nDeleting: {custom_ops_path}")
os.remove(custom_ops_path)
print("\nBuilding Custom Ops")
run(["make"], cwd=custom_ops_path.parent)
assert custom_ops_path.exists()
def get_nltk_data():
"""Gets the NLTK data using the NLTK python module."""
nltk.download("cmudict")
def pytest_sessionstart(session):
get_nltk_data()
rebuild_custom_ops()