From 3e74d07cf46aaf8da014db039227157c0f54987a Mon Sep 17 00:00:00 2001 From: TheLunarLogic Date: Thu, 10 Jul 2025 19:05:33 +0530 Subject: [PATCH 1/3] [LABIMP-6971] Annotation_guide is now conditionally required based on annotation_template_id presence. --- labellerr/client.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/labellerr/client.py b/labellerr/client.py index b92024a..eba786a 100644 --- a/labellerr/client.py +++ b/labellerr/client.py @@ -1037,21 +1037,22 @@ def initiate_create_project(self, payload): try: result = {} # validate all the parameters - required_params = ['client_id', 'dataset_name', 'dataset_description', 'data_type', 'created_by', 'project_name','annotation_guide','autolabel'] + required_params = ['client_id', 'dataset_name', 'dataset_description', 'data_type', 'created_by', 'project_name','autolabel'] for param in required_params: if param not in payload: raise LabellerrError(f"Required parameter {param} is missing") - - if param == 'client_id' and not isinstance(payload[param], str): raise LabellerrError("client_id must be a non-empty string") - - if param == 'annotation_guide': - for guide in payload['annotation_guide']: - if 'option_type' not in guide: - raise LabellerrError("option_type is required in annotation_guide") - if guide['option_type'] not in OPTION_TYPE_LIST: - raise LabellerrError(f"option_type must be one of {OPTION_TYPE_LIST}") + + # annotation_guide is only required if annotation_template_id is not provided + if not payload.get('annotation_template_id'): + if 'annotation_guide' not in payload: + raise LabellerrError("Required parameter annotation_guide is missing") + for guide in payload['annotation_guide']: + if 'option_type' not in guide: + raise LabellerrError("option_type is required in annotation_guide") + if guide['option_type'] not in OPTION_TYPE_LIST: + raise LabellerrError(f"option_type must be one of {OPTION_TYPE_LIST}") if 'folder_to_upload' in payload and 'files_to_upload' in payload: @@ -1115,15 +1116,17 @@ def dataset_ready(): print("Dataset created and ready for use") - - annotation_template_id = self.create_annotation_guideline( - payload['client_id'], - payload['annotation_guide'], - payload['project_name'], - payload['data_type'] - ) - print("Annotation guidelines created") - + # Use annotation_template_id from payload if provided, else create a new one + if 'annotation_template_id' in payload and payload['annotation_template_id']: + annotation_template_id = payload['annotation_template_id'] + else: + annotation_template_id = self.create_annotation_guideline( + payload['client_id'], + payload['annotation_guide'], + payload['project_name'], + payload['data_type'] + ) + print("Annotation guidelines created") project_response = self.create_project( project_name=payload['project_name'], From 95e6099a15b9ab82a5de7cac8c2b5317f4321eee Mon Sep 17 00:00:00 2001 From: TheLunarLogic Date: Fri, 11 Jul 2025 15:55:52 +0530 Subject: [PATCH 2/3] [LABIMP-6971] Update error message for missing annotation_guide to clarify requirements --- labellerr/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/labellerr/client.py b/labellerr/client.py index eba786a..473a91d 100644 --- a/labellerr/client.py +++ b/labellerr/client.py @@ -1047,7 +1047,7 @@ def initiate_create_project(self, payload): # annotation_guide is only required if annotation_template_id is not provided if not payload.get('annotation_template_id'): if 'annotation_guide' not in payload: - raise LabellerrError("Required parameter annotation_guide is missing") + raise LabellerrError("Please provide either annotation guide or annotation template id") for guide in payload['annotation_guide']: if 'option_type' not in guide: raise LabellerrError("option_type is required in annotation_guide") From f8de7134bb10a9111f6bdb0fa303421f993e380e Mon Sep 17 00:00:00 2001 From: TheLunarLogic Date: Sat, 12 Jul 2025 14:44:16 +0530 Subject: [PATCH 3/3] [LABIMP-6971] Added validation check in "created_by" field --- labellerr/client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/labellerr/client.py b/labellerr/client.py index 473a91d..2cd7467 100644 --- a/labellerr/client.py +++ b/labellerr/client.py @@ -1,5 +1,5 @@ # labellerr/client.py - +import re import requests import uuid from .exceptions import LabellerrError @@ -1044,6 +1044,10 @@ def initiate_create_project(self, payload): if param == 'client_id' and not isinstance(payload[param], str): raise LabellerrError("client_id must be a non-empty string") + email = payload.get("created_by") + if not re.match(r"^[^@]+@[^@]+\.[^@]+$", email or ""): + raise LabellerrError("Please enter email id in created_by") + # annotation_guide is only required if annotation_template_id is not provided if not payload.get('annotation_template_id'): if 'annotation_guide' not in payload: @@ -1054,7 +1058,7 @@ def initiate_create_project(self, payload): if guide['option_type'] not in OPTION_TYPE_LIST: raise LabellerrError(f"option_type must be one of {OPTION_TYPE_LIST}") - + if 'folder_to_upload' in payload and 'files_to_upload' in payload: raise LabellerrError("Cannot provide both files_to_upload and folder_to_upload")