HumanSignal/label-studio-sdk

project.get_tasks(), get_labelled_tasks(), get_unlabelled_tasks() throws TypeError: list indices must be integers or slices, not str

binit9 opened this issue · 2 comments

It looks like an internal error where str is passed, but integers or slices were expected. project gets properly created and import/sync tasks works fine. Also, project.get_params() runs as expected. But get_tasks(), get_labelled_tasks(),
get_unlabelled_tasks(), create_predictions() none of them are working. Here is the detailed error for project.get_tasks() :

----> 2 project.get_tasks()

File ~/.local/lib/python3.8/site-packages/label_studio_sdk/project.py:592, in Project.get_tasks(self, filters, ordering, view_id, selected_ids, only_ids)
590 while True:
591 try:
--> 592 data = self.get_paginated_tasks(
593 filters=filters,
594 ordering=ordering,
595 view_id=view_id,
596 selected_ids=selected_ids,
597 only_ids=only_ids,
598 page=page,
599 page_size=100
600 )
601 result += data['tasks']
602 page += 1

File ~/.local/lib/python3.8/site-packages/label_studio_sdk/project.py:702, in Project.get_paginated_tasks(self, filters, ordering, view_id, selected_ids, page, page_size, only_ids)
699 raise LabelStudioException('Error loading tasks')
701 data = response.json()
--> 702 tasks = data['tasks']
703 if only_ids:
704 data['tasks'] = [task['id'] for task in tasks]

TypeError: list indices must be integers or slices, not str

You should upgrade your LS to the latest version from the develop branch, or downgrade SDK version to ~0.0.9.

You should upgrade your LS to the latest version from the develop branch, or downgrade SDK version to ~0.0.9.

@makseq Thanks a lot for the quick resolution. I downgraded sdk to 0.0.9 and get get_tasks() etc. working.