Skip to content

Commit

Permalink
feat: get task data and task annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
antwxne committed Jun 14, 2022
1 parent 05dc0f5 commit 50c6209
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="CVAT wrapper",
version="0.0.16",
version="0.0.17",
author="antwxne",
author_email="[email protected]",
description="Python wrapper for CVAT API",
Expand Down
32 changes: 32 additions & 0 deletions src/CVAT/_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,35 @@ def get_project_infos(self, project_name: str) -> dict:
if response.status_code != 200:
raise Exception(response.content)
return response.json()["results"][0]

def get_task_annotation(self, task: Union[Task, int]) -> dict:
"""
It takes a task object or an integer as an argument and returns a dictionary of the task's annotations
Args:
task (Union[Task, int]): The task to get the annotation for.
Returns:
A dictionary of the task annotations.
"""
task = task.id if isinstance(task, Task) else task
response: Response = self.session.get(url=f'{self.url}/api/tasks/{task}/annotations')
if response.status_code != 200:
raise Exception(response.content)
return Task.from_json(response.json())

def get_task_data(self, task: Union[Task, int]) -> dict:
"""
It takes a task object or an integer as an argument, and returns a dictionary of the task's data
Args:
task (Union[Task, int]): The task you want to get the data for.
Returns:
A dictionary of the task data.
"""
task = task.id if isinstance(task, Task) else task
response: Response = self.session.get(url=f'{self.url}/api/tasks/{task}/data/meta')
if response.status_code != 200:
raise Exception(response.content)
return Task.from_json(response.json())

0 comments on commit 50c6209

Please sign in to comment.