Skip to content

Commit 8726314

Browse files
committed
fix unit tests, changed directory structure to be consistent with other types
1 parent de999ad commit 8726314

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

openml/runs/functions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,13 @@ def get_run(run_id):
555555
run : OpenMLRun
556556
Run corresponding to ID, fetched from the server.
557557
"""
558-
run_file = os.path.join(config.get_cache_directory(), "runs",
559-
"run_%d.xml" % run_id)
558+
run_dir = config.get_cache_directory(), "runs", run_id
559+
run_file = os.path.join(run_dir, "description.xml")
560+
561+
try:
562+
os.makedirs(run_dir)
563+
except FileExistsError:
564+
pass
560565

561566
try:
562567
return _get_cached_run(run_id)

openml/setups/functions.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,20 @@ def get_setup(setup_id):
8787
OpenMLSetup
8888
an initialized openml setup object
8989
"""
90-
run_file = os.path.join(config.get_cache_directory(), "setups", "setup_%d.xml" % setup_id)
90+
setup_dir = config.get_cache_directory(), "runs", setup_id
91+
setup_file = os.path.join(setup_dir, "description.xml")
92+
93+
try:
94+
os.makedirs(setup_dir)
95+
except FileExistsError:
96+
pass
9197

9298
try:
9399
return _get_cached_setup(setup_id)
94100

95101
except (openml.exceptions.OpenMLCacheException):
96102
setup_xml = openml._api_calls._perform_api_call('/setup/%d' % setup_id)
97-
with io.open(run_file, "w", encoding='utf8') as fh:
103+
with io.open(setup_file, "w", encoding='utf8') as fh:
98104
fh.write(setup_xml)
99105

100106
result_dict = xmltodict.parse(setup_xml)

0 commit comments

Comments
 (0)