-
Notifications
You must be signed in to change notification settings - Fork 18
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
Load Scores from URL #404
Conversation
# Conflicts: # partitura/io/__init__.py # partitura/score.py
partitura/io/__init__.py
Outdated
extension = os.path.splitext(url)[-1] | ||
|
||
# Create a temporary file | ||
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=extension) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ReportAttention: Patch coverage is
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. |
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 functionsis_url
anddownload_file
to handle URL inputs, and modified theload_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 theprocess_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.