annie.pages.csv_dialog

Table configuration dialogs: CSV files and Excel workbooks (UI).

Opened after the user has picked a file:

  • configure_table() (Dataset tab) — describe how a CSV or workbook joins to the dataset. A CSV picks a role (label tags, protagonist track, segmentation); a workbook lists every sheet, and each included sheet becomes its own label source. For label tables a _JoinEditor chooses the ID column and what it matches (the whole video id or a nested-layout path field such as {subject}), optionally by substring, resolves repeated IDs with an explicit order column, and names each feature column’s tag. A live summary shows how many videos would get a row.

  • select_id_column() (Browse tab) — pick the column holding the video ids to restrict the Browse list to.

All return None if cancelled.

Attributes

VIDEO_ID_TARGET

Match target meaning "the whole video id" (path fields are identifiers, never this).

Targets

Functions

tag_clashes(→ list[str])

Return tag names that would collide, in the order they appear.

configure_table(...)

Configure a CSV or an Excel workbook as one or more sources.

reading(→ T | None)

Run read off the event loop while a small dialog says path is being read.

configure_csv(→ annie.dataset.sources.DataSource | None)

Open the CSV configuration modal and return the resulting source.

select_id_column(→ tuple[str, list[str]] | None)

Open the id-column modal for a CSV that supplies a Browse id filter.

Module Contents

annie.pages.csv_dialog.VIDEO_ID_TARGET = 'video id'

Match target meaning “the whole video id” (path fields are identifiers, never this).

annie.pages.csv_dialog.Targets
annie.pages.csv_dialog.tag_clashes(sources: list[annie.dataset.sources.DataSource], taken: set[str]) → list[str][source]

Return tag names that would collide, in the order they appear.

A tag must be unique across the new sources and everything already shown in Browse (other tables’ tags and nested-layout path fields), or one would silently overwrite the other.

Parameters:
  • sources – The label sources about to be added.

  • taken – Tag names already in use.

Returns:

Each clashing name once; empty when all are unique.

async annie.pages.csv_dialog.configure_table(path: str | pathlib.Path, targets: Targets, taken: set[str]) → list[annie.dataset.sources.DataSource] | None[source]

Configure a CSV or an Excel workbook as one or more sources.

Parameters:
  • path – The chosen file.

  • targets – What IDs can match: VIDEO_ID_TARGET plus each path field, each mapping video id to the value an ID must equal (or contain).

  • taken – Tag names already in use (see tag_clashes()).

Returns:

The sources to add (one per included sheet for a workbook), or None if cancelled.

async annie.pages.csv_dialog.reading[T](path: pathlib.Path, read: collections.abc.Callable[[], T]) → T | None[source]

Run read off the event loop while a small dialog says path is being read.

Large tables and many-sheet workbooks take seconds to parse; the spinner shows the click was taken, and the UI stays responsive meanwhile.

Returns:

Whatever read returned; None if the app is shutting down.

async annie.pages.csv_dialog.configure_csv(path: str | pathlib.Path, targets: Targets, taken: set[str]) → annie.dataset.sources.DataSource | None[source]

Open the CSV configuration modal and return the resulting source.

Parameters:
  • path – The chosen CSV file.

  • targets – Match targets for label tables (see configure_table()).

  • taken – Tag names already in use.

Returns:

A configured DataSource, or None if cancelled.

async annie.pages.csv_dialog.select_id_column(path: str | pathlib.Path, video_stems: collections.abc.Iterable[str]) → tuple[str, list[str]] | None[source]

Open the id-column modal for a CSV that supplies a Browse id filter.

The user picks which column holds the video ids; the column is auto-suggested by matching its values against the known video stems, and the dialog reports how many of the ids actually exist in the dataset before the filter is applied.

Parameters:
  • path – The chosen CSV file.

  • video_stems – Known video stems, used to auto-suggest the id column and to report the overlap.

Returns:

The (column, ids) pair — the ids distinct and in file order — or None if cancelled or if the CSV has no header.