Download scripts/add_version_to_metadata.py from jzgdev/medleydb_sample: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/jzgdev/medleydb_sample/resolve/main/scripts/add_version_to_metadata.py
- Command line
-
hf download hf://datasets/jzgdev/medleydb_sample/scripts/add_version_to_metadata.py
-
curl -L -o add_version_to_metadata.py https://huggingface.co/datasets/jzgdev/medleydb_sample/resolve/main/scripts/add_version_to_metadata.py
1.04 kB
| """If metadata doesn't have version information, adds it | |
| """ | |
| from __future__ import print_function | |
| import glob | |
| import os | |
| import yaml | |
| from medleydb import METADATA_PATH | |
| def add_version(fpath): | |
| with open(fpath, 'r') as fhandle: | |
| data = yaml.load(fhandle) | |
| if 'version' not in data.keys(): | |
| data['version'] = 1.2 | |
| with open(fpath, 'w') as fhandle: | |
| yaml.dump(data, fhandle, indent=2, default_flow_style=False) | |
| def remove_release_date(fpath): | |
| with open(fpath, 'r') as fhandle: | |
| data = yaml.load(fhandle) | |
| if 'release date' in data.keys(): | |
| data.pop('release date', None) | |
| with open(fpath, 'w') as fhandle: | |
| yaml.dump(data, fhandle, indent=2, default_flow_style=False) | |
| def main(): | |
| """Loops over all metadata files and adds version information | |
| """ | |
| metadata_files = glob.glob(os.path.join(METADATA_PATH, '*.yaml')) | |
| for fpath in metadata_files: | |
| add_version(fpath) | |
| remove_release_date(fpath) | |
| if __name__ == "__main__": | |
| main() | |