Skip to content

Commit 0892621

Browse files
committed
music21 nto compatible with cache
1 parent 61921ac commit 0892621

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ which will download musif and all its necessary dependencies.
1818
## jSymbolic and music21 features
1919
Currently, musif is able to process and integrate jsymbolic as well as basic music21 features. If jsymbolic features are selected, Java JRE >= 8 must be installed in your OS and the `JAVA_HOME` environment variable is correctly set. `jSymbolic` will be downloaded automatically at the first run. You can force the download of `jSymbolic` and the check of Java installation by running `python -m musif.extract.features.jsymbolic`.
2020

21-
*Important*: right now jSymbolic features are NOT guaranteed to be compatible with musif's cache system, unlike some music21 stock features.
21+
*Important*: right now music21 and jSymbolic features are NOT guaranteed to be compatible with musif's cache system, unlike some music21 stock features.
2222

2323
In case of problems when installing Java or getting it to work as a command, these sites might be helpful:
2424
https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-do-I-install-Java-on-Ubuntu
@@ -35,8 +35,7 @@ https://github.com/DIDONEproject/music_symbolic_features
3535

3636
## Changelog
3737

38-
#### v1.2
39-
* fixed bug with muisc21 features not compatible with cache system. Now only those compatible will be computed
38+
#### v1.1.4
4039
* include MUSIF_ID
4140
* bug fix in dynamic features
4241
* include Key Signature feature

musif/extract/extract.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from musif.extract.utils import (cast_mixed_dtypes,
2727
extract_global_time_signature,
2828
process_musescore_file)
29-
from musif.logs import ldebug, lerr, linfo, lwarn, pdebug, perr, pinfo
29+
from musif.logs import ldebug, lerr, linfo, lwarn, pdebug, perr, pinfo, pwarn
3030
from musif.musescore import constants as mscore_c
3131
from musif.musicxml import constants as musicxml_c
3232
from musif.musicxml import (extract_numeric_tempo, fix_repeats, name_parts,
@@ -249,12 +249,13 @@ def __init__(self, *args, **kwargs):
249249
self.exclude_files = kwargs.get("exclude_files") or getattr(
250250
self._cfg, "exclude_files", None
251251
)
252-
# self.regex = re.compile("from {FEATURES_MODULES}.([\w\.]+) import")
253-
# creates the directory for the cache
252+
if any(i in self._cfg.features for i in ("jsymbolic","music21")):
253+
pwarn("\nEither music21 or jsymbolic features were requested. musif's caching system is not compatible with these, so cache will be disabled! \n")
254+
self._cfg.cache_dir = None
255+
254256
if self._cfg.cache_dir is not None:
255257
pinfo("Cache activated!")
256258
Path(self._cfg.cache_dir).mkdir(exist_ok=True)
257-
258259
if "jsymbolic" in self._cfg.features:
259260
from musif.extract.features import jsymbolic
260261

@@ -361,7 +362,7 @@ def _init_score_processing(self, idx: int, filename: PurePath):
361362
if self._cfg.cache_dir is not None:
362363
cache_name = (
363364
Path(self._cfg.cache_dir)
364-
/ filename.parent
365+
# / filename.parent
365366
/ (filename.name + CACHE_FILE_EXTENSION)
366367
)
367368
cache_name.parent.mkdir(parents=True, exist_ok=True)

musif/extract/features/harmony/handler.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def update_score_objects(
8484
)
8585

8686
except Exception as e:
87-
perr(f"Harmony problem found: {str(e)} in file {file_name}")
87+
name = score_features[FILE_NAME]
88+
perr(f"Harmony problem found: {str(e)} in file {name}")
8889

8990
finally:
9091
score_features.update(features)

musif/extract/features/harmony/utils.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,9 @@ def get_chords(harmonic_analysis):
449449

450450
numerals_and_types = [
451451
str(chord) + str(types[index]).replace("Mm", "").replace("mm", "")
452-
if types[index] not in ("M", "m")
453-
else str(chord)
454-
for index, chord in enumerate(numerals)
455-
]
452+
if types[index] not in ("M", "m") else str(chord) for index, chord in enumerate(numerals)]
456453

457454
# chords_order = sort_labels(numerals_and_types, numeral=['I', 'i', 'V', 'v', 'VII', 'vii', 'II', 'ii', 'IV', 'iv','VI','vi','III','iii'], chordtype=['', '7', '+', 'o', '%', 'M', 'm','It'], drop_duplicates=True)
458-
459455
chords_dict = count_chords(numerals_and_types) # ,order)
460456

461457
# Exception for #viio chords

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies = [
1212
"deepdiff>=6.2.1",
1313
]
1414
name = "musif"
15-
version = "1.2"
15+
version = "1.1.4"
1616
description = "Music feature extraction library from the DIDONE project"
1717
authors = [{ name = "Didone Project", email = "[email protected]" }]
1818
requires-python = ">=3.10"

0 commit comments

Comments
 (0)