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

A bunch of maintenance work for the repo #203

Merged
merged 6 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/matrix-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: FedericoCarboni/setup-ffmpeg@v3
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ jobs:
# #no-ci in the commit log flags commit we don't want CI-validated
if: ${{ !contains(github.event.head_commit.message, '#no-ci') }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: FedericoCarboni/setup-ffmpeg@v3

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.7"
cache: "pip"
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
# Legal check: make sure we don't have or introduce GPL dependencies
if pip-licenses | grep -v 'Artistic License' | grep -v LGPL | grep GNU; then echo 'Please avoid introducing *GPL dependencies'; false; fi

- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
directory: ./test
token: ${{ secrets.CODECOV_TOKEN }} # optional but apparently makes upload more reliable
Expand Down Expand Up @@ -82,12 +82,12 @@ jobs:
runs-on: windows-latest
if: ${{ !contains(github.event.head_commit.message, '#no-ci') }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: FedericoCarboni/setup-ffmpeg@v3

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.7"
cache: "pip"
Expand Down
4 changes: 4 additions & 0 deletions readalongs/audio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
in millisecond slices and lets us manipulate them as if they were simple lists.
"""

import logging
from typing import Union

from pydub import AudioSegment

from readalongs.log import LOGGER

# quiet pydub's logging
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, the beauty of logging 😉

logging.getLogger("pydub.converter").setLevel(logging.WARNING)


def join_section(audio: AudioSegment, audio_to_insert: AudioSegment, start: int):
"""Given two AudioSegments, insert the second into the first at start (ms)"""
Expand Down
17 changes: 17 additions & 0 deletions readme-heroku.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Our production Heroku deployment is controlled by the following files:
- `Procfile`: tells Heroku what command to launch in each Dyno;
- `runtime.txt`: tells Heroku which run-time engine to use (i.e., which version of Python);

Heroku detects Python by default, but `runtime.txt` lets us specify/bump the version as needed;
- `requirements.txt`: tells Heroku what our production dependencies are.

Updating `g2p`:
- By default, `g2p` only gets updated for `readalong-studio` on Heroku when:
- we make a new release of `g2p` on PyPI
- we update `requirements.min.txt` here to ask for that release
- Manual override: it is also possible to update g2p to the current commit on the `main` branch using this procedure:
- Change `requirements.min.txt` to specify `g2p @ git+https://github.com/roedoejet/g2p@main`.
- Commit that change to `main` in a sandbox connected to Heroku.
- `git push heroku main`
- This will force a build which will fetch the main branch of g2p from GitHub.
- Subsequent builds reuse the cached g2p, so they'll reuse this one. Exception: if `runtime.txt` is updated, a fresh build is done and g2p will be reverted to the latest published version.
3 changes: 1 addition & 2 deletions requirements.min.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ click>=8.0.4
coloredlogs>=10.0
# Need to install this specifically from git as the sdist is broken
editdistance @ git+https://github.com/roy-ht/[email protected] ; python_version == '3.12'
fastapi>=0.78.0
# Note: when we move g2p to >=2, we will need fastapi>=0.100.0 which requires httpx
fastapi>=0.100.0
g2p>=1.1.20230822, <2.1
httpx>=0.24.1
lxml==4.9.4
Expand Down
8 changes: 7 additions & 1 deletion test/basic_test_case.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Common base class for the ReadAlongs test suites"""

import logging
import tempfile
from pathlib import Path
from unittest import TestCase
Expand All @@ -20,7 +21,6 @@ class BasicTestCase(TestCase):
text_file = self.data_dir / "ej-fra.txt"
"""

LOGGER.setLevel("DEBUG")
data_dir = Path(__file__).parent / "data"

# Set this to True to keep the temp dirs after running, for manual inspection
Expand Down Expand Up @@ -59,3 +59,9 @@ def tearDown(self):
"""
if not self.keep_temp_dir_after_running:
self.tempdirobj.cleanup()

if LOGGER.level == logging.DEBUG:
# LOGGER.error("Logging level is DEBUG")
# Some test cases can set the logging level to DEBUG when they pass
# --debug to a CLI command, but don't let that affect subsequent tests.
LOGGER.setLevel(logging.INFO)
26 changes: 15 additions & 11 deletions test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,23 @@ def describe_suite(suite: TestSuite):
)


SUITES = ["all", "dev", "e2e", "prod", "api", "other"]


def run_tests(suite: str, describe: bool = False) -> bool:
"""Run the specified test suite.

Args:
suite: one of "all", "dev", etc specifying which suite to run
suite: one of SUITES, "dev" if the empty string
describe: if True, list all the test cases instead of running them.

Returns: True iff success
"""

if not suite:
LOGGER.info("No test suite specified, defaulting to dev.")
suite = "dev"

if suite == "e2e":
test_suite = TestSuite(e2e_tests)
elif suite == "api":
Expand All @@ -116,8 +123,7 @@ def run_tests(suite: str, describe: bool = False) -> bool:
test_suite = TestSuite(other_tests)
else:
LOGGER.error(
"Sorry, you need to select a Test Suite to run, one of: "
"dev, all (or prod), e2e, other"
"Sorry, you need to select a Test Suite to run, one of: " + " ".join(SUITES)
)
return False

Expand All @@ -126,19 +132,17 @@ def run_tests(suite: str, describe: bool = False) -> bool:
return True
else:
runner = TextTestRunner(verbosity=3)
return runner.run(test_suite).wasSuccessful()
success = runner.run(test_suite).wasSuccessful()
if not success:
LOGGER.error("Some tests failed. Please see log above.")
return success


if __name__ == "__main__":
describe = "--describe" in sys.argv
if describe:
sys.argv.remove("--describe")

try:
result = run_tests(sys.argv[1], describe)
if not result:
LOGGER.error("Some tests failed. Please see log above.")
sys.exit(1)
except IndexError:
LOGGER.error("Please specify a test suite to run: i.e. 'dev' or 'all'")
result = run_tests("" if len(sys.argv) <= 1 else sys.argv[1], describe)
if not result:
sys.exit(1)
4 changes: 2 additions & 2 deletions test/test_force_align.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

"""
Test force-alignment with SoundsSwallower FSG search from Python API
Test force-alignment with SoundSwallower FSG search from Python API
"""

import os
Expand All @@ -26,7 +26,7 @@


class TestForceAlignment(BasicTestCase):
"""Unit testing suite for forced-alignment with SoundsSwallower"""
"""Unit testing suite for forced-alignment with SoundSwallower"""

def test_align(self):
"""Basic alignment test case with XML input"""
Expand Down
Loading
Loading