Skip to content
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
4 changes: 3 additions & 1 deletion pyrit/prompt_converter/add_image_to_video_converter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

import contextlib
import logging
import os
from pathlib import Path
Expand Down Expand Up @@ -177,7 +178,8 @@ async def _add_image_to_video(self, image_path: str, output_path: str) -> str:
# Release everything
cap.release()
output_video.release()
cv2.destroyAllWindows()
with contextlib.suppress(cv2.error):
cv2.destroyAllWindows() # Not available in headless OpenCV builds
if azure_storage_flag:
os.remove(local_temp_path)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from sqlalchemy import inspect

from pyrit.identifiers import AttackIdentifier
from pyrit.identifiers import ComponentIdentifier
from pyrit.memory import MemoryInterface, SQLiteMemory
from pyrit.models import Message, MessagePiece
from pyrit.prompt_target import PromptChatTarget, limit_requests_per_minute
Expand Down Expand Up @@ -49,7 +49,7 @@ def set_system_prompt(
*,
system_prompt: str,
conversation_id: str,
attack_identifier: Optional[AttackIdentifier] = None,
attack_identifier: Optional[ComponentIdentifier] = None,
labels: Optional[dict[str, str]] = None,
) -> None:
self.system_prompt = system_prompt
Expand Down
12 changes: 10 additions & 2 deletions tests/integration/score/test_hitl_gradio_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
from pyrit.memory import CentralMemory, MemoryInterface
from pyrit.models import MessagePiece, Score
from pyrit.score import HumanInTheLoopScorerGradio
from pyrit.ui.rpc import RPCAlreadyRunningException
from pyrit.ui.rpc_client import RPCClient, RPCClientStoppedException

try:
from pyrit.ui.rpc import RPCAlreadyRunningException
from pyrit.ui.rpc_client import RPCClient, RPCClientStoppedException

_rpyc_available = True
except (ImportError, ModuleNotFoundError):
_rpyc_available = False

pytestmark = pytest.mark.skipif(not _rpyc_available, reason="rpyc not installed")


def if_gradio_installed():
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/targets/test_targets_and_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ async def test_connect_openai_completion(sqlite_instance):
@pytest.mark.parametrize(
("endpoint", "api_key", "model_name"),
[
("OPENAI_IMAGE_ENDPOINT1", "OPENAI_IMAGE_API_KEY1", "OPENAI_IMAGE_MODEL1"), # DALL-E-3
("OPENAI_IMAGE_ENDPOINT1", "OPENAI_IMAGE_API_KEY1", "OPENAI_IMAGE_MODEL1"), # gpt-image-1.5
("OPENAI_IMAGE_ENDPOINT2", "OPENAI_IMAGE_API_KEY2", "OPENAI_IMAGE_MODEL2"), # gpt-image-1
("PLATFORM_OPENAI_IMAGE_ENDPOINT", "PLATFORM_OPENAI_IMAGE_KEY", "PLATFORM_OPENAI_IMAGE_MODEL"), # DALL-E-3
("PLATFORM_OPENAI_IMAGE_ENDPOINT", "PLATFORM_OPENAI_IMAGE_KEY", "PLATFORM_OPENAI_IMAGE_MODEL"), # gpt-image-1.5
],
)
async def test_connect_image(sqlite_instance, endpoint, api_key, model_name):
Expand Down
Loading