From be1166c0d507558cc49f4f86b2704a43b487edfb Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Thu, 23 May 2024 12:13:17 -0400 Subject: [PATCH 1/7] try 3.12 --- .github/workflows/test-and-run.yml | 2 +- pyproject.toml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-and-run.yml b/.github/workflows/test-and-run.yml index 0767718..0cff68c 100644 --- a/.github/workflows/test-and-run.yml +++ b/.github/workflows/test-and-run.yml @@ -10,7 +10,7 @@ jobs: lint-and-test: strategy: matrix: - python-version: ["3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] exclude: - os: windows-latest diff --git a/pyproject.toml b/pyproject.toml index 1db4d64..a3c830b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,10 +18,10 @@ homepage = "https://fasttrackiverse.github.io/fasttrackpy/" repository = "https://github.com/FastTrackiverse/fasttrackpy" [tool.poetry.dependencies] -python = ">=3.10,<3.12" +python = ">=3.10,<=3.12" praat-parselmouth = "^0.4.3" -scipy = {version = "^1.11.3", python = ">=3.10,<3.12"} -numpy = {version = "^1.26.1", python = ">=3.10,<3.12"} +scipy = {version = "^1.11.3", python = ">=3.10,<=3.12"} +numpy = {version = "^1.26.1", python = ">=3.10,<=3.12"} polars = "^0.20.18" pytest-cov = "^4.1.0" pytest = "^7.4.3" From 8cef44ae3b8506931b3dc778e0ae906e5f7d4bae Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Thu, 23 May 2024 12:16:04 -0400 Subject: [PATCH 2/7] correct python versions --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a3c830b..df307c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,10 +18,10 @@ homepage = "https://fasttrackiverse.github.io/fasttrackpy/" repository = "https://github.com/FastTrackiverse/fasttrackpy" [tool.poetry.dependencies] -python = ">=3.10,<=3.12" +python = ">=3.10,<3.13" praat-parselmouth = "^0.4.3" -scipy = {version = "^1.11.3", python = ">=3.10,<=3.12"} -numpy = {version = "^1.26.1", python = ">=3.10,<=3.12"} +scipy = {version = "^1.11.3", python = ">=3.10,<3.13"} +numpy = {version = "^1.26.1", python = ">=3.10,<3.13"} polars = "^0.20.18" pytest-cov = "^4.1.0" pytest = "^7.4.3" From 39d2253041a504f063b38eb649d65ca5da05b841 Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Thu, 23 May 2024 12:27:08 -0400 Subject: [PATCH 3/7] remove parallelization on windows --- src/fasttrackpy/patterns/audio_textgrid.py | 11 ++++++++--- src/fasttrackpy/patterns/corpus.py | 11 +++++++---- src/fasttrackpy/patterns/just_audio.py | 10 +++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/fasttrackpy/patterns/audio_textgrid.py b/src/fasttrackpy/patterns/audio_textgrid.py index 0d7fda4..5b4fb6d 100644 --- a/src/fasttrackpy/patterns/audio_textgrid.py +++ b/src/fasttrackpy/patterns/audio_textgrid.py @@ -5,6 +5,7 @@ from fasttrackpy.patterns.just_audio import create_audio_checker from fasttrackpy.utils.safely import safely, filter_nones import re +import os from pathlib import Path from tqdm import tqdm @@ -169,9 +170,13 @@ def process_audio_textgrid( ] n_jobs = cpu_count() - candidate_list = Parallel(n_jobs=n_jobs)( - get_candidates(args_dict=arg) for arg in tqdm(arg_list) - ) + if os.name == "posix": + candidate_list = Parallel(n_jobs=n_jobs)( + get_candidates(args_dict=arg) for arg in tqdm(arg_list) + ) + else: + candidate_list = [get_candidates(arg) for arg in tqdm(arg_list)] + candidate_list, target_intervals = filter_nones(candidate_list, [candidate_list, target_intervals]) for cand, interval in zip(candidate_list, target_intervals): cand.interval = interval diff --git a/src/fasttrackpy/patterns/corpus.py b/src/fasttrackpy/patterns/corpus.py index ccdf14d..c8d1b4e 100644 --- a/src/fasttrackpy/patterns/corpus.py +++ b/src/fasttrackpy/patterns/corpus.py @@ -13,6 +13,7 @@ from operator import add from joblib import Parallel, cpu_count, delayed import warnings +import os @@ -215,10 +216,12 @@ def process_corpus( ] n_jobs = cpu_count() - candidate_list = Parallel(n_jobs=n_jobs)( - get_candidates(args_dict=arg) for arg in tqdm(arg_list) - ) - + if os.name == "posix": + candidate_list = Parallel(n_jobs=n_jobs)( + get_candidates(args_dict=arg) for arg in tqdm(arg_list) + ) + else: + candidate_list = [get_candidates(arg) for arg in tqdm(arg_list)] candidate_list, intervals = filter_nones(candidate_list, [candidate_list, intervals]) for cand, interval in zip(candidate_list, intervals): cand.interval = interval diff --git a/src/fasttrackpy/patterns/just_audio.py b/src/fasttrackpy/patterns/just_audio.py index b48316b..2b4f47c 100644 --- a/src/fasttrackpy/patterns/just_audio.py +++ b/src/fasttrackpy/patterns/just_audio.py @@ -11,6 +11,7 @@ from tqdm import tqdm from joblib import Parallel, cpu_count, delayed +import os try: import magic @@ -204,9 +205,12 @@ def process_directory( ] n_jobs = cpu_count() - all_candidates = Parallel(n_jobs=n_jobs)( - wrapped_audio(args_dict=arg) for arg in tqdm(arg_list) - ) + if os.name == "posix": + all_candidates = Parallel(n_jobs=n_jobs)( + wrapped_audio(args_dict=arg) for arg in tqdm(arg_list) + ) + else: + all_candidates = [wrapped_audio(arg) for arg in tqdm(arg_list)] all_candidates, all_audio = filter_nones(all_candidates, [all_candidates, all_audio]) for x, path in zip(all_candidates, all_audio): x.file_name = Path(str(path)).name From 59546b781448f983613aa754812e4ba0d773309c Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Fri, 24 May 2024 09:14:55 -0400 Subject: [PATCH 4/7] trying to get just_audio to pass --- src/fasttrackpy/patterns/just_audio.py | 33 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/fasttrackpy/patterns/just_audio.py b/src/fasttrackpy/patterns/just_audio.py index 2b4f47c..b980940 100644 --- a/src/fasttrackpy/patterns/just_audio.py +++ b/src/fasttrackpy/patterns/just_audio.py @@ -12,6 +12,9 @@ from tqdm import tqdm from joblib import Parallel, cpu_count, delayed import os +import sys +import logging +logging.basicConfig(level=logging.INFO) try: import magic @@ -139,9 +142,24 @@ def process_audio_file( @delayed @safely(message = "There was a problem processing an audio file.") -def wrapped_audio(args_dict): +def get_candidates_delayed(args_dict): return process_audio_file(**args_dict) +@safely(message = "There was a problem processing an audio file.") +def get_candidates(args_dict): + return process_audio_file(**args_dict) + +def run_candidates(arg_list, parallel): + if parallel: + n_jobs = cpu_count() + all_candidates = Parallel(n_jobs=n_jobs)( + get_candidates_delayed(args_dict=arg) for arg in tqdm(arg_list) + ) + else: + all_candidates = [get_candidates(args_dict=arg) for arg in tqdm(arg_list)] + + return all_candidates + def process_directory( path: str|Path, min_max_formant:float = 4000, @@ -203,15 +221,14 @@ def process_directory( } for x in all_audio ] - n_jobs = cpu_count() - if os.name == "posix": - all_candidates = Parallel(n_jobs=n_jobs)( - wrapped_audio(args_dict=arg) for arg in tqdm(arg_list) - ) - else: - all_candidates = [wrapped_audio(arg) for arg in tqdm(arg_list)] + all_candidates = run_candidates( + arg_list, os.name != "posix" and \ + sys.version_info.major == 3 and \ + sys.version_info.minor == 12 + ) all_candidates, all_audio = filter_nones(all_candidates, [all_candidates, all_audio]) + for x, path in zip(all_candidates, all_audio): x.file_name = Path(str(path)).name From 5f3fc87ad6dceaf1d91e11a9b5fbddb31f3143a4 Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Fri, 24 May 2024 09:37:25 -0400 Subject: [PATCH 5/7] nerf parallelization on just windows, python 3.12 --- src/fasttrackpy/patterns/audio_textgrid.py | 39 +++++++++++++++++----- src/fasttrackpy/patterns/corpus.py | 36 +++++++++++++++----- src/fasttrackpy/patterns/just_audio.py | 13 +++++--- 3 files changed, 66 insertions(+), 22 deletions(-) diff --git a/src/fasttrackpy/patterns/audio_textgrid.py b/src/fasttrackpy/patterns/audio_textgrid.py index 5b4fb6d..48a9edb 100644 --- a/src/fasttrackpy/patterns/audio_textgrid.py +++ b/src/fasttrackpy/patterns/audio_textgrid.py @@ -6,6 +6,7 @@ from fasttrackpy.utils.safely import safely, filter_nones import re import os +import sys from pathlib import Path from tqdm import tqdm @@ -66,7 +67,6 @@ def get_target_intervals( return intervals -@delayed @safely(message="There was a problem getting some candidate tracks.") def get_candidates(args_dict): with warnings.catch_warnings(): @@ -76,6 +76,27 @@ def get_candidates(args_dict): warnings.warn("formant tracking error") return candidates +@delayed +@safely(message="There was a problem getting some candidate tracks.") +def get_candidates_delayed(args_dict): + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + candidates = CandidateTracks(**args_dict) + if candidates.winner.formants.shape[1] == 1: + warnings.warn("formant tracking error") + return candidates + +def run_candidates(arg_list, parallel:bool): + if parallel: + n_jobs = cpu_count() + all_candidates = Parallel(n_jobs=n_jobs)( + get_candidates_delayed(args_dict=arg) for arg in tqdm(arg_list) + ) + return all_candidates + + all_candidates = [get_candidates(args_dict=arg) for arg in tqdm(arg_list)] + return all_candidates + def process_audio_textgrid( audio_path: str|Path, textgrid_path: str|Path, @@ -169,14 +190,14 @@ def process_audio_textgrid( } for x, interval in zip(sound_parts, target_intervals) ] - n_jobs = cpu_count() - if os.name == "posix": - candidate_list = Parallel(n_jobs=n_jobs)( - get_candidates(args_dict=arg) for arg in tqdm(arg_list) - ) - else: - candidate_list = [get_candidates(arg) for arg in tqdm(arg_list)] - + windows_3_12 = os.name != "posix" and \ + sys.version_info.major == 3 and \ + sys.version_info.minor == 12 + + candidate_list = run_candidates( + arg_list, not windows_3_12 + ) + candidate_list, target_intervals = filter_nones(candidate_list, [candidate_list, target_intervals]) for cand, interval in zip(candidate_list, target_intervals): cand.interval = interval diff --git a/src/fasttrackpy/patterns/corpus.py b/src/fasttrackpy/patterns/corpus.py index c8d1b4e..49a4ec7 100644 --- a/src/fasttrackpy/patterns/corpus.py +++ b/src/fasttrackpy/patterns/corpus.py @@ -14,7 +14,7 @@ from joblib import Parallel, cpu_count, delayed import warnings import os - +import sys try: @@ -115,6 +115,15 @@ def get_sound_parts( return sound_parts @delayed +@safely(message = "There was a problem getting some candidate tracks.") +def get_candidates_delayed(args_dict): + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + candidates = CandidateTracks(**args_dict) + if candidates.winner.formants.shape[1] == 1: + warnings.warn("formant tracking error") + return candidates + @safely(message = "There was a problem getting some candidate tracks.") def get_candidates(args_dict): with warnings.catch_warnings(): @@ -124,6 +133,16 @@ def get_candidates(args_dict): warnings.warn("formant tracking error") return candidates +def run_candidates(arg_list, parallel:bool): + if parallel: + n_jobs = cpu_count() + all_candidates = Parallel(n_jobs=n_jobs)( + get_candidates_delayed(args_dict=arg) for arg in tqdm(arg_list) + ) + return all_candidates + + all_candidates = [get_candidates(args_dict=arg) for arg in tqdm(arg_list)] + return all_candidates def process_corpus( corpus_path: str|Path, @@ -215,13 +234,14 @@ def process_corpus( } for x, interval in zip(sound_parts, intervals) ] - n_jobs = cpu_count() - if os.name == "posix": - candidate_list = Parallel(n_jobs=n_jobs)( - get_candidates(args_dict=arg) for arg in tqdm(arg_list) - ) - else: - candidate_list = [get_candidates(arg) for arg in tqdm(arg_list)] + windows_3_12 = os.name != "posix" and \ + sys.version_info.major == 3 and \ + sys.version_info.minor == 12 + + candidate_list = run_candidates( + arg_list, not windows_3_12 + ) + candidate_list, intervals = filter_nones(candidate_list, [candidate_list, intervals]) for cand, interval in zip(candidate_list, intervals): cand.interval = interval diff --git a/src/fasttrackpy/patterns/just_audio.py b/src/fasttrackpy/patterns/just_audio.py index b980940..c30e20b 100644 --- a/src/fasttrackpy/patterns/just_audio.py +++ b/src/fasttrackpy/patterns/just_audio.py @@ -149,15 +149,15 @@ def get_candidates_delayed(args_dict): def get_candidates(args_dict): return process_audio_file(**args_dict) -def run_candidates(arg_list, parallel): +def run_candidates(arg_list, parallel:bool): if parallel: n_jobs = cpu_count() all_candidates = Parallel(n_jobs=n_jobs)( get_candidates_delayed(args_dict=arg) for arg in tqdm(arg_list) ) - else: - all_candidates = [get_candidates(args_dict=arg) for arg in tqdm(arg_list)] + return all_candidates + all_candidates = [get_candidates(args_dict=arg) for arg in tqdm(arg_list)] return all_candidates def process_directory( @@ -222,11 +222,14 @@ def process_directory( for x in all_audio ] - all_candidates = run_candidates( - arg_list, os.name != "posix" and \ + windows_3_12 = os.name != "posix" and \ sys.version_info.major == 3 and \ sys.version_info.minor == 12 + + all_candidates = run_candidates( + arg_list, not windows_3_12 ) + all_candidates, all_audio = filter_nones(all_candidates, [all_candidates, all_audio]) for x, path in zip(all_candidates, all_audio): From 2c638e131b8b5d1ac2e86bf7fe6efd960f787d12 Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Fri, 24 May 2024 09:57:30 -0400 Subject: [PATCH 6/7] python version badges --- README.md | 3 +-- docs/index.qmd | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f48b450..4e6a1e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # FastTrackPy -[![PyPI](https://img.shields.io/pypi/v/fasttrackpy)](https://pypi.org/project/fasttrackpy/) -[![Python CI](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml/badge.svg)](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml) [![codecov](https://codecov.io/gh/FastTrackiverse/fasttrackpy/graph/badge.svg?token=GOAWY4B5C8)](https://codecov.io/gh/FastTrackiverse/fasttrackpy) [![DOI](https://zenodo.org/badge/580169086.svg)](https://zenodo.org/badge/latestdoi/580169086) +[![PyPI](https://img.shields.io/pypi/v/fasttrackpy)](https://pypi.org/project/fasttrackpy/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fasttrackpy) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fasttrackpy) [![Python CI](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml/badge.svg)](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml) [![codecov](https://codecov.io/gh/FastTrackiverse/fasttrackpy/graph/badge.svg?token=GOAWY4B5C8)](https://codecov.io/gh/FastTrackiverse/fasttrackpy) [![DOI](https://zenodo.org/badge/580169086.svg)](https://zenodo.org/badge/latestdoi/580169086) A python implementation of the FastTrack method diff --git a/docs/index.qmd b/docs/index.qmd index 78d52e6..8d9935c 100644 --- a/docs/index.qmd +++ b/docs/index.qmd @@ -1,8 +1,7 @@ --- title: "Home" --- -[![PyPI](https://img.shields.io/pypi/v/fasttrackpy)](https://pypi.org/project/fasttrackpy/) -[![Python CI](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml/badge.svg)](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml) [![codecov](https://codecov.io/gh/FastTrackiverse/fasttrackpy/graph/badge.svg?token=GOAWY4B5C8)](https://codecov.io/gh/FastTrackiverse/fasttrackpy) +[![PyPI](https://img.shields.io/pypi/v/fasttrackpy)](https://pypi.org/project/fasttrackpy/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fasttrackpy) [![Python CI](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml/badge.svg)](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml) [![codecov](https://codecov.io/gh/FastTrackiverse/fasttrackpy/graph/badge.svg?token=GOAWY4B5C8)](https://codecov.io/gh/FastTrackiverse/fasttrackpy) [![DOI](https://zenodo.org/badge/580169086.svg)](https://zenodo.org/badge/latestdoi/580169086) These are the docs for `fasttrackpy`. For more info, see [the quickstart](usage/getting_started.qmd). From 01bf49b299dadac5fa538bc0efa746f20acbe766 Mon Sep 17 00:00:00 2001 From: JoFrhwld Date: Fri, 24 May 2024 09:58:06 -0400 Subject: [PATCH 7/7] version bump --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index df307c9..98e6479 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "fasttrackpy" -version = "0.4.5" +version = "0.4.6" description = "A python implementation of FastTrack" authors = [ "JoFrhwld ",