Пример #1
0
 def _get_serialized_data(self, annotation):
     if get_bool_env('FUTURE_SAVE_TASK_TO_STORAGE', default=False):
         # export task with annotations
         return ExportDataSerializer(annotation.task).data
     else:
         from io_storages.serializers import StorageAnnotationSerializer
         # deprecated functionality - save only annotation
         return StorageAnnotationSerializer(annotation).data
Пример #2
0
 def save_annotation(self, annotation):
     client = self.get_client()
     logger.debug(f'Creating new object on {self.__class__.__name__} Storage {self} for annotation {annotation}')
     ser_annotation = StorageAnnotationSerializer(annotation).data
     with transaction.atomic():
         # Create export storage link
         link = RedisExportStorageLink.create(annotation, self)
         client.set(link.key, json.dumps(ser_annotation))
Пример #3
0
 def save_annotation(self, annotation):
     client, s3 = self.get_client_and_resource()
     logger.debug(f'Creating new object on {self.__class__.__name__} Storage {self} for annotation {annotation}')
     ser_annotation = StorageAnnotationSerializer(annotation).data
     with transaction.atomic():
         # Create export storage link
         link = S3ExportStorageLink.create(annotation, self)
         key = str(self.prefix) + '/' + link.key if self.prefix else link.key
         try:
             s3.Object(self.bucket, key).put(Body=json.dumps(ser_annotation))
         except Exception as exc:
             logger.error(f"Can't export annotation {annotation} to S3 storage {self}. Reason: {exc}", exc_info=True)
Пример #4
0
 def save_annotation(self, annotation):
     bucket = self.get_bucket()
     logger.debug(f'Creating new object on {self.__class__.__name__} Storage {self} for annotation {annotation}')
     ser_annotation = StorageAnnotationSerializer(annotation).data
     with transaction.atomic():
         # Create export storage link
         link = GCSExportStorageLink.create(annotation, self)
         key = str(self.prefix) + '/' + link.key if self.prefix else link.key
         try:
             blob = bucket.blob(key)
             blob.upload_from_string(json.dumps(ser_annotation))
         except Exception as exc:
             logger.error(f"Can't export annotation {annotation} to GCS storage {self}. Reason: {exc}", exc_info=True)
Пример #5
0
 def save_annotation(self, annotation):
     logger.debug(
         f'Creating new object on {self.__class__.__name__} Storage {self} for annotation {annotation}'
     )
     ser_annotation = StorageAnnotationSerializer(annotation).data
     with transaction.atomic():
         # Create export storage link
         link = LocalFilesExportStorageLink.create(annotation, self)
         try:
             with open(link.key, mode='w') as f:
                 json.dump(ser_annotation, f, indent=2)
         except Exception as exc:
             logger.error(
                 f"Can't export annotation {annotation} to local storage {self}. Reason: {exc}",
                 exc_info=True)
Пример #6
0
 def save_annotation(self, annotation):
     container = self.get_container()
     logger.debug(
         f'Creating new object on {self.__class__.__name__} Storage {self} for annotation {annotation}'
     )
     ser_annotation = StorageAnnotationSerializer(annotation).data
     with transaction.atomic():
         # Create export storage link
         link = AzureBlobExportStorageLink.create(annotation, self)
         try:
             blob = container.get_blob_client(link.key)
             blob.upload_blob(json.dumps(ser_annotation), overwrite=True)
         except Exception as exc:
             logger.error(
                 f"Can't export annotation {annotation} to Azure storage {self}. Reason: {exc}",
                 exc_info=True)