Skip to content

Commit 55ec853

Browse files
authored
Merge pull request #112 from franchuterivera/refactor_development_ADD_109
Pre fetch openml data for pytest
2 parents ffc1620 + 1602933 commit 55ec853

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"codecov",
4848
"pep8",
4949
"mypy",
50+
"openml"
5051
],
5152
"examples": [
5253
"matplotlib",

test/conftest.py

Lines changed: 38 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,42 @@
2325
from autoPyTorch.utils.pipeline import get_dataset_requirements
2426

2527

28+
@pytest.fixture(scope="session")
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+
tasks_used = [
37+
146818, # Australian
38+
2295, # cholesterol
39+
2075, # abalone
40+
2071, # adult
41+
3, # kr-vs-kp
42+
9981, # cnae-9
43+
146821, # car
44+
146822, # Segment
45+
2, # anneal
46+
53, # vehicle
47+
5136, # tecator
48+
4871, # sensory
49+
4857, # boston
50+
3916, # kc1
51+
]
52+
53+
# Populate the cache
54+
# This will make the test fail immediately rather than
55+
# Waiting for a openml fetch timeout
56+
openml.populate_cache(task_ids=tasks_used)
57+
# Also the bunch
58+
for task in tasks_used:
59+
fetch_openml(data_id=openml.tasks.get_task(task).dataset_id,
60+
return_X_y=True)
61+
return
62+
63+
2664
def slugify(text):
2765
return re.sub(r'[\[\]]+', '-', text.lower())
2866

0 commit comments

Comments
 (0)