olivecha / guitarsounds

python library to analyse guitar sounds
MIT License
6 stars 0 forks source link

Loading sound file crashes GUI #33

Closed cwitkowitz closed 1 year ago

cwitkowitz commented 1 year ago

I receive the following errors when attempting to load a sound file through each button of the GUI:

Single Sound

AttributeError                            Traceback (most recent call last)
File ~/Desktop/guitarsounds/guitarsounds/interface.py:783, in guitarGUI.define_sound_names(self)
    779     # Case for a single sound analysis
    780     if self.analysis == 'Single':
    781 
    782         # get the filenames
--> 783         self.file_names = [ky for ky in self.single_file_selector.value.keys()]

AttributeError: 'tuple' object has no attribute 'keys'

Dual Sounds

AttributeError                            Traceback (most recent call last)
File ~/Desktop/guitarsounds/guitarsounds/interface.py:819, in guitarGUI.define_sound_names(self)
    817     if self.analysis == 'Dual':
    818         # get the file names
--> 819         name1 = [ky for ky in self.dual_file_selector_1.value.keys()][0]
    820         name2 = [ky for ky in self.dual_file_selector_2.value.keys()][0]

AttributeError: 'tuple' object has no attribute 'keys'

Multiple Sounds

AttributeError                            Traceback (most recent call last)
File ~/Desktop/guitarsounds/guitarsounds/interface.py:824, in guitarGUI.define_sound_names(self)
    823 elif self.analysis == 'Multiple':
--> 824     self.file_names = [ky for ky in self.mult_file_selector.value.keys()]

AttributeError: 'tuple' object has no attribute 'keys'

Each results in a crash.

ebezzam commented 1 year ago

I didn't have any issue when loading sound(s) through each of the buttons. I'm wondering what could cause a difference. You mind sharing your Python version and package versions?

olivecha commented 1 year ago

It seems the 8+ version of ipywidgets stores the values associated to a file in a list of dicts and the version 7. in a dict.

ipywidgets 7.6.5 :

class FileUpload(DescriptionWidget, ValueWidget, CoreWidget):
    """
    Upload file(s) from browser to Python kernel as bytes
    """
    [...]
    error = Unicode(help='Error message').tag(sync=True)
    value = Dict(read_only=True)

ipywidgets 8.0.4

class FileUpload(DescriptionWidget, ValueWidget, CoreWidget):
    """File upload widget

    This creates a file upload input that allows the user to select
    one or more files to upload. The file metadata and content
    can be retrieved in the kernel.

    Examples
    --------

    >>> import ipywidgets as widgets
    >>> uploader = widgets.FileUpload()

    # After displaying `uploader` and uploading a file:

    >>> uploader.value
    [
      {
        'name': 'example.txt',
        'type': 'text/plain',
        'size': 36,
        'last_modified': datetime.datetime(2020, 1, 9, 15, 58, 43, 321000, tzinfo=datetime.timezone.utc),
        'content': <memory at 0x10c1b37c8>
      }
    ]
    >>> uploader.value[0].content.tobytes()
    b'This is the content of example.txt.\n'

I've specified the ipywidgets version in requirements.txt

cwitkowitz commented 1 year ago

This is indeed fixed by installing ipywidgets==7.6.5, however I don't see the referenced updates to requirements.txt. I will close the issue after that update is made.

You may also consider adding jupyter to requirements.txt, as I needed to install it manually in order to run jupyter notebook from the command line.

olivecha commented 1 year ago

The requirements.txt were only update on the JOSS branch, I've merged this change on the main branch and added jupyter to requirements.txt.