From 9f5b20ed29adb33bb01358e934b6390a2213c920 Mon Sep 17 00:00:00 2001 From: Rachel Bittner Date: Tue, 28 Sep 2021 05:52:59 -0700 Subject: [PATCH] Deprecate Dataset.load_* (#528) * closes #526 --- docs/requirements.txt | 1 + docs/source/contributing.rst | 13 ------ docs/source/contributing_examples/example.py | 20 ++------ mirdata/annotations.py | 12 +++-- mirdata/core.py | 12 ----- mirdata/datasets/acousticbrainz_genre.py | 12 +++-- mirdata/datasets/beatles.py | 21 +++++++-- mirdata/datasets/beatport_key.py | 28 ++++++++--- mirdata/datasets/billboard.py | 21 +++++++-- mirdata/datasets/cante100.py | 21 +++++++-- .../datasets/compmusic_jingju_acappella.py | 24 +++++++--- mirdata/datasets/compmusic_otmm_makam.py | 15 ++++-- mirdata/datasets/da_tacos.py | 36 ++++++++++++--- mirdata/datasets/dagstuhl_choirset.py | 21 +++++++-- mirdata/datasets/dali.py | 16 +++++-- .../freesound_one_shot_percussive_sounds.py | 11 ++++- mirdata/datasets/giantsteps_key.py | 28 ++++++++--- mirdata/datasets/giantsteps_tempo.py | 19 ++++++-- mirdata/datasets/good_sounds.py | 6 ++- mirdata/datasets/groove_midi.py | 21 +++++++-- mirdata/datasets/gtzan_genre.py | 6 ++- mirdata/datasets/guitarset.py | 36 ++++++++++++--- mirdata/datasets/haydn_op20.py | 46 ++++++++++++++----- mirdata/datasets/ikala.py | 36 ++++++++++++--- mirdata/datasets/irmas.py | 11 ++++- mirdata/datasets/maestro.py | 16 +++++-- mirdata/datasets/medley_solos_db.py | 6 ++- mirdata/datasets/medleydb_melody.py | 16 +++++-- mirdata/datasets/medleydb_pitch.py | 16 +++++-- mirdata/datasets/mridangam_stroke.py | 6 ++- .../mtg_jamendo_autotagging_moodtheme.py | 6 ++- mirdata/datasets/orchset.py | 18 ++++++-- mirdata/datasets/phenicx_anechoic.py | 11 ++++- mirdata/datasets/queen.py | 21 +++++++-- mirdata/datasets/rwc_classical.py | 16 +++++-- mirdata/datasets/rwc_jazz.py | 16 +++++-- mirdata/datasets/rwc_popular.py | 26 +++++++++-- mirdata/datasets/salami.py | 11 ++++- mirdata/datasets/saraga_carnatic.py | 42 +++++++++++++---- mirdata/datasets/saraga_hindustani.py | 36 ++++++++++++--- mirdata/datasets/slakh.py | 21 +++++++-- mirdata/datasets/tinysol.py | 6 ++- mirdata/datasets/tonality_classicaldb.py | 26 +++++++++-- mirdata/datasets/tonas.py | 21 ++++++--- setup.py | 1 + tests/test_loaders.py | 18 ++------ tox.ini | 4 +- 47 files changed, 634 insertions(+), 219 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 76779caed..00231369f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -5,3 +5,4 @@ chardet librosa>=0.7.0 tqdm sphinx==3.4.0 +Deprecated>=1.2.13 \ No newline at end of file diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index e75333218..d2e872c51 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -768,13 +768,6 @@ the ``_track metadata`` for ``track_id=track2`` will be: } -Load methods vs Track properties --------------------------------- -Track properties and cached properties should be trivial, and directly call a ``load_*`` method. -There should be no additional logic in a track property/cached property, and instead all logic -should be done in the load method. We separate these because the track properties are only usable -when data is available locally - when data is remote, the load methods are used instead. - Missing Data ------------ If a Track has a property, for example a type of annotation, that is present for some tracks and not others, @@ -800,12 +793,6 @@ This decorator is used for children of the Dataset class, and copies the Attributes from the parent class to the docstring of the child. This gives us clear and complete docs without a lot of copy-paste. -copy_docs ---------- -This decorator is used mainly for a dataset's ``load_`` functions, which -are attached to a loader's Dataset class. The attached function is identical, -and this decorator simply copies the docstring from another function. - coerce_to_bytes_io/coerce_to_string_io -------------------------------------- These are two decorators used to simplify the loading of various ``Track`` members diff --git a/docs/source/contributing_examples/example.py b/docs/source/contributing_examples/example.py index 1425ea5d0..de4928adc 100644 --- a/docs/source/contributing_examples/example.py +++ b/docs/source/contributing_examples/example.py @@ -14,15 +14,15 @@ """ import csv -import logging import json import os from typing import BinaryIO, Optional, TextIO, Tuple -import librosa -import numpy as np # -- import whatever you need here and remove # -- example imports you won't use +import librosa +import numpy as np +from smart_open import open # if you use the open function, make sure you include this line! from mirdata import download_utils, jams_utils, core, annotations @@ -94,7 +94,8 @@ class Track(core.Track): track_id (str): track id of the track Attributes: - track_id (str): track id + audio_path (str): path to audio file + annotation_path (str): path to annotation file # -- Add any of the dataset specific attributes here Cached Properties: @@ -310,17 +311,6 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - # -- Copy any loaders you wrote that should be part of the Dataset class - # -- use this core.copy_docs decorator to copy the docs from the original - # -- load_ function - @core.copy_docs(load_audio) - def load_audio(self, *args, **kwargs): - return load_audio(*args, **kwargs) - - @core.copy_docs(load_annotation) - def load_annotation(self, *args, **kwargs): - return load_annotation(*args, **kwargs) - # -- if your dataset has a top-level metadata file, write a loader for it here # -- you do not have to include this function if there is no metadata @core.cached_property diff --git a/mirdata/annotations.py b/mirdata/annotations.py index 35272e16b..c107afb91 100644 --- a/mirdata/annotations.py +++ b/mirdata/annotations.py @@ -4,6 +4,7 @@ import re from typing import List, Optional, Tuple +from deprecated.sphinx import deprecated from jams.schema import namespace import librosa import numpy as np @@ -809,8 +810,8 @@ def __init__( @property def notes(self) -> np.ndarray: logging.warning( - "Deprecation warning: NoteData.notes will be removed in a future version." - + "Use NoteData.pitches" + "NoteData.notes is deprecated as of 0.3.4 and will be removed in a future version. Use" + " NoteData.pitches." ) return self.pitches @@ -1120,8 +1121,8 @@ def __init__( @property def pronunciations(self): logging.warning( - "LyricData.pronunciations will be removed in a future version. " - + "Use LyricData.lyrics" + "LyricData.pronunciations is deprecated as of 0.3.4 and will be removed in a future" + " version. Use LyricData.lyrics." ) return self.lyrics @@ -1169,7 +1170,8 @@ def __init__( @property def value(self): logging.warning( - "Deprecation warning: TempoData.value will be removed in future versions. Use TempoData.tempos instead." + "TempoData.value is deprecated as of 0.3.4 and will be removed in a future version. Use" + " TempoData.tempos." ) return self.tempos diff --git a/mirdata/core.py b/mirdata/core.py index e34b0449b..537937d7a 100644 --- a/mirdata/core.py +++ b/mirdata/core.py @@ -67,18 +67,6 @@ def inherit(obj): return inherit -def copy_docs(original): - """ - Decorator function to copy docs from one function to another - """ - - def wrapper(target): - target.__doc__ = original.__doc__ - return target - - return wrapper - - ##### Core Classes ##### diff --git a/mirdata/datasets/acousticbrainz_genre.py b/mirdata/datasets/acousticbrainz_genre.py index 6ab16dd0d..faae0dc84 100644 --- a/mirdata/datasets/acousticbrainz_genre.py +++ b/mirdata/datasets/acousticbrainz_genre.py @@ -38,9 +38,10 @@ grant agreement No 688382 AudioCommons. """ - import json +from deprecated.sphinx import deprecated + from mirdata import download_utils, core, io from mirdata import jams_utils @@ -71,7 +72,9 @@ REMOTES = { "index": download_utils.RemoteFileMetadata( filename="acousticbrainz_genre_index.json.zip", - url="https://zenodo.org/record/4298580/files/acousticbrainz_genre_index.json.zip?download=1", + url=( + "https://zenodo.org/record/4298580/files/acousticbrainz_genre_index.json.zip?download=1" + ), checksum="810f1c003f53cbe58002ba96e6d4d138", ), "validation-01": download_utils.RemoteFileMetadata( @@ -412,7 +415,10 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_extractor) + @deprecated( + reason="Use mirdata.datasets.acousticbrainz_genre.load_extractor", + version="0.3.4", + ) def load_extractor(self, *args, **kwargs): return load_extractor(*args, **kwargs) diff --git a/mirdata/datasets/beatles.py b/mirdata/datasets/beatles.py index a5a00617f..b3931ed50 100644 --- a/mirdata/datasets/beatles.py +++ b/mirdata/datasets/beatles.py @@ -13,6 +13,7 @@ import os from typing import BinaryIO, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -309,18 +310,30 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.beatles.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_beats) + @deprecated( + reason="Use mirdata.datasets.beatles.load_beats", + version="0.3.4", + ) def load_beats(self, *args, **kwargs): return load_beats(*args, **kwargs) - @core.copy_docs(load_chords) + @deprecated( + reason="Use mirdata.datasets.beatles.load_chords", + version="0.3.4", + ) def load_chords(self, *args, **kwargs): return load_chords(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.beatles.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) diff --git a/mirdata/datasets/beatport_key.py b/mirdata/datasets/beatport_key.py index 3becc8a0f..a6734b706 100644 --- a/mirdata/datasets/beatport_key.py +++ b/mirdata/datasets/beatport_key.py @@ -27,8 +27,9 @@ import os import fnmatch import json -import librosa +from deprecated.sphinx import deprecated +import librosa from smart_open import open from mirdata import core, download_utils, jams_utils, io @@ -269,23 +270,38 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.beatport_key.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_key) + @deprecated( + reason="Use mirdata.datasets.beatport_key.load_key", + version="0.3.4", + ) def load_key(self, *args, **kwargs): return load_key(*args, **kwargs) - @core.copy_docs(load_tempo) + @deprecated( + reason="Use mirdata.datasets.beatport_key.load_tempo", + version="0.3.4", + ) def load_tempo(self, *args, **kwargs): return load_tempo(*args, **kwargs) - @core.copy_docs(load_genre) + @deprecated( + reason="Use mirdata.datasets.beatport_key.load_genre", + version="0.3.4", + ) def load_genre(self, *args, **kwargs): return load_genre(*args, **kwargs) - @core.copy_docs(load_artist) + @deprecated( + reason="Use mirdata.datasets.beatport_key.load_artist", + version="0.3.4", + ) def load_artist(self, *args, **kwargs): return load_artist(*args, **kwargs) diff --git a/mirdata/datasets/billboard.py b/mirdata/datasets/billboard.py index 41c642e1c..383d1d339 100644 --- a/mirdata/datasets/billboard.py +++ b/mirdata/datasets/billboard.py @@ -13,6 +13,7 @@ import re from typing import BinaryIO, TextIO, Optional, Tuple, Dict, List +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -516,18 +517,30 @@ def _metadata(self): } return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.billboard.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.billboard.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) - @core.copy_docs(load_named_sections) + @deprecated( + reason="Use mirdata.datasets.billboard.load_named_sections", + version="0.3.4", + ) def load_named_sections(self, *args, **kwargs): return load_named_sections(*args, **kwargs) - @core.copy_docs(load_chords) + @deprecated( + reason="Use mirdata.datasets.billboard.load_chords", + version="0.3.4", + ) def load_chords(self, *args, **kwargs): return load_chords(*args, **kwargs) diff --git a/mirdata/datasets/cante100.py b/mirdata/datasets/cante100.py index aa3d804a8..bc6c037e7 100644 --- a/mirdata/datasets/cante100.py +++ b/mirdata/datasets/cante100.py @@ -49,6 +49,7 @@ import xml.etree.ElementTree as ET from typing import Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -423,18 +424,30 @@ def _metadata(self): return metadata - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.cante100.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_spectrogram) + @deprecated( + reason="Use mirdata.datasets.cante100.load_spectrogram", + version="0.3.4", + ) def load_spectrogram(self, *args, **kwargs): return load_spectrogram(*args, **kwargs) - @core.copy_docs(load_melody) + @deprecated( + reason="Use mirdata.datasets.cante100.load_melody", + version="0.3.4", + ) def load_melody(self, *args, **kwargs): return load_melody(*args, **kwargs) - @core.copy_docs(load_notes) + @deprecated( + reason="Use mirdata.datasets.cante100.load_notes", + version="0.3.4", + ) def load_notes(self, *args, **kwargs): return load_notes(*args, **kwargs) diff --git a/mirdata/datasets/compmusic_jingju_acappella.py b/mirdata/datasets/compmusic_jingju_acappella.py index 44a3430c1..3ede15b7b 100644 --- a/mirdata/datasets/compmusic_jingju_acappella.py +++ b/mirdata/datasets/compmusic_jingju_acappella.py @@ -49,12 +49,15 @@ import csv import os +from typing import BinaryIO, Optional, TextIO, Tuple -import numpy as np +from deprecated.sphinx import deprecated import librosa -from mirdata import annotations, core, download_utils, io, jams_utils +import numpy as np from smart_open import open -from typing import BinaryIO, Optional, TextIO, Tuple + +from mirdata import annotations, core, download_utils, io, jams_utils + BIBTEX = """ @dataset{rong_gong_2018_1323561, @@ -365,14 +368,23 @@ def _metadata(self): return metadata - @core.copy_docs(load_phonemes) + @deprecated( + reason="Use mirdata.datasets.jingju_acapella.load_phonemes", + version="0.3.4", + ) def load_phonemes(self, *args, **kwargs): return load_phonemes(*args, **kwargs) - @core.copy_docs(load_phrases) + @deprecated( + reason="Use mirdata.datasets.jingju_acapella.load_phrases", + version="0.3.4", + ) def load_phrases(self, *args, **kwargs): return load_phrases(*args, **kwargs) - @core.copy_docs(load_syllable) + @deprecated( + reason="Use mirdata.datasets.jingju_acapella.load_syllable", + version="0.3.4", + ) def load_syllable(self, *args, **kwargs): return load_syllable(*args, **kwargs) diff --git a/mirdata/datasets/compmusic_otmm_makam.py b/mirdata/datasets/compmusic_otmm_makam.py index 7394913c3..bce3c26bb 100644 --- a/mirdata/datasets/compmusic_otmm_makam.py +++ b/mirdata/datasets/compmusic_otmm_makam.py @@ -35,10 +35,13 @@ import os from typing import TextIO +from deprecated.sphinx import deprecated import numpy as np -from mirdata import annotations, core, download_utils, io, jams_utils from smart_open import open +from mirdata import annotations, core, download_utils, io, jams_utils + + BIBTEX = """ @software{sertan_senturk_2016_58413, author = {Sertan Şentürk and @@ -236,10 +239,16 @@ def _metadata(self): return metadata - @core.copy_docs(load_pitch) + @deprecated( + reason="Use mirdata.datasets.compmusic_otmm_makam.load_pitch", + version="0.3.4", + ) def load_pitch(self, *args, **kwargs): return load_pitch(*args, **kwargs) - @core.copy_docs(load_mb_tags) + @deprecated( + reason="Use mirdata.datasets.compmusic_otmm_makam.load_mb_tags", + version="0.3.4", + ) def load_mb_tags(self, *args, **kwargs): return load_mb_tags(*args, **kwargs) diff --git a/mirdata/datasets/da_tacos.py b/mirdata/datasets/da_tacos.py index 9445e9070..bacd47b36 100644 --- a/mirdata/datasets/da_tacos.py +++ b/mirdata/datasets/da_tacos.py @@ -99,6 +99,7 @@ import os from typing import Optional, BinaryIO +from deprecated.sphinx import deprecated import h5py from jams import JAMS import numpy as np @@ -530,31 +531,52 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_cens) + @deprecated( + reason="Use mirdata.datasets.da_tacos.load_cens", + version="0.3.4", + ) def load_cens(self, *args, **kwargs): return load_cens(*args, **kwargs) - @core.copy_docs(load_crema) + @deprecated( + reason="Use mirdata.datasets.da_tacos.load_crema", + version="0.3.4", + ) def load_crema(self, *args, **kwargs): return load_crema(*args, **kwargs) - @core.copy_docs(load_hpcp) + @deprecated( + reason="Use mirdata.datasets.da_tacos.load_hpcp", + version="0.3.4", + ) def load_hpcp(self, *args, **kwargs): return load_hpcp(*args, **kwargs) - @core.copy_docs(load_key) + @deprecated( + reason="Use mirdata.datasets.da_tacos.load_key", + version="0.3.4", + ) def load_key(self, *args, **kwargs): return load_key(*args, **kwargs) - @core.copy_docs(load_mfcc) + @deprecated( + reason="Use mirdata.datasets.da_tacos.load_mfcc", + version="0.3.4", + ) def load_mfcc(self, *args, **kwargs): return load_mfcc(*args, **kwargs) - @core.copy_docs(load_madmom) + @deprecated( + reason="Use mirdata.datasets.da_tacos.load_madmom", + version="0.3.4", + ) def load_madmom(self, *args, **kwargs): return load_madmom(*args, **kwargs) - @core.copy_docs(load_tags) + @deprecated( + reason="Use mirdata.datasets.da_tacos.load_tags", + version="0.3.4", + ) def load_tags(self, *args, **kwargs): return load_tags(*args, **kwargs) diff --git a/mirdata/datasets/dagstuhl_choirset.py b/mirdata/datasets/dagstuhl_choirset.py index ef1161a2d..0a253fd74 100644 --- a/mirdata/datasets/dagstuhl_choirset.py +++ b/mirdata/datasets/dagstuhl_choirset.py @@ -44,6 +44,7 @@ import csv from typing import BinaryIO, Optional, TextIO, Tuple, List +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -534,18 +535,30 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.dagstuhl_choirset.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_f0) + @deprecated( + reason="Use mirdata.datasets.dagstuhl_choirset.load_f0", + version="0.3.4", + ) def load_f0(self, *args, **kwargs): return load_f0(*args, **kwargs) - @core.copy_docs(load_score) + @deprecated( + reason="Use mirdata.datasets.dagstuhl_choirset.load_score", + version="0.3.4", + ) def load_score(self, *args, **kwargs): return load_score(*args, **kwargs) - @core.copy_docs(load_beat) + @deprecated( + reason="Use mirdata.datasets.dagstuhl_choirset.load_beat", + version="0.3.4", + ) def load_beat(self, *args, **kwargs): return load_beat(*args, **kwargs) diff --git a/mirdata/datasets/dali.py b/mirdata/datasets/dali.py index 18aa6ee25..c2a5b383c 100644 --- a/mirdata/datasets/dali.py +++ b/mirdata/datasets/dali.py @@ -21,6 +21,7 @@ import pickle from typing import BinaryIO, Optional, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -339,14 +340,23 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.dali.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_annotations_granularity) + @deprecated( + reason="Use mirdata.datasets.dali.load_annotations_granularity", + version="0.3.4", + ) def load_annotations_granularity(self, *args, **kwargs): return load_annotations_granularity(*args, **kwargs) - @core.copy_docs(load_annotations_class) + @deprecated( + reason="Use mirdata.datasets.dali.load_annotations_class", + version="0.3.4", + ) def load_annotations_class(self, *args, **kwargs): return load_annotations_class(*args, **kwargs) diff --git a/mirdata/datasets/freesound_one_shot_percussive_sounds.py b/mirdata/datasets/freesound_one_shot_percussive_sounds.py index 35adafed7..4a63d0447 100644 --- a/mirdata/datasets/freesound_one_shot_percussive_sounds.py +++ b/mirdata/datasets/freesound_one_shot_percussive_sounds.py @@ -43,6 +43,7 @@ import os from typing import BinaryIO, TextIO, Tuple, Optional +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -296,10 +297,16 @@ def _metadata(self): return metadata - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.freesound_one_shot_percussive_sounds.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_file_metadata) + @deprecated( + reason="Use mirdata.datasets.freesound_one_shot_percussive_sounds.load_file_metadata", + version="0.3.4", + ) def load_file_metadata(self, *args, **kwargs): return load_file_metadata(*args, **kwargs) diff --git a/mirdata/datasets/giantsteps_key.py b/mirdata/datasets/giantsteps_key.py index 318cd6a06..cbf3dd49e 100644 --- a/mirdata/datasets/giantsteps_key.py +++ b/mirdata/datasets/giantsteps_key.py @@ -33,8 +33,9 @@ """ import json -from typing import BinaryIO, Dict, List, Optional, TextIO, Tuple +from typing import Dict, List, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -265,22 +266,37 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.giantsteps_key.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_key) + @deprecated( + reason="Use mirdata.datasets.giantsteps_key.load_key", + version="0.3.4", + ) def load_key(self, *args, **kwargs): return load_key(*args, **kwargs) - @core.copy_docs(load_tempo) + @deprecated( + reason="Use mirdata.datasets.giantsteps_key.load_tempo", + version="0.3.4", + ) def load_tempo(self, *args, **kwargs): return load_tempo(*args, **kwargs) - @core.copy_docs(load_genre) + @deprecated( + reason="Use mirdata.datasets.giantsteps_key.load_genre", + version="0.3.4", + ) def load_genre(self, *args, **kwargs): return load_genre(*args, **kwargs) - @core.copy_docs(load_artist) + @deprecated( + reason="Use mirdata.datasets.giantsteps_key.load_artist", + version="0.3.4", + ) def load_artist(self, *args, **kwargs): return load_artist(*args, **kwargs) diff --git a/mirdata/datasets/giantsteps_tempo.py b/mirdata/datasets/giantsteps_tempo.py index 687f23db4..2b330c67e 100644 --- a/mirdata/datasets/giantsteps_tempo.py +++ b/mirdata/datasets/giantsteps_tempo.py @@ -65,9 +65,9 @@ 3577631.LOFI.mp3 119 """ -import os -from typing import BinaryIO, Optional, TextIO, Tuple +from typing import Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import jams import librosa import numpy as np @@ -274,14 +274,23 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.giantsteps_tempo.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_genre) + @deprecated( + reason="Use mirdata.datasets.giantsteps_tempo.load_genre", + version="0.3.4", + ) def load_genre(self, *args, **kwargs): return load_genre(*args, **kwargs) - @core.copy_docs(load_tempo) + @deprecated( + reason="Use mirdata.datasets.giantsteps_tempo.load_tempo", + version="0.3.4", + ) def load_tempo(self, *args, **kwargs): return load_tempo(*args, **kwargs) diff --git a/mirdata/datasets/good_sounds.py b/mirdata/datasets/good_sounds.py index 57cadf3a8..5922a9b16 100644 --- a/mirdata/datasets/good_sounds.py +++ b/mirdata/datasets/good_sounds.py @@ -31,6 +31,7 @@ import os from typing import Optional, Tuple, BinaryIO +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -340,6 +341,9 @@ def _metadata(self): return {"packs": packs, "ratings": ratings, "sounds": sounds, "takes": takes} - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.good_sounds.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) diff --git a/mirdata/datasets/groove_midi.py b/mirdata/datasets/groove_midi.py index 576cad5f6..a09407d1a 100644 --- a/mirdata/datasets/groove_midi.py +++ b/mirdata/datasets/groove_midi.py @@ -49,6 +49,7 @@ import os from typing import BinaryIO, Optional, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np import pretty_midi @@ -418,19 +419,31 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.groove_midi.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_midi) + @deprecated( + reason="Use mirdata.datasets.groove_midi.load_midi", + version="0.3.4", + ) def load_midi(self, *args, **kwargs): return load_midi(*args, **kwargs) - @core.copy_docs(load_beats) + @deprecated( + reason="Use mirdata.datasets.groove_midi.load_beats", + version="0.3.4", + ) def load_beats(self, *args, **kwargs): return load_beats(*args, **kwargs) - @core.copy_docs(load_drum_events) + @deprecated( + reason="Use mirdata.datasets.groove_midi.load_drum_events", + version="0.3.4", + ) def load_drum_events(self, *args, **kwargs): return load_drum_events(*args, **kwargs) diff --git a/mirdata/datasets/gtzan_genre.py b/mirdata/datasets/gtzan_genre.py index c5c5cfe11..a729528af 100644 --- a/mirdata/datasets/gtzan_genre.py +++ b/mirdata/datasets/gtzan_genre.py @@ -18,6 +18,7 @@ from typing import BinaryIO, Optional, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -151,6 +152,9 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.gtzan_genre.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) diff --git a/mirdata/datasets/guitarset.py b/mirdata/datasets/guitarset.py index 9953c79ed..b00a7a4a0 100644 --- a/mirdata/datasets/guitarset.py +++ b/mirdata/datasets/guitarset.py @@ -55,6 +55,7 @@ import os from typing import BinaryIO, Optional, TextIO, Tuple, Dict, List +from deprecated.sphinx import deprecated import jams import librosa import numpy as np @@ -528,30 +529,51 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.guitarset.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_multitrack_audio) + @deprecated( + reason="Use mirdata.datasets.guitarset.load_multitrack_audio", + version="0.3.4", + ) def load_multitrack_audio(self, *args, **kwargs): return load_multitrack_audio(*args, **kwargs) - @core.copy_docs(load_beats) + @deprecated( + reason="Use mirdata.datasets.guitarset.load_beats", + version="0.3.4", + ) def load_beats(self, *args, **kwargs): return load_beats(*args, **kwargs) - @core.copy_docs(load_chords) + @deprecated( + reason="Use mirdata.datasets.guitarset.load_chords", + version="0.3.4", + ) def load_chords(self, *args, **kwargs): return load_chords(*args, **kwargs) - @core.copy_docs(load_key_mode) + @deprecated( + reason="Use mirdata.datasets.guitarset.load_key_mode", + version="0.3.4", + ) def load_key_mode(self, *args, **kwargs): return load_key_mode(*args, **kwargs) - @core.copy_docs(load_pitch_contour) + @deprecated( + reason="Use mirdata.datasets.guitarset.load_pitch_contour", + version="0.3.4", + ) def load_pitch_contour(self, *args, **kwargs): return load_pitch_contour(*args, **kwargs) - @core.copy_docs(load_notes) + @deprecated( + reason="Use mirdata.datasets.guitarset.load_notes", + version="0.3.4", + ) def load_notes(self, *args, **kwargs): return load_notes(*args, **kwargs) diff --git a/mirdata/datasets/haydn_op20.py b/mirdata/datasets/haydn_op20.py index 13e1918a3..aa25fe742 100644 --- a/mirdata/datasets/haydn_op20.py +++ b/mirdata/datasets/haydn_op20.py @@ -13,6 +13,7 @@ import os from typing import Optional, TextIO, List +from deprecated.sphinx import deprecated import numpy as np from mirdata import core, io, jams_utils, download_utils @@ -130,7 +131,7 @@ def duration(self) -> int: @core.cached_property def midi_path(self) -> Optional[str]: logging.warning( - "Deprecation warning: midi_path is deprecated and will be removed in a future version" + "midi_path is deprecated as of 0.3.4 and will be removed in a future version." ) return convert_and_save_to_midi(self.humdrum_annotated_path) @@ -269,6 +270,10 @@ def load_key_music21(fhandle: TextIO, resolution=28): return _load_key_base(fhandle, resolution) +@deprecated( + reason="convert_and_save_to_midi is deprecated and will be removed in a future version", + version="0.3.4", +) @io.coerce_to_string_io def convert_and_save_to_midi(fpath: TextIO): """convert to midi file and return the midi path @@ -280,10 +285,6 @@ def convert_and_save_to_midi(fpath: TextIO): str: midi file path """ - logging.warning( - "Deprecation warning: convert_and_save_to_midi is deprecated and will be removed in a" - " future version." - ) midi_path = os.path.splitext(fpath.name)[0] + ".midi" score, _ = _split_score_annotations(fpath) score.write("midi", fp=midi_path) @@ -388,30 +389,51 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_score) + @deprecated( + reason="Use mirdata.datasets.haydn_op20.load_score", + version="0.3.4", + ) def load_score(self, *args, **kwargs): return load_score(*args, **kwargs) - @core.copy_docs(load_key_music21) + @deprecated( + reason="Use mirdata.datasets.haydn_op20.load_key_music21", + version="0.3.4", + ) def load_key_music21(self, *args, **kwargs): return load_key_music21(*args, **kwargs) - @core.copy_docs(load_key) + @deprecated( + reason="Use mirdata.datasets.haydn_op20.load_key", + version="0.3.4", + ) def load_key(self, *args, **kwargs): return load_key(*args, **kwargs) - @core.copy_docs(load_chords) + @deprecated( + reason="Use mirdata.datasets.haydn_op20.load_chords", + version="0.3.4", + ) def load_chords(self, *args, **kwargs): return load_chords(*args, **kwargs) - @core.copy_docs(load_chords_music21) + @deprecated( + reason="Use mirdata.datasets.haydn_op20.load_chords_music21", + version="0.3.4", + ) def load_chords_music21(self, *args, **kwargs): return load_chords_music21(*args, **kwargs) - @core.copy_docs(load_roman_numerals) + @deprecated( + reason="Use mirdata.datasets.haydn_op20.load_roman_numerals", + version="0.3.4", + ) def load_roman_numerals(self, *args, **kwargs): return load_roman_numerals(*args, **kwargs) - @core.copy_docs(convert_and_save_to_midi) + @deprecated( + reason="Use mirdata.datasets.haydn_op20.convert_and_save_to_midi", + version="0.3.4", + ) def load_midi_path(self, *args, **kwargs): return convert_and_save_to_midi(*args, **kwargs) diff --git a/mirdata/datasets/ikala.py b/mirdata/datasets/ikala.py index a33b9c2cc..ca0423a4e 100644 --- a/mirdata/datasets/ikala.py +++ b/mirdata/datasets/ikala.py @@ -17,6 +17,7 @@ import os from typing import BinaryIO, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -403,30 +404,51 @@ def _metadata(self): return singer_map - @core.copy_docs(load_vocal_audio) + @deprecated( + reason="Use mirdata.datasets.ikala.load_vocal_audio", + version="0.3.4", + ) def load_vocal_audio(self, *args, **kwargs): return load_vocal_audio(*args, **kwargs) - @core.copy_docs(load_instrumental_audio) + @deprecated( + reason="Use mirdata.datasets.ikala.load_instrumental_audio", + version="0.3.4", + ) def load_instrumental_audio(self, *args, **kwargs): return load_instrumental_audio(*args, **kwargs) - @core.copy_docs(load_mix_audio) + @deprecated( + reason="Use mirdata.datasets.ikala.load_mix_audio", + version="0.3.4", + ) def load_mix_audio(self, *args, **kwargs): return load_mix_audio(*args, **kwargs) - @core.copy_docs(load_f0) + @deprecated( + reason="Use mirdata.datasets.ikala.load_f0", + version="0.3.4", + ) def load_f0(self, *args, **kwargs): return load_f0(*args, **kwargs) - @core.copy_docs(load_notes) + @deprecated( + reason="Use mirdata.datasets.ikala.load_notes", + version="0.3.4", + ) def load_notes(self, *args, **kwargs): return load_notes(*args, **kwargs) - @core.copy_docs(load_lyrics) + @deprecated( + reason="Use mirdata.datasets.ikala.load_lyrics", + version="0.3.4", + ) def load_lyrics(self, *args, **kwargs): return load_lyrics(*args, **kwargs) - @core.copy_docs(load_pronunciations) + @deprecated( + reason="Use mirdata.datasets.ikala.load_pronunciations", + version="0.3.4", + ) def load_pronunciations(self, *args, **kwargs): return load_pronunciations(*args, **kwargs) diff --git a/mirdata/datasets/irmas.py b/mirdata/datasets/irmas.py index b7de11293..4bab3d36f 100644 --- a/mirdata/datasets/irmas.py +++ b/mirdata/datasets/irmas.py @@ -92,6 +92,7 @@ import os from typing import BinaryIO, List, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -334,10 +335,16 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.irmas.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_pred_inst) + @deprecated( + reason="Use mirdata.datasets.irmas.load_pred_inst", + version="0.3.4", + ) def load_pred_inst(self, *args, **kwargs): return load_pred_inst(*args, **kwargs) diff --git a/mirdata/datasets/maestro.py b/mirdata/datasets/maestro.py index b29efce0b..59d477517 100644 --- a/mirdata/datasets/maestro.py +++ b/mirdata/datasets/maestro.py @@ -35,6 +35,7 @@ import os from typing import BinaryIO, Optional, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np import pretty_midi @@ -237,15 +238,24 @@ def _metadata(self): return metadata - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.maestro.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(io.load_midi) + @deprecated( + reason="Use mirdata.io.load_midi", + version="0.3.4", + ) def load_midi(self, *args, **kwargs): return io.load_midi(*args, **kwargs) - @core.copy_docs(io.load_notes_from_midi) + @deprecated( + reason="Use mirdata.io.load_notes_from_midi", + version="0.3.4", + ) def load_notes(self, *args, **kwargs): return io.load_notes_from_midi(*args, **kwargs) diff --git a/mirdata/datasets/medley_solos_db.py b/mirdata/datasets/medley_solos_db.py index f9b938d94..e7a6c634a 100644 --- a/mirdata/datasets/medley_solos_db.py +++ b/mirdata/datasets/medley_solos_db.py @@ -30,6 +30,7 @@ import os from typing import BinaryIO, Optional, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -195,6 +196,9 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.medley_solos_db.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) diff --git a/mirdata/datasets/medleydb_melody.py b/mirdata/datasets/medleydb_melody.py index c65c5689a..e94242ae7 100644 --- a/mirdata/datasets/medleydb_melody.py +++ b/mirdata/datasets/medleydb_melody.py @@ -21,6 +21,7 @@ import os from typing import BinaryIO, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -270,14 +271,23 @@ def _metadata(self): return metadata - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.medleydb_melody.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_melody) + @deprecated( + reason="Use mirdata.datasets.medleydb_melody.load_melody", + version="0.3.4", + ) def load_melody(self, *args, **kwargs): return load_melody(*args, **kwargs) - @core.copy_docs(load_melody3) + @deprecated( + reason="Use mirdata.datasets.medleydb_melody.load_melody3", + version="0.3.4", + ) def load_melody3(self, *args, **kwargs): return load_melody3(*args, **kwargs) diff --git a/mirdata/datasets/medleydb_pitch.py b/mirdata/datasets/medleydb_pitch.py index 9c4639081..426df09e3 100644 --- a/mirdata/datasets/medleydb_pitch.py +++ b/mirdata/datasets/medleydb_pitch.py @@ -21,6 +21,7 @@ import os from typing import BinaryIO, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -260,14 +261,23 @@ def _metadata(self): return metadata - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.medleydb_pitch.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_pitch) + @deprecated( + reason="Use mirdata.datasets.medleydb_pitch.load_pitch", + version="0.3.4", + ) def load_pitch(self, *args, **kwargs): return load_pitch(*args, **kwargs) - @core.copy_docs(load_notes) + @deprecated( + reason="Use mirdata.datasets.medleydb_pitch.load_notes", + version="0.3.4", + ) def load_notes(self, *args, **kwargs): return load_notes(*args, **kwargs) diff --git a/mirdata/datasets/mridangam_stroke.py b/mirdata/datasets/mridangam_stroke.py index 28c63e309..466ba4131 100644 --- a/mirdata/datasets/mridangam_stroke.py +++ b/mirdata/datasets/mridangam_stroke.py @@ -43,6 +43,7 @@ import os +from deprecated.sphinx import deprecated import librosa import numpy as np from typing import BinaryIO, Optional, Tuple @@ -198,6 +199,9 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.mridangam_stroke.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) diff --git a/mirdata/datasets/mtg_jamendo_autotagging_moodtheme.py b/mirdata/datasets/mtg_jamendo_autotagging_moodtheme.py index d36cd0ad7..6ee5b73f8 100644 --- a/mirdata/datasets/mtg_jamendo_autotagging_moodtheme.py +++ b/mirdata/datasets/mtg_jamendo_autotagging_moodtheme.py @@ -40,6 +40,7 @@ import os from typing import Optional, Tuple, BinaryIO +from deprecated.sphinx import deprecated import librosa import numpy as np from mirdata import download_utils, jams_utils, core @@ -251,7 +252,10 @@ def _metadata(self): meta["splits"] = splits return meta - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.mtg_jamendo_autotagging_moodtheme.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) diff --git a/mirdata/datasets/orchset.py b/mirdata/datasets/orchset.py index af661d636..8bfeab178 100644 --- a/mirdata/datasets/orchset.py +++ b/mirdata/datasets/orchset.py @@ -16,9 +16,10 @@ import os from typing import BinaryIO, Optional, TextIO, Tuple -from smart_open import open +from deprecated.sphinx import deprecated import librosa import numpy as np +from smart_open import open from mirdata import annotations, core, download_utils, io, jams_utils @@ -320,14 +321,23 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio_mono) + @deprecated( + reason="Use mirdata.datasets.orchset.load_audio_mono", + version="0.3.4", + ) def load_audio_mono(self, *args, **kwargs): return load_audio_mono(*args, **kwargs) - @core.copy_docs(load_audio_stereo) + @deprecated( + reason="Use mirdata.datasets.orchset.load_audio_stereo", + version="0.3.4", + ) def load_audio_stereo(self, *args, **kwargs): return load_audio_stereo(*args, **kwargs) - @core.copy_docs(load_melody) + @deprecated( + reason="Use mirdata.datasets.orchset.load_melody", + version="0.3.4", + ) def load_melody(self, *args, **kwargs): return load_melody(*args, **kwargs) diff --git a/mirdata/datasets/phenicx_anechoic.py b/mirdata/datasets/phenicx_anechoic.py index a497cd84d..8e99b6f21 100644 --- a/mirdata/datasets/phenicx_anechoic.py +++ b/mirdata/datasets/phenicx_anechoic.py @@ -46,6 +46,7 @@ """ from typing import BinaryIO, Optional, TextIO, Tuple, cast +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -419,10 +420,16 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.phenicx_anechoic.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_score) + @deprecated( + reason="Use mirdata.datasets.phenicx_anechoic.load_score", + version="0.3.4", + ) def load_score(self, *args, **kwargs): return load_score(*args, **kwargs) diff --git a/mirdata/datasets/queen.py b/mirdata/datasets/queen.py index ffebfc4a0..b9f871016 100644 --- a/mirdata/datasets/queen.py +++ b/mirdata/datasets/queen.py @@ -33,6 +33,7 @@ import os from typing import Tuple, TextIO, Optional, BinaryIO +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -263,18 +264,30 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.queen.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_key) + @deprecated( + reason="Use mirdata.datasets.queen.load_key", + version="0.3.4", + ) def load_key(self, *args, **kwargs): return load_key(*args, **kwargs) - @core.copy_docs(load_chords) + @deprecated( + reason="Use mirdata.datasets.queen.load_chords", + version="0.3.4", + ) def load_chords(self, *args, **kwargs): return load_chords(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.queen.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) diff --git a/mirdata/datasets/rwc_classical.py b/mirdata/datasets/rwc_classical.py index 6403755b5..6a238ef4b 100644 --- a/mirdata/datasets/rwc_classical.py +++ b/mirdata/datasets/rwc_classical.py @@ -53,6 +53,7 @@ import os from typing import BinaryIO, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -421,14 +422,23 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.rwc_classical.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.rwc_classical.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) - @core.copy_docs(load_beats) + @deprecated( + reason="Use mirdata.datasets.rwc_classical.load_beats", + version="0.3.4", + ) def load_beats(self, *args, **kwargs): return load_beats(*args, **kwargs) diff --git a/mirdata/datasets/rwc_jazz.py b/mirdata/datasets/rwc_jazz.py index 527096cc5..56fbaedae 100644 --- a/mirdata/datasets/rwc_jazz.py +++ b/mirdata/datasets/rwc_jazz.py @@ -44,6 +44,7 @@ import os from typing import Optional, Tuple +from deprecated.sphinx import deprecated import numpy as np from smart_open import open @@ -274,14 +275,23 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.rwc_jazz.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.rwc_jazz.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) - @core.copy_docs(load_beats) + @deprecated( + reason="Use mirdata.datasets.rwc_jazz.load_beats", + version="0.3.4", + ) def load_beats(self, *args, **kwargs): return load_beats(*args, **kwargs) diff --git a/mirdata/datasets/rwc_popular.py b/mirdata/datasets/rwc_popular.py index 0df51fd68..a7c633c70 100644 --- a/mirdata/datasets/rwc_popular.py +++ b/mirdata/datasets/rwc_popular.py @@ -16,6 +16,7 @@ import os from typing import Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import numpy as np from smart_open import open @@ -358,22 +359,37 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.rwc_popular.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.rwc_popular.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) - @core.copy_docs(load_beats) + @deprecated( + reason="Use mirdata.datasets.rwc_popular.load_beats", + version="0.3.4", + ) def load_beats(self, *args, **kwargs): return load_beats(*args, **kwargs) - @core.copy_docs(load_chords) + @deprecated( + reason="Use mirdata.datasets.rwc_popular.load_chords", + version="0.3.4", + ) def load_chords(self, *args, **kwargs): return load_chords(*args, **kwargs) - @core.copy_docs(load_vocal_activity) + @deprecated( + reason="Use mirdata.datasets.rwc_popular.load_vocal_activity", + version="0.3.4", + ) def load_vocal_activity(self, *args, **kwargs): return load_vocal_activity(*args, **kwargs) diff --git a/mirdata/datasets/salami.py b/mirdata/datasets/salami.py index e37f3c554..d33bce2e1 100644 --- a/mirdata/datasets/salami.py +++ b/mirdata/datasets/salami.py @@ -18,6 +18,7 @@ import os from typing import Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -322,10 +323,16 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.salami.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.salami.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) diff --git a/mirdata/datasets/saraga_carnatic.py b/mirdata/datasets/saraga_carnatic.py index 7521d0f19..97ba7c3aa 100644 --- a/mirdata/datasets/saraga_carnatic.py +++ b/mirdata/datasets/saraga_carnatic.py @@ -32,6 +32,8 @@ import csv import json + +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -463,34 +465,58 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_tonic) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_tonic", + version="0.3.4", + ) def load_tonic(self, *args, **kwargs): return load_tonic(*args, **kwargs) - @core.copy_docs(load_pitch) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_pitch", + version="0.3.4", + ) def load_pitch(self, *args, **kwargs): return load_pitch(*args, **kwargs) - @core.copy_docs(load_tempo) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_tempo", + version="0.3.4", + ) def load_tempo(self, *args, **kwargs): return load_tempo(*args, **kwargs) - @core.copy_docs(load_sama) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_sama", + version="0.3.4", + ) def load_sama(self, *args, **kwargs): return load_sama(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) - @core.copy_docs(load_phrases) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_phrases", + version="0.3.4", + ) def load_phrases(self, *args, **kwargs): return load_phrases(*args, **kwargs) - @core.copy_docs(load_metadata) + @deprecated( + reason="Use mirdata.datasets.saraga_carnatic.load_metadata", + version="0.3.4", + ) def load_metadata(self, *args, **kwargs): return load_metadata(*args, **kwargs) diff --git a/mirdata/datasets/saraga_hindustani.py b/mirdata/datasets/saraga_hindustani.py index 4b04a2d66..0652daa3e 100644 --- a/mirdata/datasets/saraga_hindustani.py +++ b/mirdata/datasets/saraga_hindustani.py @@ -33,6 +33,7 @@ import csv import json +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -473,30 +474,51 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.saraga_hindustani.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_tonic) + @deprecated( + reason="Use mirdata.datasets.saraga_hindustani.load_tonic", + version="0.3.4", + ) def load_tonic(self, *args, **kwargs): return load_tonic(*args, **kwargs) - @core.copy_docs(load_pitch) + @deprecated( + reason="Use mirdata.datasets.saraga_hindustani.load_pitch", + version="0.3.4", + ) def load_pitch(self, *args, **kwargs): return load_pitch(*args, **kwargs) - @core.copy_docs(load_tempo) + @deprecated( + reason="Use mirdata.datasets.saraga_hindustani.load_tempo", + version="0.3.4", + ) def load_tempo(self, *args, **kwargs): return load_tempo(*args, **kwargs) - @core.copy_docs(load_sama) + @deprecated( + reason="Use mirdata.datasets.saraga_hindustani.load_sama", + version="0.3.4", + ) def load_sama(self, *args, **kwargs): return load_sama(*args, **kwargs) - @core.copy_docs(load_sections) + @deprecated( + reason="Use mirdata.datasets.saraga_hindustani.load_sections", + version="0.3.4", + ) def load_sections(self, *args, **kwargs): return load_sections(*args, **kwargs) - @core.copy_docs(load_phrases) + @deprecated( + reason="Use mirdata.datasets.saraga_hindustani.load_phrases", + version="0.3.4", + ) def load_phrases(self, *args, **kwargs): return load_phrases(*args, **kwargs) diff --git a/mirdata/datasets/slakh.py b/mirdata/datasets/slakh.py index 082fdc6b2..4ff264282 100644 --- a/mirdata/datasets/slakh.py +++ b/mirdata/datasets/slakh.py @@ -28,6 +28,7 @@ import os from typing import BinaryIO, Optional, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np import pretty_midi @@ -406,18 +407,30 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.slakh.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(io.load_midi) + @deprecated( + reason="Use mirdata.datasets.slakh.load_midi", + version="0.3.4", + ) def load_midi(self, *args, **kwargs): return io.load_midi(*args, **kwargs) - @core.copy_docs(io.load_notes_from_midi) + @deprecated( + reason="Use mirdata.io.load_notes_from_midi", + version="0.3.4", + ) def load_notes_from_midi(self, *args, **kwargs): return io.load_notes_from_midi(*args, **kwargs) - @core.copy_docs(io.load_multif0_from_midi) + @deprecated( + reason="Use mirdata.io.load_multif0_from_midi", + version="0.3.4", + ) def load_multif0_from_midi(self, *args, **kwargs): return io.load_multif0_from_midi(*args, **kwargs) diff --git a/mirdata/datasets/tinysol.py b/mirdata/datasets/tinysol.py index 156d837eb..44defb2d8 100644 --- a/mirdata/datasets/tinysol.py +++ b/mirdata/datasets/tinysol.py @@ -47,6 +47,7 @@ import os from typing import BinaryIO, Optional, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -269,6 +270,9 @@ def _metadata(self): return metadata_index - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.tinysol.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) diff --git a/mirdata/datasets/tonality_classicaldb.py b/mirdata/datasets/tonality_classicaldb.py index b2facf60f..2019285c4 100644 --- a/mirdata/datasets/tonality_classicaldb.py +++ b/mirdata/datasets/tonality_classicaldb.py @@ -37,6 +37,7 @@ import json from typing import Any, BinaryIO, Dict, Optional, TextIO, Tuple +from deprecated.sphinx import deprecated import librosa import numpy as np @@ -284,22 +285,37 @@ def __init__(self, data_home=None, version="default"): license_info=LICENSE_INFO, ) - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.tonality_classicaldb.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_key) + @deprecated( + reason="Use mirdata.datasets.tonality_classicaldb.load_key", + version="0.3.4", + ) def load_key(self, *args, **kwargs): return load_key(*args, **kwargs) - @core.copy_docs(load_spectrum) + @deprecated( + reason="Use mirdata.datasets.tonality_classicaldb.load_spectrum", + version="0.3.4", + ) def load_spectrum(self, *args, **kwargs): return load_spectrum(*args, **kwargs) - @core.copy_docs(load_hpcp) + @deprecated( + reason="Use mirdata.datasets.tonality_classicaldb.load_hpcp", + version="0.3.4", + ) def load_hpcp(self, *args, **kwargs): return load_hpcp(*args, **kwargs) - @core.copy_docs(load_musicbrainz) + @deprecated( + reason="Use mirdata.datasets.tonality_classicaldb.load_musicbrainz", + version="0.3.4", + ) def load_musicbrainz(self, *args, **kwargs): return load_musicbrainz(*args, **kwargs) diff --git a/mirdata/datasets/tonas.py b/mirdata/datasets/tonas.py index f8b83cadc..6439f3b56 100644 --- a/mirdata/datasets/tonas.py +++ b/mirdata/datasets/tonas.py @@ -46,6 +46,7 @@ import os from typing import TextIO, Tuple, Optional +from deprecated.sphinx import deprecated import librosa import numpy as np from smart_open import open @@ -185,9 +186,8 @@ def f0_corrected(self) -> Optional[annotations.F0Data]: @property def f0(self): logging.warning( - "Deprecation warning: Track.f0 is deprecated and will " - + "be removed in a future version. Use Track.f0_automatic " - + "or Track.f0_corrected" + "Track.f0 is deprecated as of 0.3.4 and will be removed in a future version. Use" + " Track.f0_automatic or Track.f0_corrected" ) return self.f0_corrected @@ -380,14 +380,23 @@ def _metadata(self): return metadata - @core.copy_docs(load_audio) + @deprecated( + reason="Use mirdata.datasets.tonas.load_audio", + version="0.3.4", + ) def load_audio(self, *args, **kwargs): return load_audio(*args, **kwargs) - @core.copy_docs(load_f0) + @deprecated( + reason="Use mirdata.datasets.tonas.load_f0", + version="0.3.4", + ) def load_f0(self, *args, **kwargs): return load_f0(*args, **kwargs) - @core.copy_docs(load_notes) + @deprecated( + reason="Use mirdata.datasets.tonas.load_notes", + version="0.3.4", + ) def load_notes(self, *args, **kwargs): return load_notes(*args, **kwargs) diff --git a/setup.py b/setup.py index 0672dd60b..86bc59495 100644 --- a/setup.py +++ b/setup.py @@ -42,6 +42,7 @@ "scipy", "h5py >= 2.10.0", "smart_open >= 5.0.0", + "Deprecated >= 1.2.13", ], extras_require={ "tests": [ diff --git a/tests/test_loaders.py b/tests/test_loaders.py index 25199487d..2ffa94592 100644 --- a/tests/test_loaders.py +++ b/tests/test_loaders.py @@ -383,21 +383,15 @@ def test_track_placeholder_case(): def test_load_methods(): for dataset_name in DATASETS: - dataset = mirdata.initialize( - dataset_name, os.path.join(TEST_DATA_HOME, dataset_name), version="test" - ) + dataset_module = importlib.import_module(f"mirdata.datasets.{dataset_name}") - all_methods = dir(dataset) + all_methods = dir(dataset_module) load_methods = [ - getattr(dataset, m) for m in all_methods if m.startswith("load_") + getattr(dataset_module, m) for m in all_methods if m.startswith("load_") ] for load_method in load_methods: method_name = load_method.__name__ - # skip default methods - if method_name == "load_tracks" or method_name == "load_multitracks": - continue - # skip overrides, add to the SKIP dictionary to skip a specific load method if dataset_name in SKIP and method_name in SKIP[dataset_name]: continue @@ -409,12 +403,6 @@ def test_load_methods(): ) ) - params = [ - p - for p in inspect.signature(load_method).parameters.values() - if p.default == inspect._empty - ] # get list of parameters that don't have defaults - # add to the EXCEPTIONS dictionary above if your load_* function needs # more than one argument. if dataset_name in EXCEPTIONS and method_name in EXCEPTIONS[dataset_name]: diff --git a/tox.ini b/tox.ini index e50759503..87cafad15 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,6 @@ commands = [testenv:mypy] basepython=python3.8 -deps = mypy +deps = mypy>=0.910 commands = - mypy {toxinidir}/mirdata --ignore-missing-imports --allow-subclassing-any + mypy --install-types --non-interactive {toxinidir}/mirdata --ignore-missing-imports --allow-subclassing-any