Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_download(httpserver):
data_home = 'tests/resources/mir_datasets/Groove-MIDI_download'
if os.path.exists(data_home):
shutil.rmtree(data_home)
httpserver.serve_content(
open('tests/resources/download/groove-v1-0.0.zip', 'rb').read()
)
groove_midi.REMOTES = {
'all': download_utils.RemoteFileMetadata(
filename='groove-v1-0.0.zip',
url=httpserver.url,
checksum=('97a9a888d2a65cc87bb26e74df08b011'),
destination_dir=None,
)
}
groove_midi.download(data_home=data_home)
assert os.path.exists(data_home)
assert not os.path.exists(os.path.join(data_home, 'groove'))
assert os.path.exists(os.path.join(data_home, "info.csv"))
track = groove_midi.Track('drummer1/eval_session/1', data_home=data_home)
assert os.path.exists(track.midi_path)
assert os.path.exists(track.audio_path)
def test_download_partial(httpserver):
data_home = 'tests/resources/mir_datasets/MAESTRO_download'
if os.path.exists(data_home):
shutil.rmtree(data_home)
httpserver.serve_content(
open('tests/resources/download/maestro-v2.0.0.json', 'r').read()
)
maestro.REMOTES = {
'all': download_utils.RemoteFileMetadata(
filename='1-maestro-v2.0.0.json',
url=httpserver.url,
checksum=('d41d8cd98f00b204e9800998ecf8427e'),
destination_dir=None,
),
'midi': download_utils.RemoteFileMetadata(
filename='2-maestro-v2.0.0.json',
url=httpserver.url,
checksum=('d41d8cd98f00b204e9800998ecf8427e'),
destination_dir=None,
),
'metadata': download_utils.RemoteFileMetadata(
filename='3-maestro-v2.0.0.json',
url=httpserver.url,
checksum=('d41d8cd98f00b204e9800998ecf8427e'),
destination_dir='maestro-v2.0.0',
import numpy as np
import os
from mirdata import download_utils
from mirdata import jams_utils
from mirdata import track
from mirdata import utils
METADATA_REMOTE = download_utils.RemoteFileMetadata(
filename='rwc-c.csv',
url='https://github.com/magdalenafuentes/metadata/archive/master.zip',
checksum='7dbe87fedbaaa1f348625a2af1d78030',
destination_dir=None,
)
DATASET_DIR = 'RWC-Classical'
ANNOTATIONS_REMOTE_1 = download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-C-2001.BEAT.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-C-2001.BEAT.zip',
checksum='e8ee05854833cbf5eb7280663f71c29b',
destination_dir='annotations',
)
ANNOTATIONS_REMOTE_2 = download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-C-2001.CHORUS.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-C-2001.CHORUS.zip',
checksum='f77bd527510376f59f5a2eed8fd7feb3',
destination_dir='annotations',
)
def _load_metadata(data_home):
metadata_path = os.path.join(data_home, 'metadata-master', 'rwc-c.csv')
DATASET_DIR = 'MAESTRO'
REMOTES = {
'all': download_utils.RemoteFileMetadata(
filename='maestro-v2.0.0.zip',
url='https://storage.googleapis.com/magentadata/datasets/maestro/v2.0.0/maestro-v2.0.0.zip',
checksum='7a6c23536ebcf3f50b1f00ac253886a7',
destination_dir='',
),
'midi': download_utils.RemoteFileMetadata(
filename='maestro-v2.0.0-midi.zip',
url='https://storage.googleapis.com/magentadata/datasets/maestro/v2.0.0/maestro-v2.0.0-midi.zip',
checksum='8a45cc678a8b23cd7bad048b1e9034c5',
destination_dir='',
),
'metadata': download_utils.RemoteFileMetadata(
filename='maestro-v2.0.0.json',
url='https://storage.googleapis.com/magentadata/datasets/maestro/v2.0.0/maestro-v2.0.0.json',
checksum='576172af1cdc4efddcf0be7d260d48f7',
destination_dir='maestro-v2.0.0',
),
}
def _load_metadata(data_home):
metadata_path = os.path.join(data_home, 'maestro-v2.0.0.json')
if not os.path.exists(metadata_path):
logging.info("Metadata file {} not found.".format(metadata_path))
return None
# load metadata however makes sense for your dataset
with open(metadata_path, 'r') as fhandle:
# these functions are identical for all rwc datasets
from mirdata.rwc_classical import (
load_beats,
load_sections,
load_audio,
_duration_to_sec,
)
REMOTES = {
'metadata': download_utils.RemoteFileMetadata(
filename='rwc-p.csv',
url='https://github.com/magdalenafuentes/metadata/archive/master.zip',
checksum='7dbe87fedbaaa1f348625a2af1d78030',
destination_dir=None,
),
'annotations_beat': download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-P-2001.BEAT.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-P-2001.BEAT.zip',
checksum='3858aa989535bd7196b3cd07b512b5b6',
destination_dir='annotations',
),
'annotations_sections': download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-P-2001.CHORUS.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-P-2001.CHORUS.zip',
checksum='f76b3a32701fbd9bf78baa608f692a77',
destination_dir='annotations',
),
'annotations_chords': download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-P-2001.CHORD.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-P-2001.CHORD.zip',
checksum='68379c88bc8ec3f1907b32a3579197c5',
destination_dir='annotations',
import logging
import os
from mirdata import download_utils
from mirdata import jams_utils
from mirdata import track
from mirdata import utils
DATASET_DIR = "Medley-solos-DB"
ANNOTATION_REMOTE = download_utils.RemoteFileMetadata(
filename="Medley-solos-DB_metadata.csv",
url="https://zenodo.org/record/3464194/files/Medley-solos-DB_metadata.csv?download=1",
checksum="fda6a589c56785f2195c9227809c521a",
destination_dir="annotation",
)
AUDIO_REMOTE = download_utils.RemoteFileMetadata(
filename="Medley-solos-DB.tar.gz",
url="https://zenodo.org/record/3464194/files/Medley-solos-DB.tar.gz?download=1",
checksum="f5facf398793ef5c1f80c013afdf3e5f",
destination_dir="audio",
)
def _load_metadata(data_home):
metadata_path = os.path.join(
data_home, "annotation", "Medley-solos-DB_metadata.csv"
)
if not os.path.exists(metadata_path):
logging.info("Metadata file {} not found.".format(metadata_path))
return None
from mirdata.rwc_classical import _load_beats, _load_sections, _duration_to_sec
METADATA_REMOTE = download_utils.RemoteFileMetadata(
filename='rwc-g.csv',
url='https://github.com/magdalenafuentes/metadata/archive/master.zip',
checksum='7dbe87fedbaaa1f348625a2af1d78030',
destination_dir=None,
)
DATASET_DIR = 'RWC-Genre'
ANNOTATIONS_REMOTE_1 = download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-G-2001.BEAT.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-G-2001.BEAT.zip',
checksum='66427ce5f4485088c6d9bc5f7394f65f',
destination_dir='annotations',
)
ANNOTATIONS_REMOTE_2 = download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-G-2001.CHORUS.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-G-2001.CHORUS.zip',
checksum='e9fe612a0ddc7a83f3c1d17fb5fec32a',
destination_dir='annotations',
)
def _load_metadata(data_home):
metadata_path = os.path.join(data_home, 'metadata-master', 'rwc-g.csv')
if not os.path.exists(metadata_path):
logging.info(
'Metadata file {} not found.'.format(metadata_path)
+ 'You can download the metadata file by running download()'
)
import logging
import os
from mirdata import download_utils
from mirdata import jams_utils
from mirdata import track
from mirdata import utils
DATASET_DIR = "TinySOL"
AUDIO_REMOTE = download_utils.RemoteFileMetadata(
filename="TinySOL.tar.gz",
url="https://zenodo.org/record/3685367/files/TinySOL.tar.gz?download=1",
checksum="36030a7fe389da86c3419e5ee48e3b7f",
destination_dir="audio",
)
ANNOTATION_REMOTE = download_utils.RemoteFileMetadata(
filename="TinySOL_metadata.csv",
url="https://zenodo.org/record/3685367/files/TinySOL_metadata.csv?download=1",
checksum="a86c9bb115f69e61f2f25872e397fc4a",
destination_dir="annotation",
)
STRING_ROMAN_NUMERALS = {1: "I", 2: "II", 3: "III", 4: "IV"}
def _load_metadata(data_home):
metadata_path = os.path.join(data_home, "annotation", "TinySOL_metadata.csv")
if not os.path.exists(metadata_path):
logging.info("Metadata file {} not found.".format(metadata_path))
return None
metadata_index = {}
from mirdata import download_utils
from mirdata import jams_utils
from mirdata import track
from mirdata import utils
# these functions are identical for all rwc datasets
from mirdata.rwc_classical import (
load_beats,
load_sections,
load_audio,
_duration_to_sec,
)
REMOTES = {
'metadata': download_utils.RemoteFileMetadata(
filename='rwc-j.csv',
url='https://github.com/magdalenafuentes/metadata/archive/master.zip',
checksum='7dbe87fedbaaa1f348625a2af1d78030',
destination_dir=None,
),
'annotations_beat': download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-J-2001.BEAT.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-J-2001.BEAT.zip',
checksum='b483853da05d0fff3992879f7729bcb4',
destination_dir='annotations',
),
'annotations_sections': download_utils.RemoteFileMetadata(
filename='AIST.RWC-MDB-J-2001.CHORUS.zip',
url='https://staff.aist.go.jp/m.goto/RWC-MDB/AIST-Annotation/AIST.RWC-MDB-J-2001.CHORUS.zip',
checksum='44afcf7f193d7e48a7d99e7a6f3ed39d',
destination_dir='annotations',