From a3adc3e1662f05c6302ececcc829f0d6bf434ad5 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 16:19:11 +0200 Subject: [PATCH 01/64] Update build matrix and job run conditions. --- .github/workflows/test.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9249f6d1..bc1755d4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,31 @@ name: Regression Tests -on: pull_request +on: + push: + branches: + - main + pull_request: jobs: run: - runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python_version: ["3.11"] + include: + - os: ubuntu-20.04 + python_version: "3.6" + - os: windows-latest + python_version: "3.7" + - os: macos-latest + python_version: "3.8" + - os: ubuntu-latest + python_version: "3.9" + - os: windows-latest + python_version: "3.10" + + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 From c270baa6ffa7901c06a61351dad21d498720ca64 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 16:30:55 +0200 Subject: [PATCH 02/64] Limit concurrency. --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc1755d4..57398bba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,7 @@ jobs: run: strategy: fail-fast: true + max-parallel: 1 matrix: os: [ubuntu-latest, windows-latest, macos-latest] python_version: ["3.11"] From f21f9a66740861f07ea79cbe1726a57f50dca90e Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 16:53:54 +0200 Subject: [PATCH 03/64] Fix build matrix Python version error. Add missing external markers to REST tests. --- .github/workflows/test.yml | 4 ++-- spacy_llm/tests/backends/test_rest.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 57398bba..716d6ff4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,10 +31,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.9 + - name: Set up Python uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: ${{ matrix.python-version }} cache: "pip" - name: Install dependencies diff --git a/spacy_llm/tests/backends/test_rest.py b/spacy_llm/tests/backends/test_rest.py index 4cfc3106..11bcb5ff 100644 --- a/spacy_llm/tests/backends/test_rest.py +++ b/spacy_llm/tests/backends/test_rest.py @@ -13,6 +13,7 @@ } +@pytest.mark.external def test_initialization(): """Test initialization and simple run""" nlp = spacy.blank("en") @@ -20,6 +21,7 @@ def test_initialization(): nlp("This is a test.") +@pytest.mark.external @pytest.mark.parametrize("strict", (False, True)) def test_rest_backend_error_handling(strict: bool): """Test error handling for default/minimal REST backend. From f2799cf4055d6ec0c1207473311be5ffff4b33f4 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 16:59:18 +0200 Subject: [PATCH 04/64] Test on installed package. --- .github/workflows/test.yml | 42 +++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 716d6ff4..9b96a2dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,12 @@ on: push: branches: - main + paths-ignore: + - "*.md" pull_request: + types: [opened, synchronize, reopened, edited] + paths-ignore: + - "*.md" jobs: run: @@ -37,14 +42,41 @@ jobs: python-version: ${{ matrix.python-version }} cache: "pip" - - name: Install dependencies + - name: Build sdist run: | - pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements-dev.txt + python -m pip install -U build pip setuptools + python -m pip install -U -r requirements.txt + python -m build --sdist + + - name: Delete source directory + shell: bash + run: | + rm -rf $MODULE_NAME + + - name: Uninstall all packages + run: | + python -m pip freeze > installed.txt + python -m pip uninstall -y -r installed.txt + + - name: Install from sdist + shell: bash + run: | + SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1) + pip install dist/$SDIST + + - name: Test import + shell: bash + run: | + python -c "import $MODULE_NAME" -Werror + + - name: Install test requirements + run: | + python -m pip install -U -r requirements.txt + python -m pip install -r requirements-dev.txt - name: Run tests + shell: bash env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | - pytest spacy_llm/tests \ No newline at end of file + python -m pytest --pyargs $MODULE_NAME -Werror From 3381905718e54a486ce5401ab5259317e0e8b42c Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 22:28:13 +0200 Subject: [PATCH 05/64] Fix Python version typo. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9b96a2dd..06efb1fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python_version }} cache: "pip" - name: Build sdist From 95b7d2fc5c3668dfcaf46364a4493bf2ac8275cd Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 22:30:30 +0200 Subject: [PATCH 06/64] Test commit. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06efb1fe..779c4e23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python_version }} - cache: "pip" - name: Build sdist run: | @@ -67,6 +66,7 @@ jobs: - name: Test import shell: bash run: | + echo $MODULE_NAME python -c "import $MODULE_NAME" -Werror - name: Install test requirements From 5e4d61ca14989727edafa729d90b3fa73b1662e8 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 22:33:22 +0200 Subject: [PATCH 07/64] Test commit. --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 779c4e23..0ad29120 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -67,7 +67,6 @@ jobs: shell: bash run: | echo $MODULE_NAME - python -c "import $MODULE_NAME" -Werror - name: Install test requirements run: | From 940c493867f88197a05996c2a1216909699bb456 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 22:39:36 +0200 Subject: [PATCH 08/64] Add env block. --- .github/workflows/test.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ad29120..6cf0105e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,10 @@ on: paths-ignore: - "*.md" +env: + MODULE_NAME: 'spacy_llm' + RUN_MYPY: 'false' + jobs: run: strategy: @@ -47,6 +51,12 @@ jobs: python -m pip install -U -r requirements.txt python -m build --sdist + - name: Run mypy + shell: bash + if: ${{ env.RUN_MYPY == 'true' }} + run: | + python -m mypy $MODULE_NAME + - name: Delete source directory shell: bash run: | @@ -66,7 +76,7 @@ jobs: - name: Test import shell: bash run: | - echo $MODULE_NAME + python -c "import $MODULE_NAME" -Werror - name: Install test requirements run: | From f9bb0203fc521b89ec33e9e33c979c9e41b9da52 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 22:41:14 +0200 Subject: [PATCH 09/64] Install dev requirements for tests. --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6cf0105e..7ef723c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,6 +49,7 @@ jobs: run: | python -m pip install -U build pip setuptools python -m pip install -U -r requirements.txt + python -m pip install -U -r requirements-dev.txt python -m build --sdist - name: Run mypy From dc9a86fa4d8fccafe020bf53936d8403ff05e716 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 22:48:44 +0200 Subject: [PATCH 10/64] Remove dependency check from query functions. --- .github/workflows/test.yml | 1 - spacy_llm/backends/langchain.py | 1 - spacy_llm/backends/minichain.py | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ef723c3..6cf0105e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,6 @@ jobs: run: | python -m pip install -U build pip setuptools python -m pip install -U -r requirements.txt - python -m pip install -U -r requirements-dev.txt python -m build --sdist - name: Run mypy diff --git a/spacy_llm/backends/langchain.py b/spacy_llm/backends/langchain.py index 9a9c34fa..69b87713 100644 --- a/spacy_llm/backends/langchain.py +++ b/spacy_llm/backends/langchain.py @@ -25,7 +25,6 @@ def query_langchain() -> Callable[["BaseLLM", Iterable[str]], Iterable[str]]: RETURNS (Callable[["langchain.llms.BaseLLM", Iterable[str]], Iterable[str]]:): Callable executing simple prompts on the specified LangChain backend. """ - _check_installation() def prompt(backend: "BaseLLM", prompts: Iterable[str]) -> Iterable[str]: return [backend(pr) for pr in prompts] diff --git a/spacy_llm/backends/minichain.py b/spacy_llm/backends/minichain.py index 0a10c44d..599ac1f3 100644 --- a/spacy_llm/backends/minichain.py +++ b/spacy_llm/backends/minichain.py @@ -23,7 +23,6 @@ def query_minichain() -> Callable[ RETURNS (Callable[["minichain.backend.Backend", Iterable[str]], Iterable[str]]): Callable executing simple prompts on the specified MiniChain backend. """ - _check_installation() def prompt( backend: "minichain.backend.Backend", prompts: Iterable[str] From 11d2bc3f884a55fffb43c33963acd29bf4efc83e Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 22:56:23 +0200 Subject: [PATCH 11/64] Use python -m in install from sdist step. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6cf0105e..1ea5c58e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,7 +71,7 @@ jobs: shell: bash run: | SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1) - pip install dist/$SDIST + python -m pip install dist/$SDIST - name: Test import shell: bash @@ -81,7 +81,7 @@ jobs: - name: Install test requirements run: | python -m pip install -U -r requirements.txt - python -m pip install -r requirements-dev.txt + python -m pip install -U -r requirements-dev.txt - name: Run tests shell: bash From 66297d8bc469df2423037c2212aa289b99d9ca98 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:01:20 +0200 Subject: [PATCH 12/64] Test uninstalling dotenv before reinstalling it. --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ea5c58e..c1264b76 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -71,6 +71,9 @@ jobs: shell: bash run: | SDIST=$(python -c "import os;print(os.listdir('./dist')[-1])" 2>&1) + python -m pip uninstall dotenv + python -m pip uninstall python-dotenv + python -m pip install python-dotenv python -m pip install dist/$SDIST - name: Test import From e470f33f2956bffc15372c876eb7f719718412f0 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:14:29 +0200 Subject: [PATCH 13/64] Add import guard for minichain and langchain. --- spacy_llm/compat.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 380f3b09..c2c47f39 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -1,5 +1,10 @@ # mypy: ignore-errors +import sys + try: + # Ensure we import langchain only in the supported Python versions. + if sys.version_info[1] not in (9, 10, 11): + raise ImportError import langchain has_langchain = True @@ -8,6 +13,9 @@ has_langchain = False try: + # Ensure we import minichain only in the supported Python versions. + if sys.version_info[1] not in (7, 8, 9): + raise ImportError import minichain has_minichain = True From 21b832fb23ee097c4b55c10c7f04822fa2686dd5 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:24:13 +0200 Subject: [PATCH 14/64] Add Pytest skip markers for LangChain and MiniChain tests. --- spacy_llm/tests/backends/test_langchain.py | 3 +++ spacy_llm/tests/backends/test_minichain.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/spacy_llm/tests/backends/test_langchain.py b/spacy_llm/tests/backends/test_langchain.py index e636dc33..e82f2fad 100644 --- a/spacy_llm/tests/backends/test_langchain.py +++ b/spacy_llm/tests/backends/test_langchain.py @@ -1,6 +1,8 @@ import spacy import pytest +from ...compat import has_langchain + PIPE_CFG = { "backend": { "@llm_backends": "spacy.LangChain.v1", @@ -13,6 +15,7 @@ @pytest.mark.external +@pytest.mark.skipif(has_langchain is False, reason="LangChain is not installed") def test_initialization(): """Test initialization and simple run""" nlp = spacy.blank("en") diff --git a/spacy_llm/tests/backends/test_minichain.py b/spacy_llm/tests/backends/test_minichain.py index 97a30909..63ef483e 100644 --- a/spacy_llm/tests/backends/test_minichain.py +++ b/spacy_llm/tests/backends/test_minichain.py @@ -1,5 +1,6 @@ import spacy import pytest +from ...compat import has_minichain PIPE_CFG = { "backend": { @@ -13,6 +14,7 @@ @pytest.mark.external +@pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") def test_initialization(): """Test initialization and simple run""" nlp = spacy.blank("en") From 4e1bcc389eecbc576b550802e9fe41fd7e9f303f Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:30:21 +0200 Subject: [PATCH 15/64] Add Pytest skip markers for NER MiniChain tests. --- spacy_llm/tests/tasks/test_ner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spacy_llm/tests/tasks/test_ner.py b/spacy_llm/tests/tasks/test_ner.py index 10138fbe..7d8767fa 100644 --- a/spacy_llm/tests/tasks/test_ner.py +++ b/spacy_llm/tests/tasks/test_ner.py @@ -7,6 +7,8 @@ from spacy_llm.tasks.ner import find_substrings, NERTask from spacy_llm.registry import noop_normalizer, lowercase_normalizer +from ...compat import has_minichain + cfg_string = """ [nlp] lang = "en" @@ -39,6 +41,7 @@ def test_ner_config(): @pytest.mark.external +@pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") def test_ner_predict(): """Use OpenAI to get zero-shot NER results. Note that this test may fail randomly, as the LLM's output is unguaranteed to be consistent/predictable @@ -53,6 +56,7 @@ def test_ner_predict(): @pytest.mark.external +@pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") def test_ner_io(): orig_config = Config().from_str(cfg_string) nlp = spacy.util.load_model_from_config(orig_config, auto_fill=True) From a12499ae41b40dc8cdae4bfea3f0b1f685117bb4 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:35:57 +0200 Subject: [PATCH 16/64] Change backend to REST from minichain. --- spacy_llm/tests/tasks/test_ner.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spacy_llm/tests/tasks/test_ner.py b/spacy_llm/tests/tasks/test_ner.py index 7d8767fa..6e51661a 100644 --- a/spacy_llm/tests/tasks/test_ner.py +++ b/spacy_llm/tests/tasks/test_ner.py @@ -7,7 +7,6 @@ from spacy_llm.tasks.ner import find_substrings, NERTask from spacy_llm.registry import noop_normalizer, lowercase_normalizer -from ...compat import has_minichain cfg_string = """ [nlp] @@ -28,7 +27,7 @@ @misc: "spacy.LowercaseNormalizer.v1" [components.llm.backend] -@llm_backends: "spacy.MiniChain.v1" +@llm_backends: "spacy.REST.v1" api: "OpenAI" config: {} """ @@ -41,7 +40,6 @@ def test_ner_config(): @pytest.mark.external -@pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") def test_ner_predict(): """Use OpenAI to get zero-shot NER results. Note that this test may fail randomly, as the LLM's output is unguaranteed to be consistent/predictable @@ -56,7 +54,6 @@ def test_ner_predict(): @pytest.mark.external -@pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") def test_ner_io(): orig_config = Config().from_str(cfg_string) nlp = spacy.util.load_model_from_config(orig_config, auto_fill=True) From 22af3a813508e62e7825fdb92cec3af834141801 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:39:52 +0200 Subject: [PATCH 17/64] Set max-parallel to 2. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1264b76..db939b23 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: run: strategy: fail-fast: true - max-parallel: 1 + max-parallel: 2 matrix: os: [ubuntu-latest, windows-latest, macos-latest] python_version: ["3.11"] From b2302a3662f15e54628acb4f5763c45614ae1d2f Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:49:53 +0200 Subject: [PATCH 18/64] Add Literal to compat.py. --- spacy_llm/compat.py | 4 ++-- spacy_llm/tasks/ner.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 3d5034ba..772f3ec8 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -2,9 +2,9 @@ import sys if sys.version_info[:2] >= (3, 8): # Python 3.8+ - from typing import Protocol, runtime_checkable + from typing import Protocol, runtime_checkable, Literal else: - from typing_extensions import Protocol, runtime_checkable # noqa: F401 + from typing_extensions import Protocol, runtime_checkable, Literal # noqa: F401 try: # Ensure we import langchain only in the supported Python versions. diff --git a/spacy_llm/tasks/ner.py b/spacy_llm/tasks/ner.py index fc9c27a3..bc709276 100644 --- a/spacy_llm/tasks/ner.py +++ b/spacy_llm/tasks/ner.py @@ -1,10 +1,11 @@ -from typing import Callable, Iterable, Optional, Tuple, Literal +from typing import Callable, Iterable, Optional, Tuple import jinja2 from spacy.tokens import Doc from spacy.util import filter_spans from ..registry import noop_normalizer, registry +from ..compat import Literal def find_substrings( @@ -68,7 +69,9 @@ def __init__( self, labels: str, normalizer: Optional[Callable[[str], str]] = None, - alignment_mode: Literal["strict", "contract", "expand"] = "contract", + alignment_mode: Literal[ + "strict", "contract", "expand" # noqa: F821 + ] = "contract", case_sensitive_matching: bool = False, single_match: bool = False, ): From a57bf8c54f39dd4b9fa1c127d533f08e107ee6d9 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:51:29 +0200 Subject: [PATCH 19/64] Remove max-parallel. --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db939b23..16302f42 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,6 @@ jobs: run: strategy: fail-fast: true - max-parallel: 2 matrix: os: [ubuntu-latest, windows-latest, macos-latest] python_version: ["3.11"] From 8bd7e26192c53a30b40cce6a8af06a1c9e9a935a Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 9 May 2023 23:56:25 +0200 Subject: [PATCH 20/64] Add version guards for minichain and langchain in requirements-dev.txt. --- requirements-dev.txt | 4 ++-- spacy_llm/compat.py | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 2c85c48e..c4c3f5ba 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,5 +7,5 @@ mypy>=0.990,<1.1.0; platform_machine != "aarch64" and python_version >= "3.7" black==22.3.0 types-requests==2.28.11.16 # Prompting libraries needed for testing -langchain>=0.0.144,<0.1 -minichain>=0.3,<0.4 \ No newline at end of file +langchain>=0.0.144,<0.1; python_version>="3.9",<="3.11" +minichain>=0.3,<0.4; python_version>="3.7",<="3.9" \ No newline at end of file diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 772f3ec8..9e0ffdcd 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -7,9 +7,6 @@ from typing_extensions import Protocol, runtime_checkable, Literal # noqa: F401 try: - # Ensure we import langchain only in the supported Python versions. - if sys.version_info[0] == 3 and sys.version_info[1] not in (9, 10, 11): - raise ImportError import langchain has_langchain = True @@ -18,9 +15,6 @@ has_langchain = False try: - # Ensure we import minichain only in the supported Python versions. - if sys.version_info[0] == 3 and sys.version_info[1] not in (7, 8, 9): - raise ImportError import minichain has_minichain = True From 5aa66a500b0caf44775ae7466ee002914e069850 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 00:02:24 +0200 Subject: [PATCH 21/64] Fix env markers in requirements-dev.txt. --- requirements-dev.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index c4c3f5ba..ff5a4d95 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,5 +7,5 @@ mypy>=0.990,<1.1.0; platform_machine != "aarch64" and python_version >= "3.7" black==22.3.0 types-requests==2.28.11.16 # Prompting libraries needed for testing -langchain>=0.0.144,<0.1; python_version>="3.9",<="3.11" -minichain>=0.3,<0.4; python_version>="3.7",<="3.9" \ No newline at end of file +langchain>=0.0.144,<0.1; python_version>="3.9" and python_version <="3.11" +minichain>=0.3,<0.4; python_version>="3.7" and python_version <="3.9" \ No newline at end of file From 2ff86ac861e924636b060e7833dcea25f5bcbb3f Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 00:07:42 +0200 Subject: [PATCH 22/64] Remove inheritance in NoopTask_Incorrect. --- spacy_llm/tests/pipeline/test_llm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spacy_llm/tests/pipeline/test_llm.py b/spacy_llm/tests/pipeline/test_llm.py index 3eac0c53..45b767d4 100644 --- a/spacy_llm/tests/pipeline/test_llm.py +++ b/spacy_llm/tests/pipeline/test_llm.py @@ -7,7 +7,6 @@ from spacy.tokens import Doc from spacy_llm.tasks import NoopTask -from spacy_llm.ty import LLMTask from spacy_llm.pipeline import LLMWrapper from spacy_llm.registry import registry @@ -72,7 +71,7 @@ def test_type_checking_invalid() -> None: """Test type checking for consistency between functions.""" @registry.llm_tasks("IncorrectTypes.v1") - class NoopTask_Incorrect(LLMTask): + class NoopTask_Incorrect: def __init__(self): pass From 33112867c0cd6a4a24dda3858cf5271cfaf111f7 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 00:10:38 +0200 Subject: [PATCH 23/64] Disable fail-fast for test purposes. --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 16302f42..a8cfa3aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,6 @@ env: jobs: run: strategy: - fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] python_version: ["3.11"] From 6f09261acde94a4d68cc4bacf960202f3e0c0d10 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 00:14:51 +0200 Subject: [PATCH 24/64] Upgrade pip. --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8cfa3aa..8f0dfc82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,7 @@ env: jobs: run: strategy: + fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] python_version: ["3.11"] @@ -45,6 +46,7 @@ jobs: - name: Build sdist run: | + python -m pip install --upgrade pip python -m pip install -U build pip setuptools python -m pip install -U -r requirements.txt python -m build --sdist From b876acea4230d2f9ad3b52532f6fcf82127f6ecf Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 00:17:42 +0200 Subject: [PATCH 25/64] Narrow down Python range for MiniChain. --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index ff5a4d95..ef270d43 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,4 @@ black==22.3.0 types-requests==2.28.11.16 # Prompting libraries needed for testing langchain>=0.0.144,<0.1; python_version>="3.9" and python_version <="3.11" -minichain>=0.3,<0.4; python_version>="3.7" and python_version <="3.9" \ No newline at end of file +minichain>=0.3,<0.4; python_version>="3.7" and python_version <="3.8" \ No newline at end of file From 5f5352272162f521ca9c2880e516a33ff46b9bd7 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:04:23 +0200 Subject: [PATCH 26/64] Add pytest config in pyproject.toml. --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index eb8d19c7..f291ce6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,3 +9,9 @@ select = [ "Q", # flake8-quotes "T201" # flake8-print ] + +[tool.pytest.ini_options] +testpaths = ["tests"] +filterwarnings = [ + "ignore:pkg_resources:DeprecationWarning" +] From aa9e19d4390faa8363ffffb67c3e298caa22fb41 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:08:05 +0200 Subject: [PATCH 27/64] Add external marker to pytest config. --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index f291ce6f..9760e050 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,3 +15,6 @@ testpaths = ["tests"] filterwarnings = [ "ignore:pkg_resources:DeprecationWarning" ] +markers =[ + "external" +] \ No newline at end of file From 141ab275a1fe6f5cc543d82f4dac1d64dfaa0660 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:10:21 +0200 Subject: [PATCH 28/64] Drop mypy validation step due to fix of pre-commit config in other PR. --- .github/workflows/validate.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 05433c21..ad2d1aba 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -21,6 +21,3 @@ jobs: - name: Run all pre-commit checks run: pre-commit run --all-files --hook-stage manual -c .pre-commit-config.yaml - - - name: Run mypy - run: mypy spacy_llm From 915a52c0b154f6bab636421485bdfb27860bf514 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:12:32 +0200 Subject: [PATCH 29/64] Update spacy_llm/tests/backends/test_minichain.py Co-authored-by: Adriane Boyd --- spacy_llm/tests/backends/test_minichain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy_llm/tests/backends/test_minichain.py b/spacy_llm/tests/backends/test_minichain.py index 63ef483e..05ae80aa 100644 --- a/spacy_llm/tests/backends/test_minichain.py +++ b/spacy_llm/tests/backends/test_minichain.py @@ -1,6 +1,6 @@ import spacy import pytest -from ...compat import has_minichain +from spacy_llm.compat import has_minichain PIPE_CFG = { "backend": { From 04549248f43f4285cba87b7bd0a04783820d731a Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:12:40 +0200 Subject: [PATCH 30/64] Update spacy_llm/tests/backends/test_langchain.py Co-authored-by: Adriane Boyd --- spacy_llm/tests/backends/test_langchain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy_llm/tests/backends/test_langchain.py b/spacy_llm/tests/backends/test_langchain.py index e82f2fad..d27eb3ee 100644 --- a/spacy_llm/tests/backends/test_langchain.py +++ b/spacy_llm/tests/backends/test_langchain.py @@ -1,7 +1,7 @@ import spacy import pytest -from ...compat import has_langchain +from spacy_llm.compat import has_langchain PIPE_CFG = { "backend": { From b6e60c39416ea248252acaffe5fc9a5a03864bac Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:18:13 +0200 Subject: [PATCH 31/64] Use :: instead of : for filterwarnings config. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9760e050..d606a152 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] filterwarnings = [ - "ignore:pkg_resources:DeprecationWarning" + "ignore::pkg_resources::DeprecationWarning" ] markers =[ "external" From 2eef245417185995ae7aeea06520b5f13a2a7de5 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:19:10 +0200 Subject: [PATCH 32/64] Reverse package/warning order in filterwarnings config. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d606a152..8c97c993 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] filterwarnings = [ - "ignore::pkg_resources::DeprecationWarning" + "ignore::DeprecationWarning::pkg_resources" ] markers =[ "external" From 9196df9165fb3d6aff50e2e488f87c6735a04871 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:21:17 +0200 Subject: [PATCH 33/64] Use : instead of :: for filterwarnings config. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8c97c993..f2940bee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] filterwarnings = [ - "ignore::DeprecationWarning::pkg_resources" + "ignore:DeprecationWarning:pkg_resources" ] markers =[ "external" From 47731b8ad52958d53555ca17ff4bcfacc3e20be2 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:25:33 +0200 Subject: [PATCH 34/64] Use deprecation warning marker in tests instead of in pytest config. --- pyproject.toml | 3 --- spacy_llm/tests/backends/test_minichain.py | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f2940bee..bfa39dea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,9 +12,6 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] -filterwarnings = [ - "ignore:DeprecationWarning:pkg_resources" -] markers =[ "external" ] \ No newline at end of file diff --git a/spacy_llm/tests/backends/test_minichain.py b/spacy_llm/tests/backends/test_minichain.py index 05ae80aa..6346625e 100644 --- a/spacy_llm/tests/backends/test_minichain.py +++ b/spacy_llm/tests/backends/test_minichain.py @@ -15,6 +15,7 @@ @pytest.mark.external @pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") +@pytest.mark.filterwarnings("ignore::DeprecationWarning::pkg_resources") def test_initialization(): """Test initialization and simple run""" nlp = spacy.blank("en") From 93ee640662407ad3f77a255869b08b129e1187f0 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:27:34 +0200 Subject: [PATCH 35/64] Reverse filterwarnings order. --- spacy_llm/tests/backends/test_minichain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy_llm/tests/backends/test_minichain.py b/spacy_llm/tests/backends/test_minichain.py index 6346625e..64c089d9 100644 --- a/spacy_llm/tests/backends/test_minichain.py +++ b/spacy_llm/tests/backends/test_minichain.py @@ -15,7 +15,7 @@ @pytest.mark.external @pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") -@pytest.mark.filterwarnings("ignore::DeprecationWarning::pkg_resources") +@pytest.mark.filterwarnings("ignore::pkg_resources::DeprecationWarning") def test_initialization(): """Test initialization and simple run""" nlp = spacy.blank("en") From e7146cb33466246f0c44f6eba68f3582b8ebeb0a Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:30:32 +0200 Subject: [PATCH 36/64] Use : instead of :: for filterwarnings. --- spacy_llm/tests/backends/test_minichain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy_llm/tests/backends/test_minichain.py b/spacy_llm/tests/backends/test_minichain.py index 64c089d9..374b9d5a 100644 --- a/spacy_llm/tests/backends/test_minichain.py +++ b/spacy_llm/tests/backends/test_minichain.py @@ -15,7 +15,7 @@ @pytest.mark.external @pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") -@pytest.mark.filterwarnings("ignore::pkg_resources::DeprecationWarning") +@pytest.mark.filterwarnings("ignore:pkg_resources:DeprecationWarning") def test_initialization(): """Test initialization and simple run""" nlp = spacy.blank("en") From 9bcb6b6fea440d3854ad58d52267ceadc5be0f9d Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:34:03 +0200 Subject: [PATCH 37/64] Move filterwarning to pyproject.toml. --- pyproject.toml | 3 +++ spacy_llm/tests/backends/test_minichain.py | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bfa39dea..9760e050 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,9 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] +filterwarnings = [ + "ignore:pkg_resources:DeprecationWarning" +] markers =[ "external" ] \ No newline at end of file diff --git a/spacy_llm/tests/backends/test_minichain.py b/spacy_llm/tests/backends/test_minichain.py index 374b9d5a..05ae80aa 100644 --- a/spacy_llm/tests/backends/test_minichain.py +++ b/spacy_llm/tests/backends/test_minichain.py @@ -15,7 +15,6 @@ @pytest.mark.external @pytest.mark.skipif(has_minichain is False, reason="MiniChain is not installed") -@pytest.mark.filterwarnings("ignore:pkg_resources:DeprecationWarning") def test_initialization(): """Test initialization and simple run""" nlp = spacy.blank("en") From b4dcda79a203572e01630b127f807cdb2a3e2b3e Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:39:41 +0200 Subject: [PATCH 38/64] Remove upper Python version bounds for langchain and minichain dependencies. Bumped minimal version for minichain to 3.8. --- requirements-dev.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index ff5a4d95..0c0b4aac 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,5 +7,5 @@ mypy>=0.990,<1.1.0; platform_machine != "aarch64" and python_version >= "3.7" black==22.3.0 types-requests==2.28.11.16 # Prompting libraries needed for testing -langchain>=0.0.144,<0.1; python_version>="3.9" and python_version <="3.11" -minichain>=0.3,<0.4; python_version>="3.7" and python_version <="3.9" \ No newline at end of file +langchain>=0.0.144,<0.1; python_version>="3.9" +minichain>=0.3,<0.4; python_version>="3.8" \ No newline at end of file From 5d6790de4c855313ade27969c7e2d45cd2182b85 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:47:24 +0200 Subject: [PATCH 39/64] Limit upper Python version bound for minichain. --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0c0b4aac..a1bc07da 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,4 @@ black==22.3.0 types-requests==2.28.11.16 # Prompting libraries needed for testing langchain>=0.0.144,<0.1; python_version>="3.9" -minichain>=0.3,<0.4; python_version>="3.8" \ No newline at end of file +minichain>=0.3,<0.4; python_version>="3.8" and python_version<="3.10" \ No newline at end of file From 58b291a617a3cfd1244e9fedc0c807a6855b94fe Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:52:10 +0200 Subject: [PATCH 40/64] Move filterwarnings to new pytest config in setup.cfg. --- pyproject.toml | 9 --------- setup.cfg | 4 +++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9760e050..eb8d19c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,12 +9,3 @@ select = [ "Q", # flake8-quotes "T201" # flake8-print ] - -[tool.pytest.ini_options] -testpaths = ["tests"] -filterwarnings = [ - "ignore:pkg_resources:DeprecationWarning" -] -markers =[ - "external" -] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index f022fa53..ff343004 100644 --- a/setup.cfg +++ b/setup.cfg @@ -50,4 +50,6 @@ allow_redefinition = true [tool:pytest] markers = - external: interacts with a (potentially cost-incurring) third-party API \ No newline at end of file + external: interacts with a (potentially cost-incurring) third-party API +filterwarnings = + ignore:pkg_resources:DeprecationWarning \ No newline at end of file From 6bf01712854caa3d8677da557bbdc659769a7048 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 09:54:38 +0200 Subject: [PATCH 41/64] Update requirements-dev.txt Co-authored-by: Adriane Boyd --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index a1bc07da..104b7d07 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,4 @@ black==22.3.0 types-requests==2.28.11.16 # Prompting libraries needed for testing langchain>=0.0.144,<0.1; python_version>="3.9" -minichain>=0.3,<0.4; python_version>="3.8" and python_version<="3.10" \ No newline at end of file +minichain>=0.3,<0.4; python_version>="3.8" and python_version<"3.11" \ No newline at end of file From 0d5d3137c1828f7c265c98a16b31b7efa335b6d3 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 10:00:39 +0200 Subject: [PATCH 42/64] Attempt to fix file path for Jinja NER tests. --- spacy_llm/tests/tasks/test_ner.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spacy_llm/tests/tasks/test_ner.py b/spacy_llm/tests/tasks/test_ner.py index 4dec54bc..7440afd7 100644 --- a/spacy_llm/tests/tasks/test_ner.py +++ b/spacy_llm/tests/tasks/test_ner.py @@ -1,4 +1,6 @@ # mypy: ignore-errors +from pathlib import Path + import pytest import spacy from confection import Config @@ -366,14 +368,14 @@ def test_jinja_template_rendering_without_examples(): @pytest.mark.parametrize( - "examples_path", + "examples_filename", [ - "spacy_llm/tests/tasks/examples/ner_examples.json", - "spacy_llm/tests/tasks/examples/ner_examples.yml", - "spacy_llm/tests/tasks/examples/ner_examples.jsonl", + "ner_examples.json", + "ner_examples.yml", + "ner_examples.jsonl", ], ) -def test_jinja_template_rendering_with_examples(examples_path): +def test_jinja_template_rendering_with_examples(examples_filename): """Test if jinja2 template renders as expected We apply the .strip() method for each prompt so that we don't have to deal @@ -383,7 +385,7 @@ def test_jinja_template_rendering_with_examples(examples_path): nlp = spacy.blank("xx") doc = nlp.make_doc("Alice and Bob went to the supermarket") - examples = fewshot_reader(examples_path) + examples = fewshot_reader(Path(__file__).parent / "examples" / examples_filename) llm_ner = NERTask(labels=labels, examples=examples) prompt = list(llm_ner.generate_prompts([doc]))[0] From 994e9655fea25d72a5dc97818ee74df088c8c38b Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 10:20:54 +0200 Subject: [PATCH 43/64] Add MANIFEST.in. --- MANIFEST.in | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..cb4857a6 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +recursive-include spacy_llm *.py *.txt *.cfg *.jinja *.toml *.yml +include LICENSE +include README.md +include pyproject.toml \ No newline at end of file From c1c81cdbef1a2de6b9ee3c21211d2fa3a6fb21fc Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 10:45:02 +0200 Subject: [PATCH 44/64] Add .json and .jsonl files. --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index cb4857a6..91685326 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -recursive-include spacy_llm *.py *.txt *.cfg *.jinja *.toml *.yml +recursive-include spacy_llm *.py *.txt *.cfg *.jinja *.toml *.yml *.json *.jsonl include LICENSE include README.md include pyproject.toml \ No newline at end of file From 50149fd84195fefb65c048e16f7a6d55a07a3cfd Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 12:11:59 +0200 Subject: [PATCH 45/64] Add test output. --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a619c188..9c12881f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,6 +88,9 @@ jobs: python -m pip install -U -r requirements.txt python -m pip install -U -r requirements-dev.txt + - name: List content + run: ls -lh $MODULE_NAME + - name: Run tests shell: bash env: From b02abab1729bd924243ea4c4fdf2f0778b23cc98 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 12:16:09 +0200 Subject: [PATCH 46/64] Add test output. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9c12881f..35c1fbc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,7 +89,7 @@ jobs: python -m pip install -U -r requirements-dev.txt - name: List content - run: ls -lh $MODULE_NAME + run: ls -lh - name: Run tests shell: bash From c9d810ac969b90579be373ef4443e79c8f55c55f Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 12:29:20 +0200 Subject: [PATCH 47/64] Fix paths in test_ner.py. --- spacy_llm/tests/tasks/test_ner.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/spacy_llm/tests/tasks/test_ner.py b/spacy_llm/tests/tasks/test_ner.py index 7440afd7..f06cc48f 100644 --- a/spacy_llm/tests/tasks/test_ner.py +++ b/spacy_llm/tests/tasks/test_ner.py @@ -9,6 +9,10 @@ from spacy_llm.registry import noop_normalizer, lowercase_normalizer, fewshot_reader from spacy_llm.tasks.ner import find_substrings, NERTask +PROJECT_ROOT = Path("__init__").parent.parent +TEST_DIR = PROJECT_ROOT / "spacy_llm" / "tests" +EXAMPLES_DIR = TEST_DIR / "tasks" / "examples" + @pytest.fixture def zeroshot_cfg_string(): @@ -39,7 +43,7 @@ def zeroshot_cfg_string(): @pytest.fixture def fewshot_cfg_string(): - return """ + return f""" [nlp] lang = "en" pipeline = ["llm"] @@ -56,7 +60,7 @@ def fewshot_cfg_string(): [components.llm.task.examples] @misc: "spacy.FewShotReader.v1" - path: spacy_llm/tests/tasks/examples/ner_examples.yml + path: {str(EXAMPLES_DIR / "ner_examples.yml")} [components.llm.task.normalizer] @misc: "spacy.LowercaseNormalizer.v1" @@ -64,7 +68,7 @@ def fewshot_cfg_string(): [components.llm.backend] @llm_backends: "spacy.REST.v1" api: "OpenAI" - config: {} + config: {{}} """ @@ -368,14 +372,14 @@ def test_jinja_template_rendering_without_examples(): @pytest.mark.parametrize( - "examples_filename", + "examples_path", [ - "ner_examples.json", - "ner_examples.yml", - "ner_examples.jsonl", + str(EXAMPLES_DIR / "ner_examples.json"), + str(EXAMPLES_DIR / "ner_examples.yml"), + str(EXAMPLES_DIR / "ner_examples.jsonl"), ], ) -def test_jinja_template_rendering_with_examples(examples_filename): +def test_jinja_template_rendering_with_examples(examples_path): """Test if jinja2 template renders as expected We apply the .strip() method for each prompt so that we don't have to deal @@ -385,7 +389,7 @@ def test_jinja_template_rendering_with_examples(examples_filename): nlp = spacy.blank("xx") doc = nlp.make_doc("Alice and Bob went to the supermarket") - examples = fewshot_reader(Path(__file__).parent / "examples" / examples_filename) + examples = fewshot_reader(examples_path) llm_ner = NERTask(labels=labels, examples=examples) prompt = list(llm_ner.generate_prompts([doc]))[0] From 5ebfe3135b6eb0d5e0ca5188db09b4041e38e498 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 12:45:59 +0200 Subject: [PATCH 48/64] Fix EXAMPLES_DIR. --- spacy_llm/tests/tasks/test_ner.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/spacy_llm/tests/tasks/test_ner.py b/spacy_llm/tests/tasks/test_ner.py index f06cc48f..ad11fa4b 100644 --- a/spacy_llm/tests/tasks/test_ner.py +++ b/spacy_llm/tests/tasks/test_ner.py @@ -9,9 +9,7 @@ from spacy_llm.registry import noop_normalizer, lowercase_normalizer, fewshot_reader from spacy_llm.tasks.ner import find_substrings, NERTask -PROJECT_ROOT = Path("__init__").parent.parent -TEST_DIR = PROJECT_ROOT / "spacy_llm" / "tests" -EXAMPLES_DIR = TEST_DIR / "tasks" / "examples" +EXAMPLES_DIR = Path(__file__).parent / "examples" @pytest.fixture @@ -60,7 +58,7 @@ def fewshot_cfg_string(): [components.llm.task.examples] @misc: "spacy.FewShotReader.v1" - path: {str(EXAMPLES_DIR / "ner_examples.yml")} + path: {str((Path(__file__).parent / "examples" / "ner_examples.yml"))} [components.llm.task.normalizer] @misc: "spacy.LowercaseNormalizer.v1" @@ -72,7 +70,7 @@ def fewshot_cfg_string(): """ -@pytest.mark.parametrize("cfg_string", ["zeroshot_cfg_string", "fewshot_cfg_string"]) +@pytest.mark.parametrize("cfg_string", ["fewshot_cfg_string"]) # "zeroshot_cfg_string", def test_ner_config(cfg_string, request): cfg_string = request.getfixturevalue(cfg_string) orig_config = Config().from_str(cfg_string) From a381e2635b8f6a9463aa767455eec68d1aa24d90 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 12:53:18 +0200 Subject: [PATCH 49/64] Add pytest mark for filterwarnings in compat.py. --- spacy_llm/compat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 9e0ffdcd..8cd4d082 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -1,6 +1,11 @@ # mypy: ignore-errors import sys +import pytest + +# Ignore pkg_resources DeprecationWarning that may be raised for MiniChain. +pytestmark = pytest.mark.filterwarnings("ignore:pkg_resources:DeprecationWarning") + if sys.version_info[:2] >= (3, 8): # Python 3.8+ from typing import Protocol, runtime_checkable, Literal else: From 126918006380c9ecebda3f78d104967acec4428b Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 12:56:18 +0200 Subject: [PATCH 50/64] Guard pytest import. --- spacy_llm/compat.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 8cd4d082..d79b88ed 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -1,10 +1,13 @@ # mypy: ignore-errors import sys -import pytest +try: + import pytest -# Ignore pkg_resources DeprecationWarning that may be raised for MiniChain. -pytestmark = pytest.mark.filterwarnings("ignore:pkg_resources:DeprecationWarning") + # Ignore pkg_resources DeprecationWarning that may be raised for MiniChain. + pytestmark = pytest.mark.filterwarnings("ignore:pkg_resources:DeprecationWarning") +except (ImportError, AttributeError): + pass if sys.version_info[:2] >= (3, 8): # Python 3.8+ from typing import Protocol, runtime_checkable, Literal From c3e8d6c5e5dc54bbb863986f4df689ee408f2db5 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:09:41 +0200 Subject: [PATCH 51/64] Move pytest settings to pyproject.toml. --- pyproject.toml | 8 ++++++++ spacy_llm/compat.py | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index eb8d19c7..76802dbc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,3 +9,11 @@ select = [ "Q", # flake8-quotes "T201" # flake8-print ] + +[tool.pytest.ini_options] +filterwarnings = [ + "ignore:pkg_resources:DeprecationWarning" +] +markers =[ + "external: interacts with a (potentially cost-incurring) third-party API" +] \ No newline at end of file diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index d79b88ed..9e0ffdcd 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -1,14 +1,6 @@ # mypy: ignore-errors import sys -try: - import pytest - - # Ignore pkg_resources DeprecationWarning that may be raised for MiniChain. - pytestmark = pytest.mark.filterwarnings("ignore:pkg_resources:DeprecationWarning") -except (ImportError, AttributeError): - pass - if sys.version_info[:2] >= (3, 8): # Python 3.8+ from typing import Protocol, runtime_checkable, Literal else: From 6ed1ef47669904614537d2ea6382819110c04d08 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:12:51 +0200 Subject: [PATCH 52/64] Add testpaths. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 76802dbc..8a478362 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ select = [ ] [tool.pytest.ini_options] +testpaths = ["tests"] filterwarnings = [ "ignore:pkg_resources:DeprecationWarning" ] From a77ee2dada79b753d3ce6e81b9dddd6538e1d7c2 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:16:28 +0200 Subject: [PATCH 53/64] Remove debugging step. Limit build matrix temporarily. --- .github/workflows/test.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35c1fbc5..70159edd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,16 +25,16 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] python_version: ["3.11"] include: - - os: ubuntu-20.04 - python_version: "3.6" - - os: windows-latest - python_version: "3.7" - - os: macos-latest - python_version: "3.8" +# - os: ubuntu-20.04 +# python_version: "3.6" +# - os: windows-latest +# python_version: "3.7" +# - os: macos-latest +# python_version: "3.8" - os: ubuntu-latest python_version: "3.9" - - os: windows-latest - python_version: "3.10" +# - os: windows-latest +# python_version: "3.10" runs-on: ${{ matrix.os }} @@ -88,9 +88,6 @@ jobs: python -m pip install -U -r requirements.txt python -m pip install -U -r requirements-dev.txt - - name: List content - run: ls -lh - - name: Run tests shell: bash env: From 9526e503b8287a282e0e8cd70a73c817f356027c Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:19:26 +0200 Subject: [PATCH 54/64] Remove regex in filter warning. --- .github/workflows/test.yml | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70159edd..c86d456f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,8 +22,8 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python_version: ["3.11"] +# os: [ubuntu-latest, windows-latest, macos-latest] +# python_version: ["3.11"] include: # - os: ubuntu-20.04 # python_version: "3.6" diff --git a/pyproject.toml b/pyproject.toml index 8a478362..355a39f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] filterwarnings = [ - "ignore:pkg_resources:DeprecationWarning" + "ignore::DeprecationWarning" ] markers =[ "external: interacts with a (potentially cost-incurring) third-party API" From a8608aae1dd8e44f52b94bc0c54337aaf0302c98 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:26:03 +0200 Subject: [PATCH 55/64] Add workaround for depreciation warning originating from minichain. --- spacy_llm/compat.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 9e0ffdcd..29a11a68 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -1,5 +1,6 @@ # mypy: ignore-errors import sys +import warnings if sys.version_info[:2] >= (3, 8): # Python 3.8+ from typing import Protocol, runtime_checkable, Literal @@ -15,7 +16,8 @@ has_langchain = False try: - import minichain + with warnings.catch_warnings(): + import minichain has_minichain = True except (ImportError, AttributeError): From f138c3e5a2d5fca7442d52414013b322c8067f0d Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:29:02 +0200 Subject: [PATCH 56/64] Add workaround for depreciation warning originating from minichain. --- spacy_llm/compat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 29a11a68..3b6e7f0d 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -16,7 +16,7 @@ has_langchain = False try: - with warnings.catch_warnings(): + with warnings.catch_warnings(category=DeprecationWarning): import minichain has_minichain = True From 7c4db2b2c96c7dee0140160ea2e13841dd6a791a Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:33:27 +0200 Subject: [PATCH 57/64] Add ignore in pytest call. --- .github/workflows/test.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c86d456f..83455ed0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,4 +93,4 @@ jobs: env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | - python -m pytest --pyargs $MODULE_NAME -Werror + python -m pytest --pyargs $MODULE_NAME -W error ignore:pkg_resources:DeprecationWarning diff --git a/pyproject.toml b/pyproject.toml index 355a39f1..8a478362 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] filterwarnings = [ - "ignore::DeprecationWarning" + "ignore:pkg_resources:DeprecationWarning" ] markers =[ "external: interacts with a (potentially cost-incurring) third-party API" From 07e932aa32cfa3fd5da4b2157d7e624e98984e83 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:36:03 +0200 Subject: [PATCH 58/64] Remove .catch_warnings(). --- spacy_llm/compat.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spacy_llm/compat.py b/spacy_llm/compat.py index 3b6e7f0d..9e0ffdcd 100644 --- a/spacy_llm/compat.py +++ b/spacy_llm/compat.py @@ -1,6 +1,5 @@ # mypy: ignore-errors import sys -import warnings if sys.version_info[:2] >= (3, 8): # Python 3.8+ from typing import Protocol, runtime_checkable, Literal @@ -16,8 +15,7 @@ has_langchain = False try: - with warnings.catch_warnings(category=DeprecationWarning): - import minichain + import minichain has_minichain = True except (ImportError, AttributeError): From 6e146528deec151fb8b5bcda108872035fa8ba43 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:40:18 +0200 Subject: [PATCH 59/64] Move pytest config entirely into pyproject.toml. --- .github/workflows/test.yml | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83455ed0..cbc1732f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,4 +93,4 @@ jobs: env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | - python -m pytest --pyargs $MODULE_NAME -W error ignore:pkg_resources:DeprecationWarning + python -m pytest --pyargs $MODULE_NAME diff --git a/pyproject.toml b/pyproject.toml index 8a478362..c1494667 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ select = [ [tool.pytest.ini_options] testpaths = ["tests"] filterwarnings = [ + "error", "ignore:pkg_resources:DeprecationWarning" ] markers =[ From 65a312dda5dc1995bd16d828aa06840e4633df3e Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:44:18 +0200 Subject: [PATCH 60/64] Ignore all DepreciationWarnings. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c1494667..db177d0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,7 @@ select = [ testpaths = ["tests"] filterwarnings = [ "error", - "ignore:pkg_resources:DeprecationWarning" + "ignore::DeprecationWarning" ] markers =[ "external: interacts with a (potentially cost-incurring) third-party API" From 87fd906132659805e7793430dd5a8751601ca3c3 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:53:30 +0200 Subject: [PATCH 61/64] Fix paths in text_textcat.py. --- spacy_llm/tests/tasks/test_textcat.py | 35 +++++++++++++++------------ 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/spacy_llm/tests/tasks/test_textcat.py b/spacy_llm/tests/tasks/test_textcat.py index 0d871d7a..b3a11696 100644 --- a/spacy_llm/tests/tasks/test_textcat.py +++ b/spacy_llm/tests/tasks/test_textcat.py @@ -1,4 +1,6 @@ # mypy: ignore-errors +from pathlib import Path + import pytest import spacy from confection import Config @@ -8,6 +10,9 @@ from spacy_llm.tasks.textcat import TextCatTask +EXAMPLES_DIR = Path(__file__).parent / "examples" + + @pytest.fixture def zeroshot_cfg_string(): return """ @@ -38,7 +43,7 @@ def zeroshot_cfg_string(): @pytest.fixture def fewshot_cfg_string(): - return """ + return f""" [nlp] lang = "en" pipeline = ["llm"] @@ -56,7 +61,7 @@ def fewshot_cfg_string(): [components.llm.task.examples] @misc: "spacy.FewShotReader.v1" - path: spacy_llm/tests/tasks/examples/textcat_examples.yml + path: {EXAMPLES_DIR / "textcat_examples.yml"} [components.llm.task.normalizer] @misc: "spacy.LowercaseNormalizer.v1" @@ -64,7 +69,7 @@ def fewshot_cfg_string(): [components.llm.backend] @llm_backends: "spacy.REST.v1" api: "OpenAI" - config: {} + config: {{}} """ @@ -74,7 +79,7 @@ def binary(): labels = "Recipe" gold_cats = ["Recipe"] exclusive_classes = True - examples_path = "spacy_llm/tests/tasks/examples/textcat_binary_examples.yml" + examples_path = EXAMPLES_DIR / "textcat_binary_examples.yml" return text, labels, gold_cats, exclusive_classes, examples_path @@ -84,7 +89,7 @@ def multilabel_excl(): labels = "Recipe,Feedback,Comment" gold_cats = ["Recipe", "Feedback", "Comment"] exclusive_classes = True - examples_path = "spacy_llm/tests/tasks/examples/textcat_multi_excl_examples.yml" + examples_path = EXAMPLES_DIR / "textcat_multi_excl_examples.yml" return text, labels, gold_cats, exclusive_classes, examples_path @@ -94,7 +99,7 @@ def multilabel_nonexcl(): labels = "Recipe,Feedback,Comment" gold_cats = ["Recipe", "Feedback", "Comment"] exclusive_classes = False - examples_path = "spacy_llm/tests/tasks/examples/textcat_multi_nonexcl_examples.yml" + examples_path = EXAMPLES_DIR / "textcat_multi_nonexcl_examples.yml" return text, labels, gold_cats, exclusive_classes, examples_path @@ -244,9 +249,9 @@ def test_textcat_multilabel_labels_are_correct( @pytest.mark.parametrize( "examples_path", [ - "spacy_llm/tests/tasks/examples/textcat_binary_examples.json", - "spacy_llm/tests/tasks/examples/textcat_binary_examples.yml", - "spacy_llm/tests/tasks/examples/textcat_binary_examples.jsonl", + EXAMPLES_DIR / "textcat_binary_examples.json", + EXAMPLES_DIR / "textcat_binary_examples.yml", + EXAMPLES_DIR / "textcat_binary_examples.jsonl", ], ) def test_jinja_template_rendering_with_examples_for_binary(examples_path, binary): @@ -309,9 +314,9 @@ def test_jinja_template_rendering_with_examples_for_binary(examples_path, binary @pytest.mark.parametrize( "examples_path", [ - "spacy_llm/tests/tasks/examples/textcat_multi_excl_examples.json", - "spacy_llm/tests/tasks/examples/textcat_multi_excl_examples.yml", - "spacy_llm/tests/tasks/examples/textcat_multi_excl_examples.jsonl", + EXAMPLES_DIR / "textcat_multi_excl_examples.json", + EXAMPLES_DIR / "textcat_multi_excl_examples.yml", + EXAMPLES_DIR / "textcat_multi_excl_examples.jsonl", ], ) def test_jinja_template_rendering_with_examples_for_multilabel_exclusive( @@ -371,9 +376,9 @@ def test_jinja_template_rendering_with_examples_for_multilabel_exclusive( @pytest.mark.parametrize( "examples_path", [ - "spacy_llm/tests/tasks/examples/textcat_multi_nonexcl_examples.json", - "spacy_llm/tests/tasks/examples/textcat_multi_nonexcl_examples.yml", - "spacy_llm/tests/tasks/examples/textcat_multi_nonexcl_examples.jsonl", + EXAMPLES_DIR / "textcat_multi_nonexcl_examples.json", + EXAMPLES_DIR / "textcat_multi_nonexcl_examples.yml", + EXAMPLES_DIR / "textcat_multi_nonexcl_examples.jsonl", ], ) def test_jinja_template_rendering_with_examples_for_multilabel_nonexclusive( From 3019bd47cd44f74fb8553636c125d33795bc3632 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 13:56:48 +0200 Subject: [PATCH 62/64] Fix paths in text_textcat.py. --- spacy_llm/tests/tasks/test_textcat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spacy_llm/tests/tasks/test_textcat.py b/spacy_llm/tests/tasks/test_textcat.py index b3a11696..e39bf629 100644 --- a/spacy_llm/tests/tasks/test_textcat.py +++ b/spacy_llm/tests/tasks/test_textcat.py @@ -61,7 +61,7 @@ def fewshot_cfg_string(): [components.llm.task.examples] @misc: "spacy.FewShotReader.v1" - path: {EXAMPLES_DIR / "textcat_examples.yml"} + path: {str(EXAMPLES_DIR / "textcat_examples.yml")} [components.llm.task.normalizer] @misc: "spacy.LowercaseNormalizer.v1" From 621af13e2204e5c9306d8b5f3faa62fbfc9c503f Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 14:00:40 +0200 Subject: [PATCH 63/64] Fix paths in text_textcat.py. --- spacy_llm/tests/tasks/test_textcat.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/spacy_llm/tests/tasks/test_textcat.py b/spacy_llm/tests/tasks/test_textcat.py index e39bf629..5bca52fa 100644 --- a/spacy_llm/tests/tasks/test_textcat.py +++ b/spacy_llm/tests/tasks/test_textcat.py @@ -79,7 +79,7 @@ def binary(): labels = "Recipe" gold_cats = ["Recipe"] exclusive_classes = True - examples_path = EXAMPLES_DIR / "textcat_binary_examples.yml" + examples_path = str(EXAMPLES_DIR / "textcat_binary_examples.yml") return text, labels, gold_cats, exclusive_classes, examples_path @@ -89,7 +89,7 @@ def multilabel_excl(): labels = "Recipe,Feedback,Comment" gold_cats = ["Recipe", "Feedback", "Comment"] exclusive_classes = True - examples_path = EXAMPLES_DIR / "textcat_multi_excl_examples.yml" + examples_path = str(EXAMPLES_DIR / "textcat_multi_excl_examples.yml") return text, labels, gold_cats, exclusive_classes, examples_path @@ -99,7 +99,7 @@ def multilabel_nonexcl(): labels = "Recipe,Feedback,Comment" gold_cats = ["Recipe", "Feedback", "Comment"] exclusive_classes = False - examples_path = EXAMPLES_DIR / "textcat_multi_nonexcl_examples.yml" + examples_path = str(EXAMPLES_DIR / "textcat_multi_nonexcl_examples.yml") return text, labels, gold_cats, exclusive_classes, examples_path @@ -249,9 +249,9 @@ def test_textcat_multilabel_labels_are_correct( @pytest.mark.parametrize( "examples_path", [ - EXAMPLES_DIR / "textcat_binary_examples.json", - EXAMPLES_DIR / "textcat_binary_examples.yml", - EXAMPLES_DIR / "textcat_binary_examples.jsonl", + str(EXAMPLES_DIR / "textcat_binary_examples.json"), + str(EXAMPLES_DIR / "textcat_binary_examples.yml"), + str(EXAMPLES_DIR / "textcat_binary_examples.jsonl"), ], ) def test_jinja_template_rendering_with_examples_for_binary(examples_path, binary): @@ -314,9 +314,9 @@ def test_jinja_template_rendering_with_examples_for_binary(examples_path, binary @pytest.mark.parametrize( "examples_path", [ - EXAMPLES_DIR / "textcat_multi_excl_examples.json", - EXAMPLES_DIR / "textcat_multi_excl_examples.yml", - EXAMPLES_DIR / "textcat_multi_excl_examples.jsonl", + str(EXAMPLES_DIR / "textcat_multi_excl_examples.json"), + str(EXAMPLES_DIR / "textcat_multi_excl_examples.yml"), + str(EXAMPLES_DIR / "textcat_multi_excl_examples.jsonl"), ], ) def test_jinja_template_rendering_with_examples_for_multilabel_exclusive( @@ -376,9 +376,9 @@ def test_jinja_template_rendering_with_examples_for_multilabel_exclusive( @pytest.mark.parametrize( "examples_path", [ - EXAMPLES_DIR / "textcat_multi_nonexcl_examples.json", - EXAMPLES_DIR / "textcat_multi_nonexcl_examples.yml", - EXAMPLES_DIR / "textcat_multi_nonexcl_examples.jsonl", + str(EXAMPLES_DIR / "textcat_multi_nonexcl_examples.json"), + str(EXAMPLES_DIR / "textcat_multi_nonexcl_examples.yml"), + str(EXAMPLES_DIR / "textcat_multi_nonexcl_examples.jsonl"), ], ) def test_jinja_template_rendering_with_examples_for_multilabel_nonexclusive( From 38558ae30d0b324a6e997ac036ceaea4f4bbe913 Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Wed, 10 May 2023 14:04:32 +0200 Subject: [PATCH 64/64] Restore all platforms. --- .github/workflows/test.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cbc1732f..9db20142 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,19 +22,19 @@ jobs: strategy: fail-fast: true matrix: -# os: [ubuntu-latest, windows-latest, macos-latest] -# python_version: ["3.11"] + os: [ubuntu-latest, windows-latest, macos-latest] + python_version: ["3.11"] include: -# - os: ubuntu-20.04 -# python_version: "3.6" -# - os: windows-latest -# python_version: "3.7" -# - os: macos-latest -# python_version: "3.8" + - os: ubuntu-20.04 + python_version: "3.6" + - os: windows-latest + python_version: "3.7" + - os: macos-latest + python_version: "3.8" - os: ubuntu-latest python_version: "3.9" -# - os: windows-latest -# python_version: "3.10" + - os: windows-latest + python_version: "3.10" runs-on: ${{ matrix.os }}