|
1 | 1 | from typing import IO, Dict, Generator, Generic, List, TypeVar, Union |
2 | 2 |
|
3 | 3 | from scaleapi.batches import Batch, BatchStatus |
| 4 | +from scaleapi.evaluation_tasks import EvaluationTask |
4 | 5 | from scaleapi.exceptions import ScaleInvalidRequest |
5 | 6 | from scaleapi.files import File |
6 | 7 | from scaleapi.projects import Project |
@@ -787,3 +788,42 @@ def import_file(self, file_url: str, **kwargs) -> File: |
787 | 788 | payload = dict(file_url=file_url, **kwargs) |
788 | 789 | filedata = self.api.post_request(endpoint, body=payload) |
789 | 790 | return File(filedata, self) |
| 791 | + |
| 792 | + def create_evaluation_task( |
| 793 | + self, |
| 794 | + task_type: TaskType, |
| 795 | + **kwargs, |
| 796 | + ) -> EvaluationTask: |
| 797 | + """This method can only be used for Self-Serve projects. |
| 798 | + Supported Task Types: [ |
| 799 | + ImageAnnotation, |
| 800 | + Categorization, |
| 801 | + TextCollection, |
| 802 | + NamedEntityRecognition |
| 803 | + ] |
| 804 | + Parameters may differ based on the given task_type. |
| 805 | +
|
| 806 | + Args: |
| 807 | + task_type (TaskType): |
| 808 | + Task type to be created |
| 809 | + e.g.. `TaskType.ImageAnnotation` |
| 810 | + **kwargs: |
| 811 | + The same set of parameters are expected with |
| 812 | + create_task function. Additionally with |
| 813 | + an expected_response and an optional initial_response |
| 814 | + if you want to make it a review phase evaluation task |
| 815 | + The expected_response/initial_response should follow |
| 816 | + the format of any other tasks' response on your project. |
| 817 | + It's recommended to try a self_label batch to get |
| 818 | + familiar with the response format. |
| 819 | + Scale's API documentation. |
| 820 | + https://docs.scale.com/reference |
| 821 | +
|
| 822 | + Returns: |
| 823 | + EvaluationTask: |
| 824 | + Returns created evaluation task. |
| 825 | + """ |
| 826 | + endpoint = f"evaluation_tasks/{task_type.value}" |
| 827 | + |
| 828 | + evaluation_task_data = self.api.post_request(endpoint, body=kwargs) |
| 829 | + return EvaluationTask(evaluation_task_data, self) |
0 commit comments