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

Load Scores from URL #404

Merged
merged 18 commits into from
Jan 10, 2025
Merged

Load Scores from URL #404

merged 18 commits into from
Jan 10, 2025

Conversation

manoskary
Copy link
Member

This pull request introduces several enhancements to the partitura library, including the addition of URL handling for score loading and updates to interval definitions. Additionally, new unit tests have been added to validate these changes.

Enhancements to score loading:

  • partitura/io/__init__.py: Added functions is_url and download_file to handle URL inputs, and modified the load_score function to support loading scores from URLs.

Updates to interval definitions:

  • partitura/score.py: Corrected the intervals for "vi" and "vii" from minor to major in the process_local_key function.

New unit tests:

  • tests/test_urlload.py: Added new unit tests to ensure that scores can be loaded from URLs for various file formats, including Kern, MEI, MIDI, and MusicXML.

@manoskary manoskary added the enhancement New feature or request label Dec 3, 2024
@manoskary manoskary self-assigned this Dec 3, 2024
@manoskary manoskary changed the title Load Scores with URL Load Scores from URL Dec 3, 2024
extension = os.path.splitext(url)[-1]

# Create a temporary file
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=extension)
Copy link
Member

Choose a reason for hiding this comment

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

Won't it be the case that this file is never deleted, and keep accumulating on the computer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree. Probably, I need to find a better solution and debug. The load score file needs access to the file to check the extension but maybe when delete=True the file is not deleted immediately when loaded. I will push a change soon.

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out that for python version 3.8 the temporary file options are not the same as for newer versions of python therefore I had to add more edits to ensure the deletion of tmp files immediately after the end of the function.

delete_on_close=False and delete=True should now delete file upon session end.
options for delete on close are not available on python version 3.8 therefore more restructuring on the code was needed.
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 93.33333% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.27%. Comparing base (3cd1e41) to head (108a4a6).
Report is 323 commits behind head on develop.

Files with missing lines Patch % Lines
partitura/io/__init__.py 88.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #404      +/-   ##
===========================================
- Coverage    84.11%   82.27%   -1.84%     
===========================================
  Files           82       90       +8     
  Lines        14506    15833    +1327     
===========================================
+ Hits         12202    13027     +825     
- Misses        2304     2806     +502     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@manoskary manoskary merged commit 31faf74 into develop Jan 10, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants