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

Failing test_full_dataset.py with custom MultiTrack class #651

Open
HuwCheston opened this issue Dec 23, 2024 · 0 comments
Open

Failing test_full_dataset.py with custom MultiTrack class #651

HuwCheston opened this issue Dec 23, 2024 · 0 comments

Comments

@HuwCheston
Copy link

Hi, many thanks for this great package.

I'm currently creating a loader for my own dataset that defines a custom MultiTrack class and am running into some issues with running test_full_dataset.py.

As requested in the contributor information document, I run the test for my full dataset:

pytest -s tests/test_full_dataset.py --local --dataset ...

This hits an error for the test_load_mtracks function:

def test_load_mtracks(skip_remote, dataset):
    if dataset is None or dataset._multitrack_class is None:
        pytest.skip()

    # run load
    all_data = dataset.load_multitracks()

    assert isinstance(all_data, dict)

>   mtrack_ids = dataset.mm
E   AttributeError: 'Dataset' object has no attribute 'mm'

It seems that the mm attribute is not currently defined in mirdata.core.Dataset so it's not inherited by my custom Dataset class. This error can be reproduced with other datasets that also define the _multitrack_class attribute, e.g. dagstuhl_choirset, so I don't think it's necessarily something I'm doing wrong with my loader.

Steps to reproduce

(Reproducing using the dagstuhl_choirset loader that is currently implemented in mirdata, but the error is the same).

# Setting up repository and environment
git clone https://github.com/mir-dataset-loaders/mirdata.git
cd mirdata
python3 -m venv venv
source venv/bin/activate

# Installing dependencies
pip install -e .
pip install ."[tests]" ."[docs]"
pip install ."[dali]" ."[haydn_op20]" ."[cipi]"

pytest -s tests/test_full_dataset.py --local --dataset dagstuhl_choirset

Hacky fix

Looking at the code, it seems like the mm attribute should be an iterable of multitrack IDs. A hacky fix that I'm using in my loader is to define the .mm attribute in my Dataset after calling super().__init__() and populating it with the multitrack IDs from the ._index attribute. E.g.:

@core.docstring_inherit(core.Dataset)
class Dataset(core.Dataset):
    def __init__(self, data_home=None, version="default"):
        super().__init__(
            ...
        )
        self.mm = list(self._index["multitracks"].keys())

This allows the test to pass, at least for my dataset.

System information

  • Python 3.10.12
  • Ubuntu 22.04.1
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