diff --git a/README.md b/README.md index 851a222..f9dd9ca 100644 --- a/README.md +++ b/README.md @@ -1363,6 +1363,43 @@ client.delete_task(task_id="YOUR_TASK_ID") id_name_map = client.get_task_id_name_map(project="YOUR_PROJECT_SLUG") ``` +#### Create Task from S3 + +Task creation from S3. + +- Support project + - Image + - Video + - Audio + - Text + + +- To use it, you need to set the contents of the following link. +https://docs.fastlabel.ai/docs/integrations-aws-s3 + +- Setup AWS S3 properties +```python +status = client.update_aws_s3_storage( + project="YOUR_PROJECT_SLUG", + bucket_name="S3_BUCKET_NAME", + bucket_region="S3_REGIONS", +) +``` + +- Run create task from AWS S3 +```python +history = client.create_task_from_aws_s3( + project="YOUR_PROJECT_SLUG", +) +``` + +- Get AWS S3 import status +```python +history = client.get_aws_s3_import_status_by_project( + project="YOUR_PROJECT_SLUG", +) +``` + ## Annotation ### Create Annotation diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index cb3e4a7..a941a45 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -2825,6 +2825,80 @@ def copy_project(self, project_id: str) -> None: endpoint = "projects/copy" return self.api.post_request(endpoint, payload=payload) + def update_aws_s3_storage( + self, + project: str, + bucket_name: str, + bucket_region: str, + prefix: str = None + ) -> str: + """ + Insert or update AWS S3 storage settings. + + project is a slug of the project (Required). + bucket_name is a bucket name of the aws s3 (Required). + bucket_region is a bucket region of the aws s3 (Required). + prefix is a folder name in the aws s3 bucket. (Optional). + If sample_dir is specified as a prefix in the case of a hierarchical structure like the bucket below, + only the data under the sample_dir directory will be linked. + If not specified, everything under the bucket will be linked. + + [tree structure] + fastlabel + ├── sample1.jpg + └── sample_dir + └── sample2.jpg + + """ + endpoint = "storages/aws-s3/" + project + payload = { + "bucketName": bucket_name, + "bucketRegion": bucket_region, + } + if prefix: + payload["prefix"] = prefix + return self.api.put_request(endpoint, payload=payload) + + def create_task_from_aws_s3( + self, + project: str, + status: str = "registered", + tags: list[str] = [], + priority: int = 0, + ) -> dict: + """ + Insert or update AWS S3 storage settings. + + project is a slug of the project (Required). + status can be 'registered', 'completed', 'skipped', + 'reviewed', 'sent_back', 'approved', 'declined' (default: registered) (Optional). + tags is a list of tag (default: []) (Optional). + priority is the priority of the task (default: none) (Optional). + Set one of the numbers corresponding to: + none = 0, + low = 10, + medium = 20, + high = 30, + """ + endpoint = "tasks/aws-s3" + payload = { + "project": project, + "status": status, + "tags": tags, + "priority": priority, + } + return self.api.post_request(endpoint, payload=payload) + + def get_aws_s3_import_status_by_project( + self, + project: str, + ) -> dict: + """ + Returns a import status of create task from AWS S3. + """ + endpoint = "tasks/import/status/aws-s3/" + project + return self.api.get_request(endpoint) + @staticmethod def __fill_assign_users(payload: dict, **kwargs): if "assignee" in kwargs: