Skip to content

Conversation

@gitttt-1234
Copy link
Collaborator

Summary

This PR adds a Config Generator tool that helps users create sleap-nn training configurations from SLP files with smart defaults based on data analysis.

Features

  • Python API with fluent builder pattern (ConfigGenerator class)
  • Auto-configuration based on dataset analysis (pipeline, backbone, sigma, batch size, etc.)
  • Smart recommendations with reasoning for each parameter choice
  • Memory estimation for GPU and CPU with color-coded warnings
  • Interactive TUI with 4 tabs (Data → Model → Training → Export)
  • CLI command: sleap-nn config <slp_file>

Usage Examples

Quick auto-config (Python):

from sleap_nn.config_generator import generate_config
generate_config("labels.slp", "config.yaml")

Fluent API (Python):

from sleap_nn.config_generator import ConfigGenerator

config = (
    ConfigGenerator.from_slp("labels.slp")
    .auto(view="top")
    .batch_size(8)
    .save("config.yaml")
)

CLI:

# Auto-generate config
sleap-nn config labels.slp -o config.yaml

# With view type hint
sleap-nn config labels.slp -o config.yaml --view top

# Interactive TUI
sleap-nn config labels.slp --interactive

# Analyze only
sleap-nn config labels.slp --analyze-only

New Files

  • sleap_nn/config_generator/ - New module with:
    • analyzer.py - Dataset analysis (DatasetStats, analyze_slp())
    • recommender.py - Pipeline and parameter recommendations
    • memory.py - Memory estimation utilities
    • generator.py - Main ConfigGenerator class
    • tui/app.py - Interactive TUI application (Textual-based)
  • tests/test_config_generator.py - 25 test cases

Dependencies

  • Added textual>=0.40.0 (TUI framework, builds on existing rich dependency)

Test plan

  • All 25 new tests pass
  • Manual testing with real SLP files
  • Test TUI on different terminals
  • Verify generated configs work with sleap-nn train

🤖 Generated with Claude Code

Implements a config generator tool that helps users create sleap-nn
training configurations from SLP files. Features include:

- Python API with fluent builder pattern (ConfigGenerator class)
- Auto-configuration based on dataset analysis
- Smart pipeline/backbone/parameter recommendations
- Memory estimation for GPU and CPU
- Interactive TUI with 4 tabs (Data, Model, Training, Export)
- CLI command: sleap-nn config <slp_file>

Usage examples:
  # Quick auto-config
  from sleap_nn.config_generator import generate_config
  generate_config("labels.slp", "config.yaml")

  # Fluent API
  ConfigGenerator.from_slp("labels.slp").auto(view="top").batch_size(8).save("config.yaml")

  # CLI
  sleap-nn config labels.slp -o config.yaml
  sleap-nn config labels.slp --interactive

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 44.80447% with 494 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.51%. Comparing base (ff91433) to head (acace23).
⚠️ Report is 124 commits behind head on main.

Files with missing lines Patch % Lines
sleap_nn/config_generator/tui/app.py 0.00% 356 Missing ⚠️
sleap_nn/config_generator/generator.py 75.00% 48 Missing ⚠️
sleap_nn/cli.py 24.44% 34 Missing ⚠️
sleap_nn/config_generator/analyzer.py 83.07% 22 Missing ⚠️
sleap_nn/config_generator/recommender.py 81.91% 17 Missing ⚠️
sleap_nn/config_generator/memory.py 80.00% 11 Missing ⚠️
sleap_nn/config_generator/__init__.py 80.95% 4 Missing ⚠️
sleap_nn/config_generator/tui/__init__.py 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (ff91433) and HEAD (acace23). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (ff91433) HEAD (acace23)
4 3
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #438       +/-   ##
===========================================
- Coverage   95.28%   81.51%   -13.77%     
===========================================
  Files          49       81       +32     
  Lines        6765    11665     +4900     
===========================================
+ Hits         6446     9509     +3063     
- Misses        319     2156     +1837     

☔ View full report in Codecov by Sentry.
📢 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.

@gitttt-1234 gitttt-1234 marked this pull request as draft January 26, 2026 20:07
gitttt-1234 and others added 2 commits January 26, 2026 12:20
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add reactive YAML preview updates when form values change (pipeline,
  backbone, inputs, switches, selects)
- Set default pipeline selection to Single Instance
- Update head_configs to include all head types (matching expected format)
- Add missing event handlers for Switch and Select widgets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants