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

Multiple errors from code example in Datasets doc page #79

Open
drscotthawley opened this issue Nov 18, 2023 · 1 comment
Open

Multiple errors from code example in Datasets doc page #79

drscotthawley opened this issue Nov 18, 2023 · 1 comment

Comments

@drscotthawley
Copy link

Hi. I'm excited to try this but having trouble with the instructions. Taking the code from the page: https://salu133445.github.io/muspy/datasets/index.html

Even just the top part:

import muspy

# Download and extract the dataset
nes = muspy.NESMusicDatabase("data/nes/", download_and_extract=True)

Results in the error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
[<ipython-input-3-8aca46b7f8b4>](https://localhost:8080/#) in <cell line: 4>()
      2 
      3 # Download and extract the dataset
----> 4 nes = muspy.NESMusicDatabase("data/nes/", download_and_extract=True)
      5 
      6 # Convert the dataset to MusPy Music objects

2 frames
[/usr/local/lib/python3.10/dist-packages/muspy/datasets/base.py](https://localhost:8080/#) in __init__(self, root, download_and_extract, overwrite, cleanup, convert, kind, n_jobs, ignore_exceptions, use_converted, verbose)
   1113         verbose: bool = True,
   1114     ):
-> 1115         RemoteDataset.__init__(
   1116             self,
   1117             root,

[/usr/local/lib/python3.10/dist-packages/muspy/datasets/base.py](https://localhost:8080/#) in __init__(self, root, download_and_extract, overwrite, cleanup, verbose)
    572         super().__init__()
    573         self.root = Path(root).expanduser().resolve()
--> 574         self.root.mkdir(exist_ok=True)
    575 
    576         if download_and_extract:

[/usr/lib/python3.10/pathlib.py](https://localhost:8080/#) in mkdir(self, mode, parents, exist_ok)
   1173         """
   1174         try:
-> 1175             self._accessor.mkdir(self, mode)
   1176         except FileNotFoundError:
   1177             if not parents or self.parent == self:

FileNotFoundError: [Errno 2] No such file or directory: '/content/data/nes'

Apparently it's not creating the directory it needs, however that's not the only issue. If I manually create the directory via

mkdir -p /content/data/nes

and then re-run that code, then we get a new errors:

Downloading source : http://deepyeti.ucsd.edu/cdonahue/nesmdb/nesmdb_midi.tar.gz ...
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
[<ipython-input-6-523fa1721f76>](https://localhost:8080/#) in <cell line: 4>()
      2 
      3 # Download and extract the dataset
----> 4 nes = muspy.NESMusicDatabase("data/nes/", download_and_extract=True)

11 frames
[/usr/local/lib/python3.10/dist-packages/muspy/datasets/base.py](https://localhost:8080/#) in __init__(self, root, download_and_extract, overwrite, cleanup, convert, kind, n_jobs, ignore_exceptions, use_converted, verbose)
   1113         verbose: bool = True,
   1114     ):
-> 1115         RemoteDataset.__init__(
   1116             self,
   1117             root,

[/usr/local/lib/python3.10/dist-packages/muspy/datasets/base.py](https://localhost:8080/#) in __init__(self, root, download_and_extract, overwrite, cleanup, verbose)
    575 
    576         if download_and_extract:
--> 577             self.download_and_extract(
    578                 overwrite=overwrite, cleanup=cleanup, verbose=verbose
    579             )

[/usr/local/lib/python3.10/dist-packages/muspy/datasets/base.py](https://localhost:8080/#) in download_and_extract(self, overwrite, cleanup, verbose)
    705 
    706         """
--> 707         return self.download(overwrite=overwrite, verbose=verbose).extract(
    708             cleanup=cleanup, verbose=verbose
    709         )

[/usr/local/lib/python3.10/dist-packages/muspy/datasets/base.py](https://localhost:8080/#) in download(self, overwrite, verbose)
    641 
    642         for source in self._sources.values():
--> 643             download_url(
    644                 source["url"],
    645                 self.root / source["filename"],

[/usr/local/lib/python3.10/dist-packages/muspy/datasets/utils.py](https://localhost:8080/#) in download_url(url, path, overwrite, size, md5, sha256, verbose)
    171     if verbose:
    172         print(f"Downloading source : {url} ...")
--> 173         urlretrieve(url, path, reporthook=_ProgressBar())
    174         print(f"Successfully downloaded source : {path} .")
    175     else:

[/usr/lib/python3.10/urllib/request.py](https://localhost:8080/#) in urlretrieve(url, filename, reporthook, data)
    239     url_type, path = _splittype(url)
    240 
--> 241     with contextlib.closing(urlopen(url, data)) as fp:
    242         headers = fp.info()
    243 

[/usr/lib/python3.10/urllib/request.py](https://localhost:8080/#) in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    214     else:
    215         opener = _opener
--> 216     return opener.open(url, data, timeout)
    217 
    218 def install_opener(opener):

[/usr/lib/python3.10/urllib/request.py](https://localhost:8080/#) in open(self, fullurl, data, timeout)
    523         for processor in self.process_response.get(protocol, []):
    524             meth = getattr(processor, meth_name)
--> 525             response = meth(req, response)
    526 
    527         return response

[/usr/lib/python3.10/urllib/request.py](https://localhost:8080/#) in http_response(self, request, response)
    632         # request was successfully received, understood, and accepted.
    633         if not (200 <= code < 300):
--> 634             response = self.parent.error(
    635                 'http', request, response, code, msg, hdrs)
    636 

[/usr/lib/python3.10/urllib/request.py](https://localhost:8080/#) in error(self, proto, *args)
    561         if http_err:
    562             args = (dict, 'default', 'http_error_default') + orig_args
--> 563             return self._call_chain(*args)
    564 
    565 # XXX probably also want an abstract factory that knows when it makes

[/usr/lib/python3.10/urllib/request.py](https://localhost:8080/#) in _call_chain(self, chain, kind, meth_name, *args)
    494         for handler in handlers:
    495             func = getattr(handler, meth_name)
--> 496             result = func(*args)
    497             if result is not None:
    498                 return result

[/usr/lib/python3.10/urllib/request.py](https://localhost:8080/#) in http_error_default(self, req, fp, code, msg, hdrs)
    641 class HTTPDefaultErrorHandler(BaseHandler):
    642     def http_error_default(self, req, fp, code, msg, hdrs):
--> 643         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    644 
    645 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 308: Permanent Redirect

Steps to reproduce:

  1. pip install muspy
  2. Copy & past above code.

Here's a link to a Colab notebook where this is implemented:
https://colab.research.google.com/drive/1dGwwqoJ1fa53zeKQCNdL9jvce_qEUF3B?usp=sharing

@drscotthawley
Copy link
Author

drscotthawley commented Nov 18, 2023

If I forget about getting it to download the dataset, and I instead manually download, then it says the directory is empty (which it's not):

!wget -N https://storage.googleapis.com/magentadata/datasets/maestro/v3.0.0/maestro-v3.0.0-midi.zip
!unzip -n -qq maestro-v3.0.0-midi.zip
!ln -s maestro-v3.0.0 Maestro

mds = muspy.FolderDataset('/content/Maestro/2004/')

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[<ipython-input-20-2a39065f183f>](https://localhost:8080/#) in <cell line: 1>()
----> 1 mds = muspy.FolderDataset('/content/Maestro/2004/')

[/usr/local/lib/python3.10/dist-packages/muspy/datasets/base.py](https://localhost:8080/#) in __init__(self, root, convert, kind, n_jobs, ignore_exceptions, use_converted)
    917 
    918         if not self._filenames:
--> 919             raise ValueError("Nothing found in the directory.")
    920 
    921         (self.root / ".muspy.success").touch()

ValueError: Nothing found in the directory.

But a simple ls shows:

!ls Maestro/2004/

MIDI-Unprocessed_SMF_02_R1_2004_01-05_ORIG_MID--AUDIO_02_R1_2004_05_Track05_wav.midi
MIDI-Unprocessed_SMF_02_R1_2004_01-05_ORIG_MID--AUDIO_02_R1_2004_06_Track06_wav.midi
MIDI-Unprocessed_SMF_02_R1_2004_01-05_ORIG_MID--AUDIO_02_R1_2004_08_Track08_wav.midi
MIDI-Unprocessed_SMF_02_R1_2004_01-05_ORIG_MID--AUDIO_02_R1_2004_10_Track10_wav.midi
MIDI-Unprocessed_SMF_05_R1_2004_01_ORIG_MID--AUDIO_05_R1_2004_02_Track02_wav.midi
MIDI-Unprocessed_SMF_05_R1_2004_01_ORIG_MID--AUDIO_05_R1_2004_03_Track03_wav.midi
MIDI-Unprocessed_SMF_05_R1_2004_02-03_ORIG_MID--AUDIO_05_R1_2004_06_Track06_wav.midi
...etc

Not sure what to do at this point. Any tips?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant