def __init__(self, connection, uuid, data_name, query_args=None, throttle=None, retry_timeout=60.0, retry_interval=1.0, warning_interval=30.0, _metadata=None, _access_type="raw"): """ :param uuid: The node uuid :param data_name: The name of the volume :param connection: An ``httplib.HTTPConnection`` instance or something like it. :param throttle: Enable the DVID 'throttle' flag for all get/post requests :param retry_timeout: Total time to spend repeating failed requests before giving up. (Set to 0 to prevent retries.) :param retry_interval: Time to wait before repeating a failed get/post. :param warning_interval: If the retry period exceeds this interval (but hasn't hit the retry_timeout yet), a warning is emitted. :param _metadata: If provided, used as the metadata for the accessor. Otherwise, the server is queried to obtain this volume's metadata. .. note:: When DVID is overloaded, it may indicate its busy status by returning a ``503`` (service unavailable) error in response to a get/post request. In that case, the get/post methods below will automatically repeat the failed request until the `retry_timeout` is reached. """ self.uuid = uuid self.data_name = data_name self._connection = connection self._retry_timeout = retry_timeout self._retry_interval = retry_interval self._warning_interval = warning_interval self._query_args = query_args or {} self._access_type = _access_type # Special case: throttle can be set explicity via the keyword or implicitly via the query_args. # Make sure they are consistent. if 'throttle' in self._query_args: if self._query_args['throttle'] == 'on': assert throttle is None or throttle is True self._throttle = True if self._query_args['throttle'] == 'off': assert throttle is None or throttle is False self._throttle = False elif throttle is None: self._throttle = False else: self._throttle = throttle # Request this volume's metadata from DVID self.voxels_metadata = _metadata if self.voxels_metadata is None: self.voxels_metadata = voxels.get_metadata(self._connection, uuid, data_name)
def post_ndarray( self, start, stop, new_data ): """ Overwrite subvolume specified by the given start and stop pixel coordinates with new_data. """ voxels.post_ndarray( self._connection, self.uuid, self.data_name, self.voxels_metadata, start, stop, new_data ) if ( numpy.array(stop) > self.shape ).any() or \ ( numpy.array(start) < self.minindex ).any(): # It looks like this post will UPDATE the volume's extents. # Therefore, RE-request this volume's metadata from DVID so we get the new volume shape self.voxels_metadata = voxels.get_metadata( self._connection, self.uuid, self.data_name )
def __init__(self, connection, uuid, data_name): """ :param uuid: The node uuid :param data_name: The name of the volume """ self.uuid = uuid self.data_name = data_name self._connection = connection # Request this volume's metadata from DVID self.voxels_metadata = voxels.get_metadata( self._connection, uuid, data_name )
def __init__(self, connection, uuid, data_name, query_args=None, throttle=None, retry_timeout=60.0, retry_interval=1.0, warning_interval=30.0, _metadata=None, _access_type="raw"): """ :param uuid: The node uuid :param data_name: The name of the volume :param connection: An ``httplib.HTTPConnection`` instance or something like it. :param throttle: Enable the DVID 'throttle' flag for all get/post requests :param retry_timeout: Total time to spend repeating failed requests before giving up. (Set to 0 to prevent retries.) :param retry_interval: Time to wait before repeating a failed get/post. :param warning_interval: If the retry period exceeds this interval (but hasn't hit the retry_timeout yet), a warning is emitted. :param _metadata: If provided, used as the metadata for the accessor. Otherwise, the server is queried to obtain this volume's metadata. .. note:: When DVID is overloaded, it may indicate its busy status by returning a ``503`` (service unavailable) error in response to a get/post request. In that case, the get/post methods below will automatically repeat the failed request until the `retry_timeout` is reached. """ self.uuid = uuid self.data_name = data_name self._connection = connection self._retry_timeout = retry_timeout self._retry_interval = retry_interval self._warning_interval = warning_interval self._query_args = query_args or {} self._access_type = _access_type # Special case: throttle can be set explicity via the keyword or implicitly via the query_args. # Make sure they are consistent. if 'throttle' in self._query_args: if self._query_args['throttle'] == 'on': assert throttle is None or throttle is True self._throttle = True if self._query_args['throttle'] == 'off': assert throttle is None or throttle is False self._throttle = False elif throttle is None: self._throttle = False else: self._throttle = throttle # Request this volume's metadata from DVID self.voxels_metadata = _metadata if self.voxels_metadata is None: self.voxels_metadata = voxels.get_metadata( self._connection, uuid, data_name )
def post_ndarray(self, start, stop, new_data): """ Overwrite subvolume specified by the given start and stop pixel coordinates with new_data. """ # Post the data (with auto-retry) self._post_ndarray(start, stop, new_data) if ( numpy.array(stop) > self.shape ).any() or \ ( numpy.array(start) < self.minindex ).any(): # It looks like this post UPDATED the volume's extents. # Therefore, RE-request this volume's metadata from DVID so we get the new volume shape self.voxels_metadata = voxels.get_metadata(self._connection, self.uuid, self.data_name)