File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 88
99import numpy as np
1010
11+ import openml
12+
1113import pandas as pd
1214
1315import pytest
2325from 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+
2677def slugify (text ):
2778 return re .sub (r'[\[\]]+' , '-' , text .lower ())
2879
You can’t perform that action at this time.
0 commit comments