You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ir_datasets/lazy_libs.py
+35-11Lines changed: 35 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -25,14 +25,20 @@ def requests():
25
25
26
26
defbs4():
27
27
if'bs4'notin_cache:
28
-
importbs4
28
+
try:
29
+
importbs4
30
+
exceptImportErrorasie:
31
+
raiseImportError("This dataset requires beautifulsoup4. Run 'pip install ir_datasets[beautifulsoup4]' to install dependencies for this dataset") fromie
29
32
_cache['bs4'] =bs4
30
33
return_cache['bs4']
31
34
32
35
33
36
definscriptis():
34
37
if'inscriptis'notin_cache:
35
-
importinscriptis
38
+
try:
39
+
importinscriptis
40
+
exceptImportErrorasie:
41
+
raiseImportError("This dataset requires inscriptis. Run 'pip install ir_datasets[inscriptis]' to install dependencies for this dataset") fromie
36
42
_cache['inscriptis'] =inscriptis
37
43
return_cache['inscriptis']
38
44
@@ -53,19 +59,28 @@ def json():
53
59
54
60
deftrec_car():
55
61
if'trec_car'notin_cache:
56
-
importtrec_car.read_data
62
+
try:
63
+
importtrec_car.read_data
64
+
exceptImportErrorasie:
65
+
raiseImportError("This dataset requires trec-car-tools. Run 'pip install ir_datasets[car]' to install dependencies for this dataset") fromie
57
66
_cache['trec_car'] =trec_car
58
67
return_cache['trec_car']
59
68
60
69
defwarc():
61
70
if'warc'notin_cache:
62
-
importwarc
71
+
try:
72
+
importwarc
73
+
exceptImportErrorasie:
74
+
raiseImportError("This dataset requires warc. Run 'pip install ir_datasets[warc]' to install dependencies for this dataset") fromie
63
75
_cache['warc'] =warc
64
76
return_cache['warc']
65
77
66
78
defwarc_clueweb09():
67
79
if'warc_clueweb09'notin_cache:
68
-
importwarc3_wet_clueweb09
80
+
try:
81
+
importwarc3_wet_clueweb09
82
+
exceptImportErrorasie:
83
+
raiseImportError("This dataset requires warc. Run 'pip install ir_datasets[warc]' to install dependencies for this dataset") fromie
69
84
_cache['warc_clueweb09'] =warc3_wet_clueweb09
70
85
return_cache['warc_clueweb09']
71
86
@@ -83,7 +98,10 @@ def lz4_frame():
83
98
84
99
defzlib_state():
85
100
if'zlib_state'notin_cache:
86
-
importzlib_state
101
+
try:
102
+
importzlib_state
103
+
exceptImportErrorasie:
104
+
raiseImportError("This dataset requires zlib-state. Run 'pip install ir_datasets[zlib-state]' to install dependencies for this dataset") fromie
87
105
_cache['zlib_state'] =zlib_state
88
106
return_cache['zlib_state']
89
107
@@ -101,7 +119,10 @@ def lxml_html():
101
119
102
120
defijson():
103
121
if'ijson'notin_cache:
104
-
importijson
122
+
try:
123
+
importijson
124
+
exceptImportErrorasie:
125
+
raiseImportError("This dataset requires ijson. Run 'pip install ir_datasets[ijson]' to install dependencies for this dataset") fromie
105
126
_cache['ijson'] =ijson
106
127
return_cache['ijson']
107
128
@@ -110,21 +131,24 @@ def pyautocorpus():
110
131
try:
111
132
importpyautocorpus
112
133
exceptImportErrorasie:
113
-
raiseImportError("This dataset requires pyautocorpus. Run 'pip install pyautocorpus'") fromie
134
+
raiseImportError("This dataset requires pyautocorpus. Run 'pip install ir_datasets[pyautocorpus]' to install dependencies for this dataset") fromie
114
135
_cache['pyautocorpus'] =pyautocorpus
115
136
return_cache['pyautocorpus']
116
137
117
138
defunlzw3():
118
139
if'unlzw3'notin_cache:
119
-
importunlzw3
140
+
try:
141
+
importunlzw3
142
+
exceptImportErrorasex:
143
+
raiseImportError("This dataset requires unlzw3. Run 'pip install ir_datasets[unlzw3]' to install dependencies for this dataset") fromex
120
144
_cache['unlzw3'] =unlzw3
121
145
return_cache['unlzw3']
122
146
123
147
defpyarrow_parquet():
124
148
if'pyarrow_parquet'notin_cache:
125
149
try:
126
150
importpyarrow.parquet
127
-
exceptImportErrorasex:
128
-
raiseImportError("This dataset requires pyarrow. Run 'pip install pyarrow>=16.1.0'") fromex
151
+
exceptImportErrorasie:
152
+
raiseImportError("This dataset requires pyarrow. Run 'pip install ir_datasets[pyarrow]' to install dependencies for this dataset") fromie
0 commit comments