Repository: mir-dataset-loaders/mirdata

Issue:
utils.validator is undocumented
See: https://github.com/mir-dataset-loaders/mirdata/blob/master/mirdata/utils.py#L106

This is already a to-do in the code, but i figured it deserved its own issue number.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/mir-dataset-loaders/mirdata/pull/170?src=pr&el=h1) Report
> Merging [#170](https://codecov.io/gh/mir-dataset-loaders/mirdata/pull/170?src=pr&el=desc) into [master](https://codecov.io/gh/mir-dataset-loaders/mirdata/commit/19f00606c820f4b7d83da97109584f8687f2665e&el=desc) will **decrease** coverage by `0.15%`.
> The diff coverage is `n/a`.


```diff
@@            Coverage Diff             @@
##           master     #170      +/-   ##
==========================================
- Coverage   98.37%   98.21%   -0.16%     
==========================================
  Files          17       17              
  Lines        1843     1850       +7     
==========================================
+ Hits         1813     1817       +4     
- Misses         30       33       +3     
```

lostanlen: Done. This passes tests and has 100% diff hit.
I think this is ready for CR.

Patch:
diff --git a/mirdata/utils.py b/mirdata/utils.py
index 009c776..36053df 100644
--- a/mirdata/utils.py
+++ b/mirdata/utils.py
@@ -62,13 +62,12 @@ def log_message(message, silence=False):
         print(message)
 
 
-def check_index(dataset_index, data_home, silence=False):
+def check_index(dataset_index, data_home):
     """check index to find out missing files and files with invalid checksum
 
     Args:
         dataset_index (list): dataset indices
         data_home (str): Local home path that the dataset is being stored
-        silence (bool)
 
     Returns:
         missing_files (list): List of file paths that are in the dataset index
@@ -103,24 +102,48 @@ def check_index(dataset_index, data_home, silence=False):
 
 
 def validator(dataset_index, data_home, silence=False):
-    """validate.. (todo: what does it do?) """
-    missing_files, invalid_checksums = check_index(dataset_index, data_home, silence)
+    """Checks the existence and validity of files stored locally with
+    respect to the paths and file checksums stored in the reference index.
+    Logs invalid checksums and missing files.
+
+    Args:
+        dataset_index (list): dataset indices
+        data_home (str): Local home path that the dataset is being stored
+        silence (bool): if False (default), prints missing and invalid files
+        to stdout. Otherwise, this function is equivalent to check_index.
+
+    Returns:
+        missing_files (list): List of file paths that are in the dataset index
+            but missing locally.
+        invalid_checksums (list): List of file paths that file exists in the
+            dataset index but has a different checksum compare to the reference
+            checksum.
+    """
+    missing_files, invalid_checksums = check_index(dataset_index, data_home)
 
     # print path of any missing files
+    has_any_missing_file = False
     for track_id in missing_files.keys():
         if len(missing_files[track_id]) > 0:
             log_message('Files missing for {}:'.format(track_id), silence)
             for fpath in missing_files[track_id]:
                 log_message(fpath, silence)
             log_message('-' * 20, silence)
+            has_any_missing_file = True
 
     # print path of any invalid checksums
+    has_any_invalid_checksum = False
     for track_id in invalid_checksums.keys():
         if len(invalid_checksums[track_id]) > 0:
             log_message('Invalid checksums for {}:'.format(track_id), silence)
             for fpath in invalid_checksums[track_id]:
                 log_message(fpath, silence)
             log_message('-' * 20, silence)
+            has_any_invalid_checksum = True
+
+    if not (has_any_missing_file or has_any_invalid_checksum):
+        log_message('Success: the dataset is complete and all files are valid.', silence)
+        log_message('-' * 20, silence)
 
     return missing_files, invalid_checksums
 
diff --git a/setup.py b/setup.py
index da02dc4..0acd6a7 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
 if __name__ == '__main__':
     setup(
         name='mirdata',
-        version='0.1.1',
+        version='0.1.2',
         description='Common loaders for MIR datasets.',
         url='https://github.com/mir-dataset-loaders/mirdata',
         packages=find_packages(exclude=['test', '*.test', '*.test.*']),


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index f1761d2..ebc82cb 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -67,8 +67,7 @@ def test_check_index(test_index, expected_missing, expected_inv_checksum):
         test_index = json.load(index_file)
 
     missing_files, invalid_checksums = utils.check_index(
-        test_index, 'tests/resources/', True
-    )
+        test_index, 'tests/resources/')
 
     assert expected_missing == missing_files
     assert expected_inv_checksum == invalid_checksums
@@ -79,6 +78,7 @@ def test_check_index(test_index, expected_missing, expected_inv_checksum):
     [
         ({'10161_chorus': ['tests/resources/10162_chorus.wav']}, {}),
         ({}, {'10161_chorus': ['tests/resources/10161_chorus.wav']}),
+        ({}, {}),
     ],
 )
 def test_validator(mocker, mock_check_index, missing_files, invalid_checksums):
@@ -87,12 +87,7 @@ def test_validator(mocker, mock_check_index, missing_files, invalid_checksums):
     m, c = utils.validator('foo', 'bar', True)
     assert m == missing_files
     assert c == invalid_checksums
-    mock_check_index.assert_called_once_with('foo', 'bar', True)
-
-    # if missing_files or invalid_checksums:
-    #     mock_create_invalid.assert_called_once_with(missing_files, invalid_checksums)
-    # else:
-    #     mock_create_validated.assert_called_once_with('baz')
+    mock_check_index.assert_called_once_with('foo', 'bar')
 
 
 def test_get_default_dataset_path():