Exemple #1
0
    def block_widths(self):
        """Gets the widths of the blocks.

        Note: This works with the property structure `_widths_cache` to avoid
            having to recompute these values each time they are needed.
        """
        if self._widths_cache is None:
            if not isinstance(self._partitions_cache[0][0].width(), int):
                try:
                    # The first column will have the correct lengths. We have an
                    # invariant that requires that all blocks be the same width in a
                    # column of blocks.
                    self._widths_cache = np.array(
                        ray.get([
                            obj.width().oid
                            for obj in self._partitions_cache[0]
                        ]) if len(self._partitions_cache) > 0 else [])
                except RayTaskError as e:
                    handle_ray_task_error(e)
                except AttributeError:
                    self._widths_cache = np.array([
                        obj.width() if isinstance(obj.width(), int) else
                        ray.get(obj.width().oid)
                        for obj in self._partitions_cache[0]
                    ])
            else:
                self._widths_cache = np.array([
                    obj.width() if isinstance(obj.width(), int) else ray.get(
                        obj.width().oid) for obj in self._partitions_cache[0]
                ])
        return self._widths_cache
Exemple #2
0
    def get(self):
        """Gets the object out of the plasma store.

        Returns:
            The object from the plasma store.
        """
        if len(self.call_queue):
            self.drain_call_queue()
        try:
            return ray.get(self.oid)
        except RayTaskError as e:
            handle_ray_task_error(e)
Exemple #3
0
 def ip(self):
     if self._ip_cache is None:
         if len(self.call_queue):
             self.drain_call_queue()
         else:
             self._ip_cache = self.apply(lambda df: df)._ip_cache
     if isinstance(self._ip_cache, ObjectIDType):
         try:
             self._ip_cache = ray.get(self._ip_cache)
         except RayTaskError as e:
             handle_ray_task_error(e)
     return self._ip_cache
Exemple #4
0
 def width(self):
     if self._width_cache is None:
         if len(self.call_queue):
             self.drain_call_queue()
         else:
             self._length_cache, self._width_cache = get_index_and_columns.remote(
                 self.oid)
     if isinstance(self._width_cache, ray.ObjectID):
         try:
             self._width_cache = ray.get(self._width_cache)
         except RayTaskError as e:
             handle_ray_task_error(e)
     return self._width_cache
Exemple #5
0
    def block_lengths(self):
        """Gets the lengths of the blocks.

        Note: This works with the property structure `_lengths_cache` to avoid
            having to recompute these values each time they are needed.
        """
        if self._lengths_cache is None:
            try:
                # The first column will have the correct lengths. We have an
                # invariant that requires that all blocks be the same length in a
                # row of blocks.
                self._lengths_cache = np.array(
                    ray.get([obj.length().oid for obj in self._partitions_cache.T[0]])
                    if len(self._partitions_cache.T) > 0
                    else []
                )
            except RayTaskError as e:
                handle_ray_task_error(e)
        return self._lengths_cache
Exemple #6
0
 def wait(self):
     self.drain_call_queue()
     try:
         ray.wait([self.oid])
     except RayTaskError as e:
         handle_ray_task_error(e)