From d706f805cea7e461e52225803b5244da2b1faeea Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Tue, 28 Jan 2025 15:26:40 -0600 Subject: [PATCH 1/3] update for ollama error change The latest ollama package changed the error raised from httpx to OSError * set new minimum version for ollama > 0.4.7 * update error handler in test --- pyproject.toml | 2 +- requirements.txt | 2 +- tests/generators/test_ollama.py | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index caa6f2bbf..8ffa017b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,7 @@ dependencies = [ "lorem==0.1.1", "xdg-base-dirs>=6.0.1", "wn==0.9.5", - "ollama>=0.1.7", + "ollama>=0.4.7", "tiktoken>=0.7.0" ] diff --git a/requirements.txt b/requirements.txt index 50de30fe5..e91cf0243 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,7 +34,7 @@ python-magic>=0.4.21; sys_platform != "win32" lorem==0.1.1 xdg-base-dirs>=6.0.1 wn==0.9.5 -ollama>=0.1.7 +ollama>=0.4.7 tiktoken>=0.7.0 # tests pytest>=8.0 diff --git a/tests/generators/test_ollama.py b/tests/generators/test_ollama.py index 49a557709..a419e78d7 100644 --- a/tests/generators/test_ollama.py +++ b/tests/generators/test_ollama.py @@ -2,7 +2,6 @@ import ollama import respx import httpx -from httpx import ConnectError from garak.generators.ollama import OllamaGeneratorChat, OllamaGenerator PINGED_OLLAMA_SERVER = False # Avoid calling the server multiple times if it is not running @@ -17,7 +16,7 @@ def ollama_is_running(): try: ollama.list() # Gets a list of all pulled models. Used as a ping OLLAMA_SERVER_UP = True - except ConnectError: + except ConnectionError: OLLAMA_SERVER_UP = False finally: PINGED_OLLAMA_SERVER = True @@ -141,4 +140,4 @@ def test_error_on_nonexistant_model_chat_mocked(respx_mock): model_name = "non-existant-model" gen = OllamaGeneratorChat(model_name) with pytest.raises(ollama.ResponseError): - gen.generate("This shouldnt work") \ No newline at end of file + gen.generate("This shouldnt work") From 74651c5183f03038976de77c60f948e44f8a0b7b Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Wed, 29 Jan 2025 08:30:13 -0600 Subject: [PATCH 2/3] add nightly packaging and pytest workflow --- .github/workflows/nightly.yml | 20 ++++++++++++++++++++ .github/workflows/remote_package_install.yml | 1 + .github/workflows/test_linux.yml | 1 + .github/workflows/test_macos.yml | 1 + .github/workflows/test_windows.yml | 1 + 5 files changed, 24 insertions(+) create mode 100644 .github/workflows/nightly.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..2d252036f --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,20 @@ +name: Nightly Testing + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + linux: + name: Nightly Linux + uses: ./.github/workflows/test_linux.yml + windows: + name: Nightly Windows + uses: ./.github/workflows/test_windows.yml + macos: + name: Nightly MacOS + uses: ./.github/workflows/test_macos.yml + package_test: + name: Nightly Packaging + uses: ./.github/workflows/remote_package_install.yml diff --git a/.github/workflows/remote_package_install.yml b/.github/workflows/remote_package_install.yml index 91380b6f6..047a1d41f 100644 --- a/.github/workflows/remote_package_install.yml +++ b/.github/workflows/remote_package_install.yml @@ -6,6 +6,7 @@ on: - 'main' pull_request: workflow_dispatch: + workflow_call: jobs: build: diff --git a/.github/workflows/test_linux.yml b/.github/workflows/test_linux.yml index 9a5ce5bc3..5cafa1656 100644 --- a/.github/workflows/test_linux.yml +++ b/.github/workflows/test_linux.yml @@ -6,6 +6,7 @@ on: - 'main' pull_request: workflow_dispatch: + workflow_call: jobs: build: diff --git a/.github/workflows/test_macos.yml b/.github/workflows/test_macos.yml index 1f24a07a6..f32135440 100644 --- a/.github/workflows/test_macos.yml +++ b/.github/workflows/test_macos.yml @@ -6,6 +6,7 @@ on: - 'main' pull_request: workflow_dispatch: + workflow_call: jobs: build_macos: diff --git a/.github/workflows/test_windows.yml b/.github/workflows/test_windows.yml index 8f87fcb33..c4c0f4623 100644 --- a/.github/workflows/test_windows.yml +++ b/.github/workflows/test_windows.yml @@ -6,6 +6,7 @@ on: - 'main' pull_request: workflow_dispatch: + workflow_call: jobs: build_windows: From cfe125aa567fc740e48a20334c64abf006812cb5 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Wed, 29 Jan 2025 09:02:56 -0600 Subject: [PATCH 3/3] only run nighly in the core repository --- .github/workflows/nightly.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2d252036f..cc3039fdf 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -8,13 +8,17 @@ on: jobs: linux: name: Nightly Linux + if: github.repository_owner == 'NVIDIA' uses: ./.github/workflows/test_linux.yml windows: name: Nightly Windows + if: github.repository_owner == 'NVIDIA' uses: ./.github/workflows/test_windows.yml macos: name: Nightly MacOS + if: github.repository_owner == 'NVIDIA' uses: ./.github/workflows/test_macos.yml package_test: name: Nightly Packaging + if: github.repository_owner == 'NVIDIA' uses: ./.github/workflows/remote_package_install.yml