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

fixes for pydantic v2 #184

Merged
merged 1 commit into from
Mar 5, 2024
Merged

fixes for pydantic v2 #184

merged 1 commit into from
Mar 5, 2024

Conversation

crowncastlejsl
Copy link
Contributor

Overview

pydantic<3,>1.7 from the requirements.txt resolves to v.6.1, which has some backwards incompatibility with v1

Reproducing

Code snippet to reproduce:

from label_studio_sdk import Client

API_KEY = os.environ["LABEL_STUDIO_API_KEY"]
ls = Client(url=LABEL_STUDIO_URL, api_key=API_KEY)
assert ls.check_connection()["status"] == "UP", 'Connection status is not UP'
user_table = ls.get_users()

Error:

pydantic_core._pydantic_core.ValidationError: 1 validation error for User
org_membership
  Field required [type=missing, input_value={'id': 1, 'first_name': '...ject at 0x7f9712a4ff50>}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.6/v/missing

Details

Client.get_users makes an API call to /api/users which never returns an org_membership field, according to the API reference

The Optional field works differently in Pydantic v2, and is actually required.

Fix

  • Added defaults for some Optional fields
  • Sorted some imports with isort

@niklub niklub merged commit 5336efa into HumanSignal:master Mar 5, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants