peal.web.ingest.discover_classes

peal.web.ingest.discover_classes(root, max_depth=3)[source]

Find the folder level that holds one sub-folder per class.

A zip that wraps everything in a single top-level folder is descended, up to max_depth levels.

Parameters:
  • root (str) – Directory the upload was extracted to.

  • max_depth (int) – How many single-folder wrappers may be descended.

Returns:

  • class_root (str) – The directory whose sub-folders are the classes.

  • classes (dict) – {class_name: [image paths relative to that class folder]} with at least two entries.

Raises:

IngestError – If no level with at least two image-bearing class folders is found.