44from scaleapi .evaluation_tasks import EvaluationTask
55from scaleapi .exceptions import ScaleInvalidRequest
66from scaleapi .files import File
7- from scaleapi .projects import Project
7+ from scaleapi .projects import Project , TaskTemplate
88from scaleapi .training_tasks import TrainingTask
99
1010from ._version import __version__ # noqa: F401
@@ -619,6 +619,7 @@ def create_batch(
619619 callback : str = "" ,
620620 calibration_batch : bool = False ,
621621 self_label_batch : bool = False ,
622+ metadata : Dict = None ,
622623 ) -> Batch :
623624 """Create a new Batch within a project.
624625 https://docs.scale.com/reference#batch-creation
@@ -639,6 +640,8 @@ def create_batch(
639640 Only applicable for self serve projects.
640641 Create a self_label batch by setting
641642 the self_label_batch flag to true.
643+ metadata (Dict):
644+ Optional metadata to be stored at the TaskBatch level
642645
643646 Returns:
644647 Batch: Created batch object
@@ -650,6 +653,7 @@ def create_batch(
650653 calibration_batch = calibration_batch ,
651654 self_label_batch = self_label_batch ,
652655 callback = callback ,
656+ metadata = metadata or {},
653657 )
654658 batchdata = self .api .post_request (endpoint , body = payload )
655659 return Batch (batchdata , self )
@@ -828,6 +832,22 @@ def get_batches(
828832 offset += batches .limit
829833 has_more = batches .has_more
830834
835+ def set_batch_metadata (self , batch_name : str , metadata : Dict ) -> Batch :
836+ """Sets metadata for a TaskBatch.
837+
838+ Args:
839+ batch_name (str):
840+ Batch name
841+ metadata (Dict):
842+ Metadata to set for TaskBatch
843+
844+ Returns:
845+ Batch
846+ """
847+ endpoint = f"batches/{ Api .quote_string (batch_name )} /setMetadata"
848+ batchdata = self .api .post_request (endpoint , body = metadata )
849+ return Batch (batchdata , self )
850+
831851 def create_project (
832852 self ,
833853 project_name : str ,
@@ -934,6 +954,23 @@ def update_project(self, project_name: str, **kwargs) -> Project:
934954 projectdata = self .api .post_request (endpoint , body = kwargs )
935955 return Project (projectdata , self )
936956
957+ def get_project_template (self , project_name : str ) -> TaskTemplate :
958+ """Gets the task template of a project if a template exists.
959+ Throws an error if the project task-type does not support
960+ Task Templates. Currently only TextCollection and Chat task
961+ types support Task Templates.
962+
963+ Args:
964+ project_name (str):
965+ Project's name
966+
967+ Returns:
968+ TaskTemplate
969+ """
970+ endpoint = f"projects/{ Api .quote_string (project_name )} /taskTemplates"
971+ template = self .api .get_request (endpoint )
972+ return TaskTemplate (template , self )
973+
937974 def upload_file (self , file : IO , ** kwargs ) -> File :
938975 """Upload file.
939976 Refer to Files API Reference:
0 commit comments