class documentation
class Mapper(abc.ABC): (source)
Known subclasses: fiftyone.core.map.mapper.LocalMapper
Constructor: Mapper(batch_cls, num_workers, batch_size)
Base class for mapping samples in parallel
Class Method | create |
Create a new mapper instance |
Method | __init__ |
Undocumented |
Method | map |
Applies map function to each sample and returns an iterator of the results. |
Property | batch |
Number of samples per worker batch |
Property | num |
Number of workers to use |
Static Method | _handle |
Common error handling when a map error occurs |
Method | _map |
of the results. |
Instance Variable | _batch |
Undocumented |
Instance Variable | _batch |
Undocumented |
Instance Variable | _num |
Undocumented |
@classmethod
@abc.abstractmethod
def create(cls, *, config:
@abc.abstractmethod
def create(cls, *, config:
focc.FiftyOneConfig
, batch_cls: type[ fomb.SampleBatch]
, num_workers: int | None
= None, **__):
(source)
¶
Create a new mapper instance
def __init__(self, batch_cls:
type[ fomb.SampleBatch]
, num_workers: int
, batch_size: int | None
= None):
(source)
¶
Undocumented
def map_samples(self, sample_collection:
SampleCollection[ T]
, map_fcn: Callable[ [ T], R]
, *, progress: bool | Literal[ 'workers'] | None
= None, save: bool
= False, skip_failures: bool
= True) -> Iterator[ tuple[ bson.ObjectId, R]]
:
(source)
¶
Applies map function to each sample and returns an iterator of the results.
Parameters | |
sampleSampleCollection[T] | The sample collection to map. |
mapCallable[[T] , R] | The map function to apply to each sample. |
progress:Union[bool , Literal[ "workers"]] | Whether or not and how to render progress. |
save:bool , optional | Whether to save mutated samples mutated in the map function. Defaults to False. |
skipbool , optional | Whether to gracefully continue without raising an error if the map function raises an exception for a sample. Defaults to True. |
Returns | |
Iterator[ | Undocumented |
Yields | |
Iterator[Tuple[bson.ObjectId , R]] |
|
@staticmethod
def _handle_map_error(sample_id:
def _handle_map_error(sample_id:
bson.ObjectId
, err: Exception
, skip_failures: bool
):
(source)
¶
Common error handling when a map error occurs
@abc.abstractmethod
def _map_samples(self, sample_collection:
def _map_samples(self, sample_collection:
SampleCollection[ T]
, map_fcn: Callable[ [ T], R]
, *, progress: bool | Literal[ 'workers'] | None
, save: bool
, skip_failures: bool
) -> Iterator[ tuple[ bson.ObjectId, Exception | None, R | None]]
:
(source)
¶
overridden in
fiftyone.core.map.mapper.LocalMapper
- Applies map function to each sample batch and returns an iterator
- of the results.
Parameters | |
sampleSampleCollection[T] | The sample collection to map. |
mapCallable[[T] , R] | The map function to apply to each sample. |
progress:Union[bool , Literal[ "workers"]] | Whether or not and how to render progress. |
save:bool , optional | Whether to save mutated samples mutated in the map function. Defaults to False. |
skipbool , optional | Whether to gracefully continue without raising an error if the map function raises an exception for a sample. Defaults to True. |
Returns | |
Iterator[ | Undocumented |
Yields | |
MapSampleBatchesReturnType |
|