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

[Feature]: Add working local tests for Azure Content Safety Callbacks #3591

Open
ishaan-jaff opened this issue May 12, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@ishaan-jaff
Copy link
Contributor

The Feature

@Lunik would appreciate help on this - file is test_azure_content_safety.py

  • These tests were failing for us locally with this stacktrace
  • This will be marked as a BETA feature until we have testing on CI/CD
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x11737ba60>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x1173a8220>, 51413.432590791)]']
connector: <aiohttp.connector.TCPConnector object at 0x11737baf0>
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x11737beb0>
transport: <_SelectorSocketTransport closing fd=14>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 918, in write
    n = self._sock.send(data)
OSError: [Errno 9] Bad file descriptor

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 684, in _process_write_backlog
    self._transport.write(chunk)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 924, in write
    self._fatal_error(exc, 'Fatal write error on socket transport')
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 719, in _fatal_error
    self._force_close(exc)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/selector_events.py", line 731, in _force_close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 745, in call_soon
    self._check_closed()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

Motivation, pitch

Twitter / LinkedIn details

No response

@ishaan-jaff ishaan-jaff added the enhancement New feature or request label May 12, 2024
@Lunik
Copy link
Contributor

Lunik commented May 12, 2024

Hi, here is how is have tested it :

Prepare test env

python3 -m venv .venv
.venv/bin/activate

poetry install -E extra_proxy -E proxy
pip install pytest-asyncio
pip install azure-ai-contentsafety

Running the test

export AZURE_CONTENT_SAFETY_ENDPOINT="https://<INSTANCE_NAME>.cognitiveservices.azure.com/"
export AZURE_CONTENT_SAFETY_API_KEY="<API_KEY>"

poetry run pytest -p no:warnings litellm/tests/test_azure_content_safety.py

Result

====================================== test session starts =======================================
platform darwin -- Python 3.10.14, pytest-7.4.4, pluggy-1.4.0
rootdir: ~/litellm
plugins: anyio-4.3.0, mock-3.12.0, asyncio-0.23.6
asyncio: mode=strict
collected 8 items                                                                                                                                                      

litellm/tests/test_azure_content_safety.py ........                            [100%]

======================================= 8 passed in 4.36s ========================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants