litellm icon indicating copy to clipboard operation
litellm copied to clipboard

Fix warnings from pydantic

Open lj-wego opened this issue 1 year ago โ€ข 6 comments

Attempt to fix pydantic warnings.

before:

poetry run pytest . | grep warning
Configuration file exists at /Users/lj/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/lj/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.
=============================== warnings summary ===============================
../../../../Library/Caches/pypoetry/virtualenvs/litellm-vO9t8ogX-py3.11/lib/python3.11/site-packages/pydantic/_internal/_config.py:284: 25 warnings
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 39 warnings, 4 errors in 2.37s ========================

after:

poetry run pytest . | grep warning
Configuration file exists at /Users/lj/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/lj/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.
=============================== warnings summary ===============================
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================= 1 warning, 4 errors in 2.04s =========================

running same test as #3600:

poetry run pytest litellm/tests/test_proxy_server.py
Configuration file exists at /Users/lj/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/lj/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.
================================================================== test session starts ==================================================================
platform darwin -- Python 3.11.3, pytest-7.4.4, pluggy-1.5.0
rootdir: /Users/lj/Documents/litellm
plugins: anyio-4.3.0, asyncio-0.23.6, mock-3.14.0
asyncio: mode=Mode.STRICT
collected 12 items                                                                                                                                      

litellm/tests/test_proxy_server.py s..........s                                                                                                   [100%]

=================================================================== warnings summary ====================================================================
litellm/utils.py:59
  /Users/lj/Documents/litellm/litellm/utils.py:59: DeprecationWarning: open_text is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
    with resources.open_text("litellm.llms.tokenizers", "anthropic_tokenizer.json") as f:

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= 10 passed, 2 skipped, 1 warning in 7.84s ========================================================

Not fixing the import lib warning as it is not explicitly related to pydantic.

Regarding pydantic v1 compatibility https://github.com/BerriAI/litellm/pull/3600#discussion_r1598686881

Openai (1.25.1) is using pydantic v2 https://github.com/openai/openai-python/blob/aed1e43745cd6358b4bafd3a39b3dfeee5e31a03/requirements.lock#L40

Relevant issues

Fixes #3417 #3600 #3664

Type

๐Ÿ› Bug Fix ๐Ÿงน Refactoring

lj-wego avatar May 16 '24 09:05 lj-wego

The latest updates on your projects. Learn more about Vercel for Git โ†—๏ธŽ

Name Status Preview Comments Updated (UTC)
litellm โœ… Ready (Inspect) Visit Preview ๐Ÿ’ฌ Add feedback May 31, 2024 3:39am

vercel[bot] avatar May 16 '24 09:05 vercel[bot]

Thanks for this @lj-wego,

Can you confirm it passes on the list of tests the previous PR attempting to address this failed on - https://github.com/BerriAI/litellm/pull/3664

  1. tests/test_ratelimit.py
  2. test_organizations.py/test_organization_new
  3. Failed linting on types/completion.py, types/router.py, types.embedding.py

krrishdholakia avatar May 21 '24 00:05 krrishdholakia

  1. tests/test_ratelimit.py

image

lj-wego avatar May 21 '24 03:05 lj-wego

test_organizations.py/test_organization_new

took awhile to figure out what needed to be ran but managed to set up a local docker postgres, prisma migrate and ran the server, and then the test.

image

results

image

lj-wego avatar May 21 '24 03:05 lj-wego

Failed linting on types/completion.py, types/router.py, types.embedding.py

i believe this fixes this https://github.com/BerriAI/litellm/pull/3670#discussion_r1604283980

lj-wego avatar May 21 '24 03:05 lj-wego

@krrishdholakia can confirm it works on my machine.

lj-wego avatar May 21 '24 03:05 lj-wego

Thanks! This is really cogging our CI logs. :(

rickyyx avatar May 30 '24 18:05 rickyyx

Merged new changes and updated one pesky class Config that was introduced.

Hands tied here for the CI since: a. i don't have most of the services API keys to properly run the full test/lint suite b. i don't use circle ci so can't reproduce the testing workflow.

lj-wego avatar May 31 '24 03:05 lj-wego

Merging in - i'll let you know if there's any issues on ci/cd @lj-wego

Thank you again for your help here!

krrishdholakia avatar May 31 '24 05:05 krrishdholakia

@krrishdholakia i notice the CI failing and this might be the issue.

installs older pydantic image

image

https://github.com/BerriAI/litellm/blob/deb87f71e330dcaf56574a477d9457d589754cd3/.circleci/requirements.txt#L10

lj-wego avatar May 31 '24 09:05 lj-wego

Added a PR here to address this. Unless this is reverted ๐Ÿ˜“

lj-wego avatar May 31 '24 10:05 lj-wego