Skip to content

Commit

Permalink
More fixes for local schema caching/testing
Browse files Browse the repository at this point in the history
  • Loading branch information
IanCa committed Jul 26, 2024
1 parent 97f29bc commit 4f62c4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
10 changes: 3 additions & 7 deletions hed/schema/hed_schema_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,16 @@ def _load_schema_version_sub(xml_version, schema_namespace="", xml_folder=None,
f"Must specify a schema version by number, found no version on {xml_version} schema.",
filename=name)
try:
# 1. Try fully local copy
# 1. Try fully local(or from direct cache)
final_hed_xml_file = hed_cache.get_hed_version_path(xml_version, library_name, xml_folder)
if not final_hed_xml_file:
hed_cache.cache_local_versions(xml_folder)
# 2. Cache the schemas included in hedtools and try local again
final_hed_xml_file = hed_cache.get_hed_version_path(xml_version, library_name, xml_folder)
hed_schema = load_schema(final_hed_xml_file, schema=schema, name=name)
except HedFileError as e:
if e.code == HedExceptions.FILE_NOT_FOUND:
# Cache all schemas if we haven't recently.
hed_cache.cache_xml_versions(cache_folder=xml_folder)
# 3. See if we got a copy from online
# 2. See if we got a copy from online
final_hed_xml_file = hed_cache.get_hed_version_path(xml_version, library_name, xml_folder)
# 4. Finally check for a pre-release one
# 3. Finally check for a pre-release one
if not final_hed_xml_file:
final_hed_xml_file = hed_cache.get_hed_version_path(xml_version, library_name, xml_folder,
check_prerelease=True)
Expand Down
3 changes: 0 additions & 3 deletions spec_tests/test_hed_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ def tearDownClass(cls):
schema.set_cache_directory(cls.saved_cache_folder)

def test_local_cache(self):
final_hed_xml_file = hed_cache.get_hed_version_path("8.2.0", None, local_hed_directory=self.hed_cache_dir)
self.assertFalse(final_hed_xml_file)
hed_cache.cache_local_versions(self.hed_cache_dir)
final_hed_xml_file = hed_cache.get_hed_version_path("8.2.0", None, local_hed_directory=self.hed_cache_dir)
self.assertTrue(final_hed_xml_file)

Expand Down

0 comments on commit 4f62c4c

Please sign in to comment.