|
59 | 59 | from .dataset_item_uploader import DatasetItemUploader |
60 | 60 | from .deprecation_warning import deprecated |
61 | 61 | from .errors import DatasetItemRetrievalError |
| 62 | +from .metadata_manager import ExportMetadataType, MetadataManager |
62 | 63 | from .payload_constructor import ( |
63 | 64 | construct_append_scenes_payload, |
64 | 65 | construct_model_run_creation_payload, |
@@ -1392,3 +1393,45 @@ def _upload_items( |
1392 | 1393 |
|
1393 | 1394 | populator = DatasetItemUploader(self.id, self._client) |
1394 | 1395 | return populator.upload(dataset_items, batch_size, update) |
| 1396 | + |
| 1397 | + def update_scene_metadata(self, mapping: Dict[str, dict]): |
| 1398 | + """ |
| 1399 | + Update (merge) scene metadata for each reference_id given in the mapping. |
| 1400 | + The backed will join the specified mapping metadata to the exisiting metadata. |
| 1401 | + If there is a key-collision, the value given in the mapping will take precedence. |
| 1402 | +
|
| 1403 | + Args: |
| 1404 | + mapping: key-value pair of <reference_id>: <metadata> |
| 1405 | +
|
| 1406 | + Examples: |
| 1407 | + >>> mapping = {"scene_ref_1": {"new_key": "foo"}, "scene_ref_2": {"some_value": 123}} |
| 1408 | + >>> dataset.update_scene_metadata(mapping) |
| 1409 | +
|
| 1410 | + Returns: |
| 1411 | + A dictionary outlining success or failures. |
| 1412 | + """ |
| 1413 | + mm = MetadataManager( |
| 1414 | + self.id, self._client, mapping, ExportMetadataType.SCENES |
| 1415 | + ) |
| 1416 | + return mm.update() |
| 1417 | + |
| 1418 | + def update_item_metadata(self, mapping: Dict[str, dict]): |
| 1419 | + """ |
| 1420 | + Update (merge) dataset item metadata for each reference_id given in the mapping. |
| 1421 | + The backed will join the specified mapping metadata to the exisiting metadata. |
| 1422 | + If there is a key-collision, the value given in the mapping will take precedence. |
| 1423 | +
|
| 1424 | + Args: |
| 1425 | + mapping: key-value pair of <reference_id>: <metadata> |
| 1426 | +
|
| 1427 | + Examples: |
| 1428 | + >>> mapping = {"item_ref_1": {"new_key": "foo"}, "item_ref_2": {"some_value": 123}} |
| 1429 | + >>> dataset.update_item_metadata(mapping) |
| 1430 | +
|
| 1431 | + Returns: |
| 1432 | + A dictionary outlining success or failures. |
| 1433 | + """ |
| 1434 | + mm = MetadataManager( |
| 1435 | + self.id, self._client, mapping, ExportMetadataType.DATASET_ITEMS |
| 1436 | + ) |
| 1437 | + return mm.update() |
0 commit comments