class documentation

Base class for DatasetExporter utilities that provide support for populating a directory or manifest of media files.

This class is designed for populating a single, flat directory or manifest of media files, and automatically takes care of things like name clashes as necessary.

The export strategy used is defined by the export_mode parameter, and users of this class can restrict the available options via the supported_modes parameter.

Parameters
export_mode

the export mode to use. The supported values are:

  • True: copy all media files into the output directory
  • False: don't export media. This option is only useful when exporting labeled datasets whose label format stores sufficient information to locate the associated media
  • "move": move all media files into the output directory
  • "symlink": create symlinks to the media files in the output directory
  • "manifest": create a data.json in the output directory that maps UUIDs used in the labels files to the filepaths of the source media, rather than exporting the actual media
export_path

the location to export the media. Can be any of the following:

  • When export_media is True, "move", or "symlink", a directory in which to export the media
  • When export_mode is "manifest", the path to write a JSON file mapping UUIDs to input filepaths
  • When export_media is False, this parameter has no effect
rel_diran optional relative directory to strip from each input filepath to generate a unique identifier for each media. When exporting media, this identifier is joined with export_path to generate an output path for each exported media. This argument allows for populating nested subdirectories that match the shape of the input paths. The path is converted to an absolute path (if necessary) via fiftyone.core.storage.normalize_path
chunk_sizean optional chunk size to use when exporting media files. If provided, media files will be nested in subdirectories of the output directory with at most this many media files per subdirectory. Has no effect if a rel_dir is provided
supported_modesan optional tuple specifying a subset of the export_mode values that are allowed
default_extthe file extension to use when generating default output paths
ignore_extswhether to omit file extensions when generating UUIDs for files
Method __enter__ Undocumented
Method __exit__ Undocumented
Method __init__ Undocumented
Method close Performs any necessary actions to complete the export.
Method export Exports the given media.
Method setup Performs necessary setup to begin exporting media.
Instance Variable chunk_size Undocumented
Instance Variable default_ext Undocumented
Instance Variable export_mode Undocumented
Instance Variable export_path Undocumented
Instance Variable ignore_exts Undocumented
Instance Variable rel_dir Undocumented
Instance Variable supported_modes Undocumented
Method _get_uuid Undocumented
Method _handle_fo3d_file Undocumented
Method _write_media Undocumented
Instance Variable _filename_maker Undocumented
Instance Variable _manifest Undocumented
Instance Variable _manifest_path Undocumented
def __enter__(self): (source)

Undocumented

def __exit__(self, *args): (source)

Undocumented

def __init__(self, export_mode, export_path=None, rel_dir=None, chunk_size=None, supported_modes=None, default_ext=None, ignore_exts=False): (source)
def close(self): (source)

Performs any necessary actions to complete the export.

def export(self, media_or_path, outpath=None): (source)

Exports the given media.

Parameters
media_or_paththe media or path to the media on disk
outpath:Nonea manually-specified location to which to export the media. By default, the media will be exported into export_path
Returns
a tuple of
  • the path to the exported media
  • the UUID of the exported media
def setup(self): (source)

Performs necessary setup to begin exporting media.

DatasetExporter classes using this class should invoke this method in DatasetExporter.setup.

chunk_size: None = (source)

Undocumented

default_ext: None = (source)

Undocumented

export_mode = (source)

Undocumented

export_path: None = (source)

Undocumented

ignore_exts: False = (source)

Undocumented

Undocumented

supported_modes: None = (source)

Undocumented

def _get_uuid(self, path): (source)

Undocumented

def _handle_fo3d_file(self, fo3d_path, fo3d_output_path): (source)

Undocumented

_filename_maker = (source)

Undocumented

_manifest = (source)

Undocumented

_manifest_path = (source)

Undocumented