Skip to content

Commit 08d7a7b

Browse files
authored
Merge pull request #124 from fastlabel/issue-2869-create-task-by-s3-at-sdk
feat: add create task from s3 by sdk
2 parents aa80c5d + 76f05d4 commit 08d7a7b

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,43 @@ client.delete_task(task_id="YOUR_TASK_ID")
13631363
id_name_map = client.get_task_id_name_map(project="YOUR_PROJECT_SLUG")
13641364
```
13651365

1366+
#### Create Task from S3
1367+
1368+
Task creation from S3.
1369+
1370+
- Support project
1371+
- Image
1372+
- Video
1373+
- Audio
1374+
- Text
1375+
1376+
1377+
- To use it, you need to set the contents of the following link.
1378+
https://docs.fastlabel.ai/docs/integrations-aws-s3
1379+
1380+
- Setup AWS S3 properties
1381+
```python
1382+
status = client.update_aws_s3_storage(
1383+
project="YOUR_PROJECT_SLUG",
1384+
bucket_name="S3_BUCKET_NAME",
1385+
bucket_region="S3_REGIONS",
1386+
)
1387+
```
1388+
1389+
- Run create task from AWS S3
1390+
```python
1391+
history = client.create_task_from_aws_s3(
1392+
project="YOUR_PROJECT_SLUG",
1393+
)
1394+
```
1395+
1396+
- Get AWS S3 import status
1397+
```python
1398+
history = client.get_aws_s3_import_status_by_project(
1399+
project="YOUR_PROJECT_SLUG",
1400+
)
1401+
```
1402+
13661403
## Annotation
13671404

13681405
### Create Annotation

fastlabel/__init__.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,6 +2825,80 @@ def copy_project(self, project_id: str) -> None:
28252825
endpoint = "projects/copy"
28262826
return self.api.post_request(endpoint, payload=payload)
28272827

2828+
def update_aws_s3_storage(
2829+
self,
2830+
project: str,
2831+
bucket_name: str,
2832+
bucket_region: str,
2833+
prefix: str = None
2834+
) -> str:
2835+
"""
2836+
Insert or update AWS S3 storage settings.
2837+
2838+
project is a slug of the project (Required).
2839+
bucket_name is a bucket name of the aws s3 (Required).
2840+
bucket_region is a bucket region of the aws s3 (Required).
2841+
prefix is a folder name in the aws s3 bucket. (Optional).
2842+
If sample_dir is specified as a prefix in the case of a hierarchical structure like the bucket below,
2843+
only the data under the sample_dir directory will be linked.
2844+
If not specified, everything under the bucket will be linked.
2845+
2846+
[tree structure]
2847+
fastlabel
2848+
├── sample1.jpg
2849+
└── sample_dir
2850+
└── sample2.jpg
2851+
2852+
"""
2853+
endpoint = "storages/aws-s3/" + project
2854+
payload = {
2855+
"bucketName": bucket_name,
2856+
"bucketRegion": bucket_region,
2857+
}
2858+
if prefix:
2859+
payload["prefix"] = prefix
2860+
return self.api.put_request(endpoint, payload=payload)
2861+
2862+
def create_task_from_aws_s3(
2863+
self,
2864+
project: str,
2865+
status: str = "registered",
2866+
tags: list[str] = [],
2867+
priority: int = 0,
2868+
) -> dict:
2869+
"""
2870+
Insert or update AWS S3 storage settings.
2871+
2872+
project is a slug of the project (Required).
2873+
status can be 'registered', 'completed', 'skipped',
2874+
'reviewed', 'sent_back', 'approved', 'declined' (default: registered) (Optional).
2875+
tags is a list of tag (default: []) (Optional).
2876+
priority is the priority of the task (default: none) (Optional).
2877+
Set one of the numbers corresponding to:
2878+
none = 0,
2879+
low = 10,
2880+
medium = 20,
2881+
high = 30,
2882+
"""
2883+
endpoint = "tasks/aws-s3"
2884+
payload = {
2885+
"project": project,
2886+
"status": status,
2887+
"tags": tags,
2888+
"priority": priority,
2889+
}
2890+
return self.api.post_request(endpoint, payload=payload)
2891+
2892+
def get_aws_s3_import_status_by_project(
2893+
self,
2894+
project: str,
2895+
) -> dict:
2896+
"""
2897+
Returns a import status of create task from AWS S3.
2898+
"""
2899+
endpoint = "tasks/import/status/aws-s3/" + project
2900+
return self.api.get_request(endpoint)
2901+
28282902
@staticmethod
28292903
def __fill_assign_users(payload: dict, **kwargs):
28302904
if "assignee" in kwargs:

0 commit comments

Comments
 (0)