HumanSignal / label-studio-sdk

Label Studio SDK
https://api.labelstud.io
Apache License 2.0
96 stars 59 forks source link

client.tasks.list with fields = 'all' fails on comment_authors #348

Open LeoVrana opened 5 days ago

LeoVrana commented 5 days ago

Hi!

I am on Label Studio enterprise, on version 1.0.5. I am trying to get annotation data for a project via the SDK + API. The problem is that when I iterate over tasks, any task with a comment inevitably throws a pydantic ValidationError:

>>> tasks = ls.tasks.list(project=project_id, fields='all')
>>> for t in tasks:
...     pass
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ls/.st_env/lib/python3.10/site-packages/label_studio_sdk/_extensions/pager_ext.py", line 23, in __iter__
    for item in super().__iter__():
  File "/home/ls/.st_env/lib/python3.10/site-packages/label_studio_sdk/core/pagination.py", line 42, in __iter__
    for page in self.iter_pages():
  File "/home/ls/.st_env/lib/python3.10/site-packages/label_studio_sdk/core/pagination.py", line 53, in iter_pages
    page = page.get_next()
  File "/home/ls/.st_env/lib/python3.10/site-packages/label_studio_sdk/tasks/client.py", line 217, in <lambda>
    _get_next = lambda: self.list(
  File "/home/ls/.st_env/lib/python3.10/site-packages/label_studio_sdk/tasks/client_ext.py", line 10, in list
    return SyncPagerExt.from_sync_pager(super().list(**kwargs))
  File "/home/ls/.st_env/lib/python3.10/site-packages/label_studio_sdk/tasks/client.py", line 215, in list
    _parsed_response = pydantic_v1.parse_obj_as(TasksListResponse, _response.json())  # type: ignore
  File "/home/ls/.st_env/lib/python3.10/site-packages/pydantic/v1/tools.py", line 38, in parse_obj_as
    return model_type(__root__=obj).__root__
  File "/home/ls/.st_env/lib/python3.10/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 3 validation errors for ParsingModel[TasksListResponse]
__root__ -> tasks -> 11 -> comment_authors -> 0
  value is not a valid integer (type=type_error.integer)
__root__ -> tasks -> 20 -> comment_authors -> 0
  value is not a valid integer (type=type_error.integer)
__root__ -> tasks -> 78 -> comment_authors -> 0
  value is not a valid integer (type=type_error.integer)

Let me know if there is any other information you might need.

dsinghvi commented 5 days ago

@LeoVrana thanks for submitting this issue, will follow up