class documentation

A class that generates unique output paths in a directory. This is multiprocess safe and uses a shared temporary directory structure organized by parent process ID and configuration hash. The approach is robust and handles edge cases like idempotency and file extensions.

This class provides a get_output_path method that generates unique filenames in the specified output directory.

If an input path is provided, its filename is maintained, unless a name conflict in output_dir would occur, in which case an index of the form "-%d" % count is appended to the filename.

If no input filename is provided, an output filename of the form <output_dir>/<count><default_ext> is generated, where count is the number of files in output_dir.

If no output_dir is provided, then unique filenames with no base directory are generated.

If a rel_dir is provided, then this path will be stripped from each input path to generate the identifier of each file (rather than just its basename). This argument allows for populating nested subdirectories in output_dir that match the shape of the input paths.

If alt_dir is provided, you can use get_alt_path to retrieve the equivalent path rooted in this directory rather than output_dir.

Parameters
output_dira directory in which to generate output paths
rel_diran optional relative directory to strip from each path. The path is converted to an absolute path (if necessary) via fiftyone.core.storage.normalize_path
alt_diran optional alternate directory in which to generate paths when get_alt_path is called
default_extthe file extension to use when generating default output paths
ignore_extswhether to omit file extensions when checking for duplicate filenames
ignore_existingwhether to ignore existing files in output_dir for output filename generation purposes
idempotentwhether to return the same output path when the same input path is provided multiple times (True) or to generate new output paths (False)
Method __init__ Undocumented
Method get_alt_path Returns the alternate path for the given output path generated by get_output_path.
Method get_output_path Returns a unique output path.
Method seen_input_path Checks whether we've already seen the given input path.
Instance Variable alt_dir Undocumented
Instance Variable default_ext Undocumented
Instance Variable idempotent Undocumented
Instance Variable ignore_existing Undocumented
Instance Variable ignore_exts Undocumented
Instance Variable output_dir Undocumented
Instance Variable rel_dir Undocumented
Instance Variable starting_filepath_counts Undocumented
Instance Variable starting_filepaths Undocumented
Instance Variable tmp_dir Undocumented
def __init__(self, ppid, output_dir=None, rel_dir=None, alt_dir=None, default_ext=None, ignore_exts=False, ignore_existing=False, idempotent=True): (source)

Undocumented

def get_alt_path(self, output_path, alt_dir=None): (source)

Returns the alternate path for the given output path generated by get_output_path.

Parameters
output_pathan output path
alt_dir:Nonea directory in which to return the alternate path. If not provided, alt_dir is used
Returns
the corresponding alternate path
def get_output_path(self, input_path=None, output_ext=None): (source)

Returns a unique output path.

Parameters
input_path:Nonean input path
output_ext:Nonean optional output extension to use
Returns
the output path
def seen_input_path(self, input_path): (source)

Checks whether we've already seen the given input path.

Parameters
input_pathan input path
Returns
True/False

Undocumented

default_ext: None = (source)

Undocumented

idempotent: True = (source)

Undocumented

ignore_existing: False = (source)

Undocumented

ignore_exts: False = (source)

Undocumented

output_dir: None = (source)

Undocumented

Undocumented

starting_filepath_counts = (source)

Undocumented

starting_filepaths = (source)

Undocumented

Undocumented