From cfe01da8f20fdbd7d36b145f74d4895c7f97d90d Mon Sep 17 00:00:00 2001 From: Javier Luna Molina Date: Wed, 11 Sep 2019 17:15:35 +0200 Subject: [PATCH 1/2] Add 'format' to export_project (#5) * Add format to adapter's interface * Add format to export_project in adapter --- pycaprio/core/adapters/http_adapter.py | 5 +++-- pycaprio/core/interfaces/adapter.py | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pycaprio/core/adapters/http_adapter.py b/pycaprio/core/adapters/http_adapter.py index cb5e7bb..ae39221 100644 --- a/pycaprio/core/adapters/http_adapter.py +++ b/pycaprio/core/adapters/http_adapter.py @@ -101,8 +101,9 @@ def delete_annotation(self, project_id: int, document_id: int, user_name: str): allowed_statuses=(204, 200)) return True - def export_project(self, project_id: int) -> bytes: - response = self.client.get(f"/projects/{project_id}/export.zip", allowed_statuses=(200,)) + def export_project(self, project_id: int, format: str = DocumentFormats.DEFAULT) -> bytes: + response = self.client.get(f"/projects/{project_id}/export.zip", allowed_statuses=(200,), + params={'format': format}) return response.content def import_project(self, zip_stream: IO) -> Project: diff --git a/pycaprio/core/interfaces/adapter.py b/pycaprio/core/interfaces/adapter.py index c4d58a4..c1f89d4 100644 --- a/pycaprio/core/interfaces/adapter.py +++ b/pycaprio/core/interfaces/adapter.py @@ -61,11 +61,13 @@ def annotations(self, project_id: int, document_id: int) -> List[Annotation]: pass # pragma: no cover @abstractmethod - def annotation(self, project_id: int, document_id: int, annotation_id: int) -> bytes: + def annotation(self, project_id: int, document_id: int, annotation_id: int, + format: str = DocumentFormats.DEFAULT) -> bytes: """ Retrieves a Document :param project_id: The project_id of the Project where the Annotation is located :param document_id: The document_id of the Document where the Annotation is located + :param format: Format in which the annotation will be downloaded :return: Content of the Annotation in bytes """ pass # pragma: no cover @@ -98,7 +100,7 @@ def create_document(self, project_id: int, document_name: str, content: IO, @abstractmethod def create_annotation(self, project_id: int, document_id: int, user_name: str, content: IO, - annotation_format: str = DocumentFormats.DEFAULT, state: str = AnnotationStatus): + annotation_format: str = DocumentFormats.DEFAULT, state: str = AnnotationStatus.DEFAULT): """ Creates a Document :param project_id: Id of the Project where the new Document will be created @@ -139,10 +141,11 @@ def delete_annotation(self, project_id: int, document_id: int, user_name: str) - pass # pragma: no cover @abstractmethod - def export_project(self, project_id: int) -> bytes: + def export_project(self, project_id: int, format: str = DocumentFormats.DEFAULT) -> bytes: """ Exports a Project into a .zip file. :param project_id: Project id. + :param format: Format in which the documents and annotations will be exported. :return: Zip file in bytes. """ pass # pragma: no cover From 43e6f01c5ac72abefe4a71b3445bc8164d02f29b Mon Sep 17 00:00:00 2001 From: JavierLuna Date: Wed, 11 Sep 2019 17:19:56 +0200 Subject: [PATCH 2/2] Bump version to 0.0.2rc3 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8de9132..0263254 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pycaprio" -version = "0.0.2rc2" +version = "0.0.2rc3" description = "Python client for the INCEpTION annotation tool API" authors = ["Savanamed"] license = "MIT"