talmolab / sleap

A deep learning framework for multi-animal pose tracking.
https://sleap.ai
Other
435 stars 97 forks source link

Allow passing in `Labels` to `app.main` #1524

Closed roomrys closed 1 year ago

roomrys commented 1 year ago

Description

This is more a debugging feature than anything else. A lot of the times when I want to visually inspect a project after making changes to the code, I will end up calling sleap-label through it's entry point function sleap.gui.app.main. This forces me to save the file and use the path to that file to then open the project in the GUI.

This PR allows developers to

  1. just pass in the Labels to visually inspect via sleap.gui.app.main
  2. create an instance of the GUI after using the GPU

and it also

  1. creates the argparser in it's own function

Types of changes

Does this address any currently open issues?

[list open issues here]

Outside contributors checklist

Thank you for contributing to SLEAP!

:heart:

Summary by CodeRabbit

New Features:

Improvements:

Bug Fixes:

coderabbitai[bot] commented 1 year ago

Walkthrough

The changes primarily revolve around enhancing the MainWindow class and main function in sleap/gui/app.py to accept an optional labels parameter, improving flexibility. Additionally, error handling has been introduced for CPU-only mode switch, and a new function create_parser has been added for argument parsing.

Changes

File Summary
sleap/gui/app.py Introduced labels parameter to MainWindow and main function, added create_parser function, and implemented error handling for CPU-only mode switch.
sleap/gui/commands.py Enhanced loadProjectFile method to accept Union[str, Labels] parameter and improved do_action and ask functions to handle None filename and Labels instance respectively.

🐇

In the land of code, changes were made,

With logic and precision, a foundation was laid.

The rabbit hopped, the keys did clatter,

Crafting solutions to make SLEAP better.

With labels in hand, and errors caught,

A more robust system, the rabbit has wrought. 🎉

Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - Mention `@coderabbitai` in any *review comment* for bot assistance. - Note: Review comments are made on code diffs or files, not on the PR overview. ### Pause Incremental Reviews - Insert `@coderabbitai: ignore` in the PR description to halt the bot's ongoing reviews. Remove the line to resume. - Additionally, enter `@coderabbitai pause` to halt the bot's ongoing reviews as any issue or review comment. To resume reviews, enter `@coderabbitai resume` as any issue or review comment.
codecov[bot] commented 1 year ago

Codecov Report

Merging #1524 (9b5b1c7) into develop (ed77b49) will decrease coverage by 0.02%. The diff coverage is 63.63%.

@@             Coverage Diff             @@
##           develop    #1524      +/-   ##
===========================================
- Coverage    73.39%   73.38%   -0.02%     
===========================================
  Files          134      134              
  Lines        23961    23973      +12     
===========================================
+ Hits         17586    17592       +6     
- Misses        6375     6381       +6     
Files Coverage Δ
sleap/gui/commands.py 61.35% <100.00%> (ø)
sleap/gui/app.py 74.73% <50.00%> (-0.62%) :arrow_down:

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more