Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/test_camera_view_gating.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,3 +505,30 @@ def fake_run(plan, out_dir, exporters, progress, n_workers, cancel_check):
assert len(records) == 1
assert "2 sessions" in records[0].getMessage()
assert engine._skip_tally is None


@pytest.mark.parametrize("failure", ["raises", "cancelled"])
def test_run_flushes_the_skip_tally_when_it_raises_or_is_cancelled(
monkeypatch, caplog, failure
) -> None:
from track2data.core.progress import OperationCancelled

_register_depth_scale_metric(monkeypatch)
engine = Engine(_manifest_3d_cal("scalar", ["IL-DS"]))
exc = OperationCancelled() if failure == "cancelled" else RuntimeError("boom")

def fake_run(plan, out_dir, exporters, progress, n_workers, cancel_check):
for i in range(2):
fused = _with_depth(_make_psess(_make_session(f"s{i}", n_frames=10, n_animals=2)))
fused.px_per_cm = None
engine.compute_metrics(fused)
raise exc

monkeypatch.setattr(engine, "_run", fake_run)
monkeypatch.setattr(engine, "_checked_plan", lambda: object())
with caplog.at_level(logging.WARNING, logger="track2data.api"), pytest.raises(type(exc)):
engine.run("out")
records = [r for r in caplog.records if "IL-DS" in r.getMessage()]
assert len(records) == 1
assert "2 sessions" in records[0].getMessage()
assert engine._skip_tally is None
7 changes: 6 additions & 1 deletion tests/test_readers/test_deeplabcut_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ def test_a_2d_table_with_z_and_likelihood_is_not_claimed_by_dlc3d(tmp_path: Path


def test_the_3d_readers_texts_all_say_deeplabcut_3d(tmp_path: Path) -> None:
assert "DeepLabCut 3-D" in DeepLabCut3DReader.display_name
plain = tmp_path / "notes.csv"
plain.write_text("a,b\n1,2\n")
with pytest.raises(Track2DataError) as err:
Expand All @@ -282,3 +281,9 @@ def test_the_3d_readers_texts_all_say_deeplabcut_3d(tmp_path: Path) -> None:
with pytest.raises(Track2DataError) as err:
read(empty)
assert "DeepLabCut 3-D" in err.value.remediation


def test_display_name_is_exported_provenance_and_must_not_change() -> None:
# display_name is exported as source_software (README, manifest.json, PROJECT_SUMMARY.md,
# run log); changing it would change the exports of existing native DLC-3D projects.
assert DeepLabCut3DReader.display_name == "DeepLabCut 3D (triangulated CSV)"
5 changes: 3 additions & 2 deletions track2data/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,8 +1390,9 @@ def _aggregated_skip_log(self) -> Iterator[None]:
the block ends (also on an error or a cancellation). ``run()`` opens it, so a run logs
"IL-16 skipped for 12 sessions: ..." once instead of once per session; a direct
``compute_metrics`` call outside a run still logs its own skip at once. A nested scope
joins the outer one. Worker processes of a parallel run each have their own engine and
scope, so they log per worker."""
joins the outer one. A parallel run (``n_workers > 1``) does not benefit: its workers
call ``_run_one_unit`` directly and never open the scope, so they log per session and the
parent logs nothing for these skips (as before the aggregation)."""
if self._skip_tally is not None:
yield
return
Expand Down
2 changes: 1 addition & 1 deletion track2data/readers/deeplabcut_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class DeepLabCut3DReader(SessionReader):
"""DeepLabCut-3D triangulated tables (CSV): one session per file."""

name = "deeplabcut_3d"
display_name: ClassVar[str] = "DeepLabCut 3-D (triangulated CSV)"
display_name: ClassVar[str] = "DeepLabCut 3D (triangulated CSV)"
verification = "synthetic_only"
coordinate_frame = "physical_unaligned"
provides_native_3d: ClassVar[bool] = True
Expand Down