Skip to content

Commit cbc7e09

Browse files
ADD_109
1 parent 5adc607 commit cbc7e09

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

test/conftest.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import numpy as np
1010

11+
import openml
12+
1113
import pandas as pd
1214

1315
import pytest
@@ -23,6 +25,55 @@
2325
from autoPyTorch.utils.pipeline import get_dataset_requirements
2426

2527

28+
@pytest.fixture(scope="session", autouse=True)
29+
def callattr_ahead_of_alltests(request):
30+
"""
31+
This procedure will run at the start of the pytest session.
32+
It will prefetch several task that are going to be used by
33+
the testing face, and it does so in a robust way, until the openml
34+
API provides the desired resources
35+
"""
36+
start_time = time.time()
37+
38+
tasks_used = [
39+
146818, # Australian
40+
2295, # cholesterol
41+
2075, # abalone
42+
2071, # adult
43+
3, # kr-vs-kp
44+
9981, # cnae-9
45+
146821, # car
46+
146822, # Segment
47+
2, # anneal
48+
53, # vehicle
49+
5136, # tecator
50+
4871, # sensory
51+
4857, # boston
52+
3916, # kc1
53+
]
54+
55+
# Try to populate the tests 5 times
56+
patience = 5
57+
for i in range(patience):
58+
try:
59+
# Populate the cache
60+
openml.populate_cache(task_ids=tasks_used)
61+
# Also the bunch
62+
for task in tasks_used:
63+
fetch_openml(data_id=openml.tasks.get_task(task).dataset_id,
64+
return_X_y=True)
65+
break
66+
except Exception as e:
67+
if i == patience - 1:
68+
print("Failed to preload openml dataset for testing after {} iters.".format(
69+
patience
70+
))
71+
raise e
72+
73+
print(f"Pre-Fetch of {len(tasks_used)} tasks took {time.time() - start_time} seconds...")
74+
return
75+
76+
2677
def slugify(text):
2778
return re.sub(r'[\[\]]+', '-', text.lower())
2879

0 commit comments

Comments
 (0)