hed_cache¶
Infrastructure for caching HED schema from remote repositories.
Functions
|
Cache all schemas included with the HED installation. |
|
Cache all schemas at the given URLs. |
Return the current value of HED_CACHE_DIRECTORY. |
|
|
Get HED XML file path in a directory. |
|
Get the HED versions in the HED directory. |
|
Retrieve the library data for the given library. |
|
Set default global HED cache directory. |
- cache_local_versions(cache_folder)[source]¶
Cache all schemas included with the HED installation.
- Parameters:
cache_folder (str) – The folder holding the cache.
- Returns:
Returns -1 on cache access failure. None otherwise
- Return type:
int or None
- cache_xml_versions(hed_base_urls=('https://api.github.com/repos/hed-standard/hed-schemas/contents/standard_schema',), hed_library_urls=('https://api.github.com/repos/hed-standard/hed-schemas/contents/library_schemas',), skip_folders=('deprecated',), cache_folder=None)[source]¶
Cache all schemas at the given URLs.
- Parameters:
hed_base_urls (str or list) – Path or list of paths. These should point to a single folder.
hed_library_urls (str or list) – Path or list of paths. These should point to folder containing library folders.
skip_folders (list) – A list of subfolders to skip over when downloading.
cache_folder (str) – The folder holding the cache.
- Returns:
- Returns -1 if cache failed for any reason, including having been cached too recently.
Returns 0 if it successfully cached this time.
- Return type:
float
Notes
The Default skip_folders is ‘deprecated’.
The HED cache folder defaults to HED_CACHE_DIRECTORY.
- The directories on GitHub are of the form:
https://api.github.com/repos/hed-standard/hed-schemas/contents/standard_schema
- get_hed_version_path(xml_version, library_name=None, local_hed_directory=None, check_prerelease=False)[source]¶
Get HED XML file path in a directory. Only returns filenames that exist.
- Parameters:
library_name (str or None) – Optional the schema library name.
xml_version (str) – Returns this version if it exists
local_hed_directory (str) – Path to local HED directory. Defaults to HED_CACHE_DIRECTORY
check_prerelease (bool) – Also check for prerelease schemas
- Returns:
The path to the latest HED version the HED directory.
- Return type:
str
- get_hed_versions(local_hed_directory=None, library_name=None, check_prerelease=False)[source]¶
Get the HED versions in the HED directory.
- Parameters:
local_hed_directory (str) – Directory to check for versions which defaults to hed_cache.
library_name (str or None) – An optional schema library name. None retrieves the standard schema only. Pass “all” to retrieve all standard and library schemas as a dict.
check_prerelease (bool) – If True, results can include prerelease schemas
- Returns:
List of version numbers or dictionary {library_name: [versions]}.
- Return type:
list or dict
- get_library_data(library_name, cache_folder=None)[source]¶
Retrieve the library data for the given library.
Currently, this is just the valid ID range.
- Parameters:
library_name (str) – The schema name. “” for standard schema.
cache_folder (str) – The cache folder to use if not using the default.
- Returns:
The data for a specific library.
- Return type:
library_data(dict)