Skip to content

Commit bc25db8

Browse files
committed
added fake cache, added unit test, fixed cache location
1 parent fcfa7d9 commit bc25db8

5 files changed

Lines changed: 1131 additions & 7 deletions

File tree

openml/runs/functions.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ def obtain_field(xml_obj, fieldname, from_server, cast=None):
699699
else:
700700
task_evaluation_measure = None
701701

702-
703702
flow_id = int(run['oml:flow_id'])
704703
flow_name = obtain_field(run, 'oml:flow_name', from_server)
705704
setup_id = obtain_field(run, 'oml:setup_id', from_server, cast=int)
@@ -714,7 +713,7 @@ def obtain_field(xml_obj, fieldname, from_server, cast=None):
714713
parameters[key] = value
715714

716715
if 'oml:input_data' in run:
717-
dataset_id = int(run['oml:input_data']['oml:dataset']['oml:did'])
716+
dataset_id = int(run['oml:input_data']['oml:dataset'][0]['oml:did'])
718717
elif not from_server:
719718
dataset_id = None
720719

@@ -877,10 +876,9 @@ def _create_trace_from_arff(arff_obj):
877876
def _get_cached_run(run_id):
878877
"""Load a run from the cache."""
879878
cache_dir = config.get_cache_directory()
880-
run_cache_dir = os.path.join(cache_dir, "runs")
879+
run_cache_dir = os.path.join(cache_dir, "runs", str(run_id))
881880
try:
882-
run_file = os.path.join(run_cache_dir,
883-
"run_%d.xml" % int(run_id))
881+
run_file = os.path.join(run_cache_dir, "description.xml")
884882
with io.open(run_file, encoding='utf8') as fh:
885883
run = _create_run_from_xml(xml=fh.read())
886884
return run

openml/setups/functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def setup_exists(flow, model=None):
6060
def _get_cached_setup(setup_id):
6161
"""Load a run from the cache."""
6262
cache_dir = config.get_cache_directory()
63-
setup_cache_dir = os.path.join(cache_dir, "setups")
63+
setup_cache_dir = os.path.join(cache_dir, "setups", str(setup_id))
6464
try:
65-
setup_file = os.path.join(setup_cache_dir, "setup_%d.xml" % int(setup_id))
65+
setup_file = os.path.join(setup_cache_dir, "description.xml" % int(setup_id))
6666
with io.open(setup_file, encoding='utf8') as fh:
6767
setup_xml = xmltodict.parse(fh.read())
6868
setup = _create_setup_from_xml(setup_xml)

tests/files/runs/1/description.xml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<oml:run xmlns:oml="http://openml.org/openml">
2+
<oml:run_id>1</oml:run_id>
3+
<oml:uploader>1</oml:uploader>
4+
<oml:uploader_name>Jan van Rijn</oml:uploader_name>
5+
<oml:task_id>68</oml:task_id>
6+
<oml:task_type>Learning Curve</oml:task_type>
7+
<oml:task_evaluation_measure>predictive_accuracy</oml:task_evaluation_measure>
8+
<oml:flow_id>61</oml:flow_id>
9+
<oml:flow_name>weka.REPTree(1)</oml:flow_name>
10+
<oml:setup_id>6</oml:setup_id>
11+
<oml:error></oml:error> <oml:setup_string>weka.classifiers.trees.REPTree -- -M 2 -V 0.001 -N 3 -S 1 -L -1 -I 0.0</oml:setup_string>
12+
<oml:parameter_setting>
13+
<oml:name>I</oml:name>
14+
<oml:value>0.0</oml:value>
15+
</oml:parameter_setting>
16+
<oml:parameter_setting>
17+
<oml:name>L</oml:name>
18+
<oml:value>-1</oml:value>
19+
</oml:parameter_setting>
20+
<oml:parameter_setting>
21+
<oml:name>M</oml:name>
22+
<oml:value>2</oml:value>
23+
</oml:parameter_setting>
24+
<oml:parameter_setting>
25+
<oml:name>N</oml:name>
26+
<oml:value>3</oml:value>
27+
</oml:parameter_setting>
28+
<oml:parameter_setting>
29+
<oml:name>S</oml:name>
30+
<oml:value>1</oml:value>
31+
</oml:parameter_setting>
32+
<oml:parameter_setting>
33+
<oml:name>V</oml:name>
34+
<oml:value>0.001</oml:value>
35+
</oml:parameter_setting>
36+
<oml:tag>curves</oml:tag>
37+
<oml:tag>test_base_tagOMLObject_2</oml:tag>
38+
<oml:tag>weka</oml:tag>
39+
<oml:tag>weka_3.7.12-SNAPSHOT</oml:tag>
40+
<oml:input_data>
41+
<oml:dataset>
42+
<oml:did>2</oml:did>
43+
<oml:name>anneal</oml:name>
44+
<oml:url>https://www.openml.org/data/download/1666876/phpFsFYVN</oml:url>
45+
</oml:dataset>
46+
<oml:dataset>
47+
<oml:did>9</oml:did>
48+
<oml:name>autos</oml:name>
49+
<oml:url>https://www.openml.org/data/download/9/dataset_9_autos.arff</oml:url>
50+
</oml:dataset>
51+
<oml:dataset>
52+
<oml:did>54</oml:did>
53+
<oml:name>vehicle</oml:name>
54+
<oml:url>https://www.openml.org/data/download/54/dataset_54_vehicle.arff</oml:url>
55+
</oml:dataset>
56+
</oml:input_data>
57+
<oml:output_data>
58+
<oml:file>
59+
<oml:did>-1</oml:did> <!-- Deprecated field, will be removed during next upgrade. -->
60+
<oml:file_id>63</oml:file_id>
61+
<oml:name>description</oml:name>
62+
<oml:url>https://www.openml.org/data/download/63/weka_generated_run5258986433356798974.xml</oml:url>
63+
</oml:file>
64+
<oml:file>
65+
<oml:did>-1</oml:did> <!-- Deprecated field, will be removed during next upgrade. -->
66+
<oml:file_id>313413</oml:file_id>
67+
<oml:name>model_readable</oml:name>
68+
<oml:url>https://www.openml.org/data/download/313413/WekaModel_weka.classifiers.bayes.AveragedNDependenceEstimators.A1DE2474025000319897700.model</oml:url>
69+
</oml:file>
70+
<oml:file>
71+
<oml:did>-1</oml:did> <!-- Deprecated field, will be removed during next upgrade. -->
72+
<oml:file_id>622143</oml:file_id>
73+
<oml:name>model_serialized</oml:name>
74+
<oml:url>https://www.openml.org/data/download/622143/WekaSerialized_weka.classifiers.bayes.AveragedNDependenceEstimators.A1DE3739675682024987582.model</oml:url>
75+
</oml:file>
76+
<oml:file>
77+
<oml:did>-1</oml:did> <!-- Deprecated field, will be removed during next upgrade. -->
78+
<oml:file_id>64</oml:file_id>
79+
<oml:name>predictions</oml:name>
80+
<oml:url>https://www.openml.org/data/download/64/weka_generated_predictions5823074444642592781.arff</oml:url>
81+
</oml:file>
82+
<oml:evaluation>
83+
<oml:name>area_under_roc_curve</oml:name>
84+
<oml:value>0.839359</oml:value> <oml:array_data>[0.0,0.99113,0.898048,0.874862,0.791282,0.807343,0.820674]</oml:array_data> </oml:evaluation>
85+
<oml:evaluation>
86+
<oml:name>average_cost</oml:name>
87+
<oml:value>0</oml:value> </oml:evaluation>
88+
<oml:evaluation>
89+
<oml:name>f_measure</oml:name>
90+
<oml:value>0.600026</oml:value> <oml:array_data>[0,0,0.711934,0.735714,0.601363,0.435678,0.430913]</oml:array_data> </oml:evaluation>
91+
<oml:evaluation>
92+
<oml:name>kappa</oml:name>
93+
<oml:value>0.491678</oml:value> </oml:evaluation>
94+
<oml:evaluation>
95+
<oml:name>kb_relative_information_score</oml:name>
96+
<oml:value>1063.298606</oml:value> </oml:evaluation>
97+
<oml:evaluation>
98+
<oml:name>mean_absolute_error</oml:name>
99+
<oml:value>0.127077</oml:value> </oml:evaluation>
100+
<oml:evaluation>
101+
<oml:name>mean_prior_absolute_error</oml:name>
102+
<oml:value>0.220919</oml:value> </oml:evaluation>
103+
<oml:evaluation>
104+
<oml:name>number_of_instances</oml:name>
105+
<oml:value>2050</oml:value> <oml:array_data>[0,30,220,670,540,320,270]</oml:array_data> </oml:evaluation>
106+
<oml:evaluation>
107+
<oml:name>os_information</oml:name>
108+
<oml:array_data>[ Oracle Corporation, 1.7.0_51, amd64, Linux, 3.7.10-1.28-desktop ]</oml:array_data> </oml:evaluation>
109+
<oml:evaluation>
110+
<oml:name>precision</oml:name>
111+
<oml:value>0.599589</oml:value> <oml:array_data>[0,0,0.650376,0.705479,0.556782,0.48289,0.585987]</oml:array_data> </oml:evaluation>
112+
<oml:evaluation>
113+
<oml:name>predictive_accuracy</oml:name>
114+
<oml:value>0.614634</oml:value> </oml:evaluation>
115+
<oml:evaluation>
116+
<oml:name>prior_entropy</oml:name>
117+
<oml:value>2.326811</oml:value> </oml:evaluation>
118+
<oml:evaluation>
119+
<oml:name>recall</oml:name>
120+
<oml:value>0.614634</oml:value> <oml:array_data>[0,0,0.786364,0.768657,0.653704,0.396875,0.340741]</oml:array_data> </oml:evaluation>
121+
<oml:evaluation>
122+
<oml:name>relative_absolute_error</oml:name>
123+
<oml:value>0.575218</oml:value> </oml:evaluation>
124+
<oml:evaluation>
125+
<oml:name>root_mean_prior_squared_error</oml:name>
126+
<oml:value>0.331758</oml:value> </oml:evaluation>
127+
<oml:evaluation>
128+
<oml:name>root_mean_squared_error</oml:name>
129+
<oml:value>0.280656</oml:value> </oml:evaluation>
130+
<oml:evaluation>
131+
<oml:name>root_relative_squared_error</oml:name>
132+
<oml:value>0.845964</oml:value> </oml:evaluation>
133+
<oml:evaluation>
134+
<oml:name>scimark_benchmark</oml:name>
135+
<oml:value>1973.4091512218106</oml:value> <oml:array_data>[ 1262.1133708514062, 1630.9393838458018, 932.0675956790141, 1719.5408190761134, 4322.384586656718 ]</oml:array_data> </oml:evaluation>
136+
<oml:evaluation>
137+
<oml:name>total_cost</oml:name>
138+
<oml:value>0</oml:value> </oml:evaluation>
139+
</oml:output_data>
140+
</oml:run>

0 commit comments

Comments
 (0)