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_downloader(mocker, mock_path):
mock_zip = mocker.patch.object(download_utils, 'download_zip_file')
mock_tar = mocker.patch.object(download_utils, 'download_tar_file')
mock_file = mocker.patch.object(download_utils, 'download_from_remote')
# Zip only
download_utils.downloader('a', zip_downloads=['foo'])
mock_zip.assert_called_once_with('foo', 'a', False, False)
mocker.resetall()
# tar only
download_utils.downloader('a', tar_downloads=['foo'])
mock_tar.assert_called_once_with('foo', 'a', False, False)
mocker.resetall()
# file only
download_utils.downloader('a', file_downloads=['foo'])
mock_file.assert_called_once_with('foo', 'a', False)
mocker.resetall()
# zip and tar
download_utils.downloader('a', zip_downloads=['foo'], tar_downloads=['foo'])
mock_zip.assert_called_once_with('foo', 'a', False, False)
mock_tar.assert_called_once_with('foo', 'a', False, False)
mocker.resetall()
# zip and file
download_utils.downloader('a', zip_downloads=['foo'], file_downloads=['foo'])
download_utils.downloader('a', zip_downloads=['foo'])
mock_zip.assert_called_once_with('foo', 'a', False, False)
mocker.resetall()
# tar only
download_utils.downloader('a', tar_downloads=['foo'])
mock_tar.assert_called_once_with('foo', 'a', False, False)
mocker.resetall()
# file only
download_utils.downloader('a', file_downloads=['foo'])
mock_file.assert_called_once_with('foo', 'a', False)
mocker.resetall()
# zip and tar
download_utils.downloader('a', zip_downloads=['foo'], tar_downloads=['foo'])
mock_zip.assert_called_once_with('foo', 'a', False, False)
mock_tar.assert_called_once_with('foo', 'a', False, False)
mocker.resetall()
# zip and file
download_utils.downloader('a', zip_downloads=['foo'], file_downloads=['foo'])
mock_zip.assert_called_once_with('foo', 'a', False, False)
mock_file.assert_called_once_with('foo', 'a', False)
mocker.resetall()
# tar and file
download_utils.downloader('a', tar_downloads=['foo'], file_downloads=['foo'])
mock_tar.assert_called_once_with('foo', 'a', False, False)
mock_file.assert_called_once_with('foo', 'a', False)
mocker.resetall()
if data_home is None:
data_home = utils.get_default_dataset_path(DATASET_DIR)
info_message = """
To download this dataset, visit:
https://zenodo.org/record/2620624#.XKZc7hNKh24
and request access.
Once downloaded, unzip the file MedleyDB-Pitch.zip
and copy the result to:
{data_home}
""".format(
data_home=data_home
)
download_utils.downloader(
data_home, info_message=info_message, force_overwrite=force_overwrite
)
def download(data_home=None):
"""Download TinySOL.
Args:
data_home (str): Local path where the dataset is stored.
If `None`, looks for the data in the default directory, `~/mir_datasets`
"""
if data_home is None:
data_home = utils.get_default_dataset_path(DATASET_DIR)
download_utils.downloader(
data_home,
tar_downloads=[AUDIO_REMOTE],
file_downloads=[ANNOTATION_REMOTE],
cleanup=True,
)
# Connect to the instance
$ INSTANCE_HOSTNAME=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID | jq -r .Reservations[0].Instances[0].PublicDnsName)
$ MSD_FOLDER={msd_folder}
$ ssh -A -i $PEM_PATH ubuntu@$INSTANCE_HOSTNAME
# On the instance, mount the MSD:
$ sudo mkdir $MSD_FOLDER
$ sudo mount $DEVICE $MSD_FOLDER
$ sudo chmod 777 $MSD_FOLDER'
""".format(
msd_folder=data_home
)
download_utils.downloader(data_home, info_message=info_message)
def download(data_home=None):
"""Download GuitarSet.
Args:
data_home (str): Local path where the dataset is stored.
If `None`, looks for the data in the default directory, `~/mir_datasets`
"""
if data_home is None:
data_home = utils.get_default_dataset_path(DATASET_DIR)
download_utils.downloader(
data_home,
zip_downloads=[
ANNOTATION_REMOTE,
AUDIO_HEX_CLN_REMOTE,
AUDIO_HEX_REMOTE,
AUDIO_MIC_REMOTE,
AUDIO_MIX_REMOTE,
],
cleanup=True,
)