From 16257f8ec07c1823fa0b9c4c1c5073b182853b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 19 Mar 2024 14:57:50 -0700 Subject: [PATCH 1/5] move src/dailyai/tests to tests --- .github/workflows/tests.yaml | 2 +- README.md | 14 ++++++++++++++ pyproject.toml | 3 +++ src/dailyai/tests/__init__.py | 0 .../integration/integration_azure_llm.py | 0 .../integration/integration_ollama_llm.py | 0 .../integration/integration_openai_llm.py | 0 {src/dailyai/tests => tests}/test_aggregators.py | 0 {src/dailyai/tests => tests}/test_ai_services.py | 0 .../test_daily_transport_service.py | 0 {src/dailyai/tests => tests}/test_pipeline.py | 0 11 files changed, 18 insertions(+), 1 deletion(-) delete mode 100644 src/dailyai/tests/__init__.py rename {src/dailyai/tests => tests}/integration/integration_azure_llm.py (100%) rename {src/dailyai/tests => tests}/integration/integration_ollama_llm.py (100%) rename {src/dailyai/tests => tests}/integration/integration_openai_llm.py (100%) rename {src/dailyai/tests => tests}/test_aggregators.py (100%) rename {src/dailyai/tests => tests}/test_ai_services.py (100%) rename {src/dailyai/tests => tests}/test_daily_transport_service.py (100%) rename {src/dailyai/tests => tests}/test_pipeline.py (100%) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c564208e8..9ec1572c9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -40,4 +40,4 @@ jobs: - name: Test with pytest run: | pip install pytest - pytest --doctest-modules --ignore-glob="*to_be_updated*" src/dailyai + pytest --doctest-modules --ignore-glob="*to_be_updated*" src tests diff --git a/README.md b/README.md index c8dff3252..dc0c8c042 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,20 @@ If you want to use this package from another directory, you can run: pip install path_to_this_repo ``` +### Running tests + +To run tests you need to install `pytest`: + +``` +pip install pytest +``` + +Then, from the root directory, run: + +``` +pytest --doctest-modules --ignore-glob="*to_be_updated*" src tests +``` + ## Setting up your editor This project uses strict [PEP 8](https://peps.python.org/pep-0008/) formatting. diff --git a/pyproject.toml b/pyproject.toml index d2e61fdbb..e1eac802b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,3 +45,6 @@ Website = "https://daily.co" [tool.setuptools.packages.find] # All the following settings are optional: where = ["src"] + +[tool.pytest.ini_options] +pythonpath = ["src"] diff --git a/src/dailyai/tests/__init__.py b/src/dailyai/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/dailyai/tests/integration/integration_azure_llm.py b/tests/integration/integration_azure_llm.py similarity index 100% rename from src/dailyai/tests/integration/integration_azure_llm.py rename to tests/integration/integration_azure_llm.py diff --git a/src/dailyai/tests/integration/integration_ollama_llm.py b/tests/integration/integration_ollama_llm.py similarity index 100% rename from src/dailyai/tests/integration/integration_ollama_llm.py rename to tests/integration/integration_ollama_llm.py diff --git a/src/dailyai/tests/integration/integration_openai_llm.py b/tests/integration/integration_openai_llm.py similarity index 100% rename from src/dailyai/tests/integration/integration_openai_llm.py rename to tests/integration/integration_openai_llm.py diff --git a/src/dailyai/tests/test_aggregators.py b/tests/test_aggregators.py similarity index 100% rename from src/dailyai/tests/test_aggregators.py rename to tests/test_aggregators.py diff --git a/src/dailyai/tests/test_ai_services.py b/tests/test_ai_services.py similarity index 100% rename from src/dailyai/tests/test_ai_services.py rename to tests/test_ai_services.py diff --git a/src/dailyai/tests/test_daily_transport_service.py b/tests/test_daily_transport_service.py similarity index 100% rename from src/dailyai/tests/test_daily_transport_service.py rename to tests/test_daily_transport_service.py diff --git a/src/dailyai/tests/test_pipeline.py b/tests/test_pipeline.py similarity index 100% rename from src/dailyai/tests/test_pipeline.py rename to tests/test_pipeline.py From 593513c84a0693a3de65e2242de5f922ba1737c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 19 Mar 2024 15:17:48 -0700 Subject: [PATCH 2/5] github: add venv caching --- .github/workflows/tests.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 9ec1572c9..4ba5eafec 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -22,9 +22,15 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python + id: setup_python uses: actions/setup-python@v4 with: python-version: '3.10' + - name: Cache virtual environment + uses: actions/cache@v3 + with: + key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}} + path: .venv - name: Install system packages run: sudo apt-get install -y portaudio19-dev - name: Install basic dependencies From 5cdb82ad3c1c6cd1e791fadc2bf4607a8f2c87a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 19 Mar 2024 15:18:29 -0700 Subject: [PATCH 3/5] README: one more autopep8 emacs update --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index dc0c8c042..531d2412b 100644 --- a/README.md +++ b/README.md @@ -130,13 +130,7 @@ You can use [use-package](https://github.com/jwiegley/use-package) to install [p (setq py-autopep8-options '("-a" "-a"))) ``` -If you don't have it already, you also need to install [autopep8](https://pypi.org/project/autopep8/): - -``` -pip install autopep8 -``` - -If use install `autopep8` in the `venv` environment described before, you can use [pyvenv-auto](https://github.com/ryotaro612/pyvenv-auto) to automatically load the virtual environment inside Emacs. +`autopep8` was installed in the `venv` environment described before, so you should be able to use [pyvenv-auto](https://github.com/ryotaro612/pyvenv-auto) to automatically load that environment inside Emacs. ```elisp (use-package pyvenv-auto From ae2dcf88edd2ddf297585540370e156b41706d4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 19 Mar 2024 15:23:09 -0700 Subject: [PATCH 4/5] github: use virtual environment --- .github/workflows/tests.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4ba5eafec..5de8faee6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -33,14 +33,18 @@ jobs: path: .venv - name: Install system packages run: sudo apt-get install -y portaudio19-dev - - name: Install basic dependencies + - name: Setup virtual environment + run: | + python -m venv .venv + source .venv/bin/activate + - name: Install basic Python dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Build project run: | python -m build - - name: Install project and other dependencies + - name: Install project and other Python dependencies run: | pip install --editable . - name: Test with pytest From a189e2618f096ecf496d58ec28f28298f5e5119a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 19 Mar 2024 15:31:03 -0700 Subject: [PATCH 5/5] github: source venv in every step --- .github/workflows/tests.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5de8faee6..4222e1e8f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -29,25 +29,30 @@ jobs: - name: Cache virtual environment uses: actions/cache@v3 with: - key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}} + # TODO: we are hashing requirements.txt but that doesn't contain all + # our dependencies pinned. + key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('requirements.txt') }} path: .venv - name: Install system packages run: sudo apt-get install -y portaudio19-dev - name: Setup virtual environment run: | python -m venv .venv - source .venv/bin/activate - name: Install basic Python dependencies run: | + source .venv/bin/activate python -m pip install --upgrade pip pip install -r requirements.txt - name: Build project run: | + source .venv/bin/activate python -m build - name: Install project and other Python dependencies run: | + source .venv/bin/activate pip install --editable . - name: Test with pytest run: | + source .venv/bin/activate pip install pytest pytest --doctest-modules --ignore-glob="*to_be_updated*" src tests