calamari.catalog.build_catalog#

calamari.catalog.build_catalog(root, *, group_fn=None, dedup_between=None, path_filter=None)#

Build a Catalog – the inventory of every recognised measurement file under root, plus the root it resolves against.

Parameters:
  • root (Path | str) – Root directory to scan.

  • group_fn (Callable[[Path], str] | None) – Maps a file’s path (relative to root) to a group label string – see summarise(). Unlike a direct summarise() call, build_catalog always applies some group_fn: if none is given, _default_group_fn() (the first relative path component) is used, so the returned DataFrame always has a 'group' column to sort and (optionally) deduplicate by.

  • dedup_between (tuple[str, str] | None) – (redundant_group, canonical_group) group labels (as produced by group_fn) to cross-check same-named summary files for byte equality (including headers and formatting) – see _detect_duplicates(). Default None: no duplicate detection is attempted, and every row gets is_duplicate=False, dup_status='' (the columns are still present, for a consistent schema regardless of whether dedup was requested).

  • path_filter (Callable[[Path], bool] | None) – Predicate over root-relative file paths, passed to find_files() before content probing. Excluded files are never opened by calamari, including during duplicate detection. Included files still undergo normal content recognition and metadata classification. For an explicit selection, use e.g. lambda path: path in selected with a set of root-relative Paths. Default None: include every candidate. Predicate exceptions propagate; they are not file parse errors.

Return type:

Catalog

Returns:

calamari.catalog.Catalog – One row per recognised file (see summarise() for columns, plus is_duplicate, canonical_path, and dup_status – see _detect_duplicates()), sorted by group then filename then relative_path, wrapped with root as a Catalog (the plain frame is its .df). Files that fail to parse are skipped and reported on .parse_errors (a list of (path, error_message) tuples); filenames genuinely colliding between the two dedup_between groups (same name, different content) are listed on .name_collision_differs; the total number of included, recognised files (before parse failures) is .n_scanned. The same three values are mirrored on .df.attrs under those names.

Raises:

OSError – If root is missing (FileNotFoundError), is not a directory (NotADirectoryError), or cannot be listed (PermissionError) – propagated from find_files(), so a mistyped root is never reported as an empty catalog.