Skip to content

Commit 6db8cf0

Browse files
Merge pull request #200 from fastlabel/feature/object-metadata-io
feat: create and download custom metadata
2 parents 6b31063 + f427db2 commit 6db8cf0

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2514,7 +2514,11 @@ dataset_object = client.create_dataset_object(
25142514
"value": "dog",
25152515
"type": "bbox" # type can be 'bbox', 'segmentation'.
25162516
}
2517-
]
2517+
],
2518+
custom_metadata={
2519+
"key": "value",
2520+
"metadata": "metadata-value"
2521+
}
25182522
)
25192523
```
25202524

@@ -2568,6 +2572,10 @@ See API docs for details.
25682572
"confidenceScore": -1
25692573
}
25702574
],
2575+
"customMetadata": {
2576+
"key": "value",
2577+
"metadata": "metadata-value"
2578+
},
25712579
'createdAt': '2022-10-30T08:32:20.748Z',
25722580
'updatedAt': '2022-10-30T08:32:20.748Z'
25732581
}

fastlabel/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4050,7 +4050,11 @@ async def __download(base_path: Path, _obj: dict):
40504050
exist_dataset_objects = json.load(open(output_path))
40514051
with Path(base_path / "annotations.json").open("w") as f:
40524052
annotations = [
4053-
{"name": obj["name"], "annotations": obj["annotations"]}
4053+
{
4054+
"name": obj["name"],
4055+
"annotations": obj["annotations"],
4056+
"customMetadata": obj["customMetadata"],
4057+
}
40544058
for obj in objects
40554059
]
40564060
json.dump(
@@ -4076,6 +4080,7 @@ def create_dataset_object(
40764080
file_path: str,
40774081
tags: List[str] = None,
40784082
annotations: List[dict] = None,
4083+
custom_metadata: Optional[dict[str, str]] = None,
40794084
) -> dict:
40804085
"""
40814086
Create a dataset object.
@@ -4102,6 +4107,8 @@ def create_dataset_object(
41024107
payload["tags"] = tags
41034108
if annotations:
41044109
payload["annotations"] = annotations
4110+
if custom_metadata:
4111+
payload["customMetadata"] = custom_metadata
41054112
return self.api.post_request(endpoint, payload=payload)
41064113

41074114
def delete_dataset_object(self, dataset_id: str, object_name: str) -> None:
@@ -4418,6 +4425,7 @@ def get_histories(
44184425

44194426
return self.api.get_request(endpoint, params=params)
44204427

4428+
44214429
def delete_extra_annotations_parameter(annotations: list) -> list:
44224430
for annotation in annotations:
44234431
annotation.pop("id", None)
@@ -4437,4 +4445,4 @@ def delete_extra_attributes_parameter(attributes: list) -> list:
44374445
attribute.pop("title", None)
44384446
attribute.pop("name", None)
44394447
attribute.pop("type", None)
4440-
return attributes
4448+
return attributes

0 commit comments

Comments
 (0)