1414 POINTCLOUD_LOCATION_KEY ,
1515 REFERENCE_ID_KEY ,
1616 TRACKS_KEY ,
17+ UPLOAD_TO_SCALE_KEY ,
1718 VIDEO_LOCATION_KEY ,
1819 VIDEO_URL_KEY ,
1920)
@@ -507,6 +508,7 @@ class VideoScene(ABC):
507508 metadata : Optional [dict ] = field (default_factory = dict )
508509 attachment_type : Optional [str ] = None
509510 tracks : List [Track ] = field (default_factory = list )
511+ use_privacy_mode : bool = False
510512
511513 def __post_init__ (self ):
512514 if self .attachment_type :
@@ -534,7 +536,6 @@ def length(self) -> int:
534536 return len (self .items )
535537
536538 def validate (self ):
537- # TODO: make private
538539 assert (
539540 self .items or self .video_location
540541 ), "Please upload either a video_location or an array of dataset items representing frames"
@@ -545,9 +546,10 @@ def validate(self):
545546 assert (
546547 self .length > 0
547548 ), "When uploading an array of items scene must have a list of items of length at least 1"
548- assert (
549- not self .video_location
550- ), "No video location is accepted when uploading an array of items unless you are using privacy mode"
549+ if not self .use_privacy_mode :
550+ assert (
551+ not self .video_location
552+ ), "No video location is accepted when uploading an array of items unless you are using privacy mode"
551553 for item in self .items :
552554 assert isinstance (
553555 item , DatasetItem
@@ -577,9 +579,10 @@ def add_item(
577579 update: Whether to overwrite the item at the specified index, if it
578580 exists. Default is False.
579581 """
580- assert (
581- not self .video_location
582- ), "Cannot add item to a video without items"
582+ if not self .use_privacy_mode :
583+ assert (
584+ not self .video_location
585+ ), "Cannot add item to a video without items"
583586 if index is None :
584587 index = len (self .items )
585588 assert (
@@ -598,9 +601,10 @@ def get_item(self, index: int) -> DatasetItem:
598601
599602 Return:
600603 :class:`DatasetItem`: DatasetItem at the specified index."""
601- assert (
602- not self .video_location
603- ), "Cannot add item to a video without items"
604+ if not self .use_privacy_mode :
605+ assert (
606+ not self .video_location
607+ ), "Cannot add item to a video without items"
604608 if index < 0 or index > len (self .items ):
605609 raise ValueError (
606610 f"This scene does not have an item at index { index } "
@@ -613,9 +617,10 @@ def get_items(self) -> List[DatasetItem]:
613617 Returns:
614618 List[:class:`DatasetItem`]: List of DatasetItems, sorted by index ascending.
615619 """
616- assert (
617- not self .video_location
618- ), "Cannot add item to a video without items"
620+ if not self .use_privacy_mode :
621+ assert (
622+ not self .video_location
623+ ), "Cannot add item to a video without items"
619624 return self .items
620625
621626 def info (self ):
@@ -679,6 +684,9 @@ def to_payload(self) -> dict:
679684 payload [METADATA_KEY ] = self .metadata
680685 if self .video_location :
681686 payload [VIDEO_URL_KEY ] = self .video_location
687+ # needed in order for the backed validation to work
688+ if self .use_privacy_mode is not None :
689+ payload [UPLOAD_TO_SCALE_KEY ] = not self .use_privacy_mode
682690 if self .items :
683691 items_payload = [
684692 item .to_payload (is_scene = True ) for item in self .items
0 commit comments