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

Added genre to ballroom datataset loader #629

Merged
merged 11 commits into from
Oct 28, 2024

Conversation

Masetto96
Copy link
Contributor

#628

The track object of the ballroom dataset does not have the annotation about the genre of the track. Therefore, the genre attribute have been included from the name of the audio path.

Test for getting the genre from the audio path has been implemented.

Following the contribution guidelines, code has been formatted and all tests passed.

@Masetto96
Copy link
Contributor Author

@genisplaja @guillemcortes plz review :)

@genisplaja
Copy link
Collaborator

hey @Masetto96, I did finally take a look at this one and LGTM. Let us update #630 so that codecov works as expected and we can try to merge this one.

Copy link
Collaborator

@genisplaja genisplaja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Almost there, I guess it works as expected, and I don't see any missing tests. Just requesting minor changes for consistency and that's ready :)
Sorry for taking that long to review... we were super busy updating soundata for the JOSS submission man. Thanks for the understanding!

tests/test_loaders.py Outdated Show resolved Hide resolved

Cached Properties:
beats (BeatData): human-labeled beat annotations
tempo (float): human-labeled tempo annotations

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove added enter. Or is it because formatting issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the new line, however I noticed that in other scripts it is sometimes present

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Was just not to unnecessary change lines. I guess it does not affect at all, I can take a look

@@ -164,6 +168,20 @@ def to_jams(self):
)


def get_genre(audio_path: Optional[str]) -> Optional[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally, for consistency, we name this functions load_<thing>(). I think it would be nice if you could use this convention here as well

@@ -130,6 +132,8 @@ def __init__(
self.beats_path = self.get_path("beats")
self.tempo_path = self.get_path("tempo")

self.genre = get_genre(self.audio_path)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While making the changes I spotted a mistake. Here I changed line 135 to self.load_genre()

Copy link
Collaborator

@genisplaja genisplaja Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! @Masetto96 although are you sure is self.load_genre()? I think that the load_genre() function is outside the class right? Shouldn't it be without the self.?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, you are right! I assumed it was part of the class but I did not look carefully. Sorry about that!

data_home = "tests/resources/mir_datasets/ballroom"
dataset = ballroom.Dataset(data_home)
track = dataset.track("Media-105901")
genre = ballroom.get_genre(track.audio_path)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made necessary changes also here

Copy link
Collaborator

@genisplaja genisplaja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I guess we need PR #631 to be merged so that the tests pass, and then we can propagate the update to this PR and merge. Thanks @Masetto96 :)

@genisplaja
Copy link
Collaborator

genisplaja commented Oct 16, 2024

hey @Masetto96, very close but there is a small thing that we are still missing. All custom load_* methods are passed through a test to check that if a wrong filepath is given, an error should be thrown, but in your load_genre function that does not happen, and that's why the tests are not passing. I guess all files should have a genre right? Because all audio files are contained in a "genre"-named folder. Then it would make sense that an error is thrown if the audio path is not found.

Then, you would need to see if the filepath exists, and throw, I think, a FileNotFound error otherwise.

@Masetto96
Copy link
Contributor Author

Done! Let me know if I there is something else. Thank you for the code review.

@genisplaja
Copy link
Collaborator

Hey @Masetto96 man, finally fetched your fork and played around to figure out the issue. Sorry that I didn't notice that we were using a too overcomplicated solution for a problem that should be way easier to address. Let me explain how we should be actually loading the genre:

  • The load_genre method should not exist.
  • You can directly get self.genre as an attribute of the Track class like this: self.genre = os.path.basename(os.path.dirname(self.audio_path)).lower(), in the Track init.
  • Then, the test_load_genre is also not needed anymore.

In the end, the genre annotation is not contained in a local file, but rather in a filepath that is already contained in the library itself (in the .json index), so you wouldn't even need to download the dataset to get the genre. Therefore, we don't need a cached property for that. genre can be a simple attribute of the ballroom Track class and you would read from the path. Sorry that I did not notice that earlier... thanks for following my suggestions man. If you could update that, I am pretty sure the tests will pass (are passing locally for me), so we will be able to move on with that one. Thanks again and sorry for the confusion :)

@Masetto96
Copy link
Contributor Author

Masetto96 commented Oct 21, 2024

Of course @genisplaja , your suggestion makes a lot of sense!

Copy link

codecov bot commented Oct 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.08%. Comparing base (dc3ac00) to head (8f8a3ae).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
+ Coverage   97.07%   97.08%   +0.01%     
==========================================
  Files          64       64              
  Lines        7392     7388       -4     
==========================================
- Hits         7176     7173       -3     
+ Misses        216      215       -1     

@tanmayy24 tanmayy24 merged commit 73edbf9 into mir-dataset-loaders:master Oct 28, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

3 participants