Skip to content

feat(cli): reach DLC-project import and COCO seg/identity options from convert#496

Open
talmo wants to merge 1 commit into
mainfrom
feat/cli-convert-new-readers
Open

feat(cli): reach DLC-project import and COCO seg/identity options from convert#496
talmo wants to merge 1 commit into
mainfrom
feat/cli-convert-new-readers

Conversation

@talmo

@talmo talmo commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes two related medium CLI-gap findings by extending sio convert (and CLI format inference) to reach two 0.8.0 readers that were previously Python-only.

Finding A: DLC project import unreachable from the CLI

_infer_input_format returned None for a DeepLabCut project directory and config.yaml, so sio convert <dir> failed with "Cannot infer input format", and --from dlc on a config.yaml misrouted to the single-CSV DLC reader.

Fix:

  • _infer_input_format now detects a DLC project — a directory containing both config.yaml and labeled-data/, or a standalone config.yaml that validates as a DLC project config (via the existing dlc._is_dlc_project_path) — and returns a new dlc_project format.
  • dlc_project added to INPUT_FORMATS so --from dlc_project is accepted.
  • A plain DLC CSV is still detected as dlc; an unrelated config.yaml is not misclassified.

sio convert <dlcproject> works end to end via load_file (convert does not pass open_videos for non-slp inputs).

Finding B: COCO category_as_track / segmentation_format not reachable from convert

The #479 identity-track feature and ROI mode were Python-only because convert built load_kwargs with only format (+open_videos for slp).

Fix: convert gains --coco-category-as-track (flag) and --coco-segmentation [mask|roi], forwarded into the COCO loader when the input format is coco. Defaults match the Python API (category_as_track=False, segmentation_format="mask").

Testing

tests/io/test_cli.py:

  • DLC project detection: directory, standalone config.yaml, and a non-DLC config.yaml (returns None).
  • sio convert <dlcproject> auto-detected, and explicit --from dlc_project on a config.yaml; both write frames.
  • COCO convert with --coco-category-as-track --coco-segmentation roi (identity tracks + vector ROIs) vs defaults (rasterized masks, no tracks).

Each new-feature test fails on main and passes with the fix (verified by stashing cli.py). Lint clean (ruff format + ruff check); docs rebuilt with mkdocs build.

Notes

  • sio show <dlcproject> additionally requires the separate open PR fix(dlc): accept benign loader kwargs in DLC project/splits loaders #488 (fix/dlc-loader-kwargs, adds **kwargs to dlc.load_dlc_project so show's open_videos/lazy kwargs are tolerated). That fix is not on main, so this PR intentionally does not test sio show <dlcproject>.
  • cli.py is also edited by sibling CLI PRs; edits here are localized to _infer_input_format, INPUT_FORMATS, and the convert command to minimize merge conflicts.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YHwWuvFdH5W539AgSjuTxV

…m convert

Extend `sio convert` (and CLI format inference) to reach two 0.8.0 readers
that were previously Python-only.

DLC project import: `_infer_input_format` now detects a DeepLabCut project
(a directory containing config.yaml + labeled-data/, or a standalone project
config.yaml validated by content) and returns a new `dlc_project` format.
`dlc_project` is added to INPUT_FORMATS so `--from dlc_project` is accepted.
A plain DLC CSV is still detected as `dlc`, and an unrelated config.yaml is
not misclassified.

COCO options: `convert` gains `--coco-category-as-track` and
`--coco-segmentation [mask|roi]`, forwarded into the COCO loader when the
input format is coco. Defaults match the Python API (category_as_track=False,
segmentation_format="mask").

Docs (cli.md) document the new options, the dlc_project format, and the
detection rules. Tests cover detection (directory + config.yaml + non-DLC
config), DLC-project convert (auto + explicit --from), and COCO convert with
options vs defaults.

Note: `sio show <dlcproject>` additionally requires #488 (adds **kwargs to
dlc.load_dlc_project) and is intentionally not exercised here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YHwWuvFdH5W539AgSjuTxV
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.97%. Comparing base (fbf20c0) to head (01b09c1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #496   +/-   ##
=======================================
  Coverage   92.97%   92.97%           
=======================================
  Files          54       54           
  Lines       19444    19457   +13     
  Branches     4395     4399    +4     
=======================================
+ Hits        18078    18091   +13     
  Misses        651      651           
  Partials      715      715           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

github-actions Bot pushed a commit that referenced this pull request Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Docs Preview

Preview URL https://io.sleap.ai/pr/496/
Commit 01b09c1c22b064c7385c0394f5e785089b209ac1

Changed pages:

API changes detected - View API Reference

This preview will be removed when the PR is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant