Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation of datasets without metadata #342

Merged
merged 5 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/beatles_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3961,6 +3961,5 @@
"5567706d5daaea876d3dee1792ac3195"
]
}
},
"metadata": null
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/beatport_key_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -20805,6 +20805,5 @@
"60c90e1129bdebcf1de40bed59897fd0"
]
}
},
"metadata": null
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/giantsteps_key_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -8401,6 +8401,5 @@
"dcc6f1137df57c614e3f272a9d3480a3"
]
}
},
"metadata": null
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/giantsteps_tempo_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -9297,6 +9297,5 @@
"ee57fa94541b682b80167964a2e4c54f"
]
}
},
"metadata": null
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/gtzan_genre_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6001,6 +6001,5 @@
"1af32d4de97623717afcc6746301afd0"
]
}
},
"metadata": null
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/guitarset_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -7921,6 +7921,5 @@
"d699dae486611205efbb070086c786fe"
]
}
},
"metadata": null
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/irmas_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -95341,6 +95341,5 @@
"4bd0f05ee752e758ab98bc06b2f4e91d"
]
}
},
"metadata": null
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/mridangam_stroke_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -41857,6 +41857,5 @@
"b88aca5399bb1d9fc34d15e67ba83399"
]
}
},
"metadata": null
}
}
2 changes: 1 addition & 1 deletion mirdata/datasets/indexes/rwc_classical_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@
"metadata": {
"rwc-c": [
"metadata-master/rwc-c.csv",
"7dbe87fedbaaa1f348625a2af1d78030"
"9a9a09178017d69bc13eed87b9e089ab"
]
}
}
2 changes: 1 addition & 1 deletion mirdata/datasets/indexes/rwc_jazz_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@
"metadata": {
"rwc-j": [
"metadata-master/rwc-j.csv",
"7dbe87fedbaaa1f348625a2af1d78030"
"7850791b1833b1e4943bb47989d20d55"
]
}
}
2 changes: 1 addition & 1 deletion mirdata/datasets/indexes/rwc_popular_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@
"metadata": {
"rwc-p": [
"metadata-master/rwc-p.csv",
"7dbe87fedbaaa1f348625a2af1d78030"
"2311ffa9c150bdc83575f581e1ad8bc2"
]
}
}
3 changes: 1 addition & 2 deletions mirdata/datasets/indexes/saraga_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -11591,6 +11591,5 @@
"dbc34dd75c6118f2df09900fa8f094c5"
]
}
},
"metadata": null
}
}
7 changes: 3 additions & 4 deletions mirdata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def check_metadata(file_dict, data_home, verbose):
missing = {}
invalid = {}
for file_id, file in tqdm.tqdm(file_dict.items(), disable=not verbose):
print(file_id, file)
filepath = file[0]
checksum = file[1]
if filepath is not None:
Expand Down Expand Up @@ -141,7 +140,7 @@ def check_index(dataset_index, data_home, verbose=True):
invalid_checksums = {}

# check index
if dataset_index['metadata'] is not None:
if 'metadata' in dataset_index and dataset_index['metadata'] is not None:
missing_metadata, invalid_metadata = check_metadata(
dataset_index['metadata'],
data_home,
Expand All @@ -150,7 +149,7 @@ def check_index(dataset_index, data_home, verbose=True):
missing_files['metadata'] = missing_metadata
invalid_checksums['metadata'] = invalid_metadata

if 'tracks' in dataset_index:
if 'tracks' in dataset_index and dataset_index['tracks'] is not None:
missing_tracks, invalid_tracks = check_files(
dataset_index['tracks'],
data_home,
Expand All @@ -159,7 +158,7 @@ def check_index(dataset_index, data_home, verbose=True):
missing_files['tracks'] = missing_tracks
invalid_checksums['tracks'] = invalid_tracks

if 'multitracks' in dataset_index:
if 'multitracks' in dataset_index and dataset_index['multitracks'] is not None:
missing_multitracks, invalid_multitracks = check_files(
dataset_index['multitracks'],
data_home,
Expand Down
8 changes: 5 additions & 3 deletions scripts/update_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ def update_index(all_indexes):
# The computation of the checksum should be customized in the make_index
# of each dataset. This is a patch to convert previous indexes to the new format.
new_index = {'version': version,
'tracks': old_index,
'metadata': metadata_checksums}
'tracks': old_index}

if metadata_files is not None:
new_index['metadata'] = metadata_checksums

with open(os.path.join(INDEXES_PATH, index_name), 'w') as fhandle:
json.dump(new_index, fhandle, indent=2)
Expand All @@ -162,7 +164,7 @@ def test_index(dataset_names):

"""

mandatory_keys = ['metadata', 'version']
mandatory_keys = ['version']
for module in dataset_names:
index = mirdata.Dataset(module)._index
assert type(index['tracks']) == dict
Expand Down