From 50c620917fa5dfa61c18f12e222b90a8f94f9e11 Mon Sep 17 00:00:00 2001 From: Antoine DESRUET Date: Tue, 14 Jun 2022 16:42:58 +0200 Subject: [PATCH] feat: get task data and task annotation --- setup.py | 2 +- src/CVAT/_get.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 95c6c47..45a32ab 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="CVAT wrapper", - version="0.0.16", + version="0.0.17", author="antwxne", author_email="antoine.desruet@epitech.eu", description="Python wrapper for CVAT API", diff --git a/src/CVAT/_get.py b/src/CVAT/_get.py index 82b7b37..1909848 100644 --- a/src/CVAT/_get.py +++ b/src/CVAT/_get.py @@ -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()) \ No newline at end of file