Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace (broken) --unrag with --ragged #1539

Merged
merged 3 commits into from
Oct 11, 2023

Conversation

roomrys
Copy link
Collaborator

@roomrys roomrys commented Oct 10, 2023

Description

The --unrag argument was previous unable to be set to False due to its "default of true" and "store_true" nature. This PR flips to a more correct logic which uses a --ragged argument with default false and true if --ragged or -r is included (i.e. store_true). The broken --unrag argument has been dropped. This is an alternative PR to #1531.

Types of changes

  • Bugfix
  • New feature
  • Refactor / Code style update (no logical changes)
  • Build / CI changes
  • Documentation Update
  • Other (explain)

Does this address any currently open issues?

Outside contributors checklist

  • Review the guidelines for contributing to this repository
  • Read and sign the CLA and add yourself to the authors list
  • Make sure you are making a pull request against the develop branch (not main). Also you should start your branch off develop
  • Add tests that prove your fix is effective or that your feature works
  • Add necessary documentation (if appropriate)

Thank you for contributing to SLEAP!

❤️

Summary by CodeRabbit

  • Refactor: Replaced -u/--unrag option with -r/--ragged in the command-line interface. The new -r option allows keeping tensors ragged if present. If omitted, ragged tensors will be converted into regular tensors with NaN padding.
  • Documentation: Updated the CLI guide to reflect the changes in the command-line arguments.
  • Test: Added a new test function test_make_export_cli to verify the functionality of the updated command-line parser.

@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

Merging #1539 (8d1de19) into develop (ed77b49) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           develop    #1539      +/-   ##
===========================================
- Coverage    73.39%   73.39%   -0.01%     
===========================================
  Files          134      134              
  Lines        23961    23961              
===========================================
- Hits         17586    17585       -1     
- Misses        6375     6376       +1     
Files Coverage Δ
sleap/nn/inference.py 81.25% <ø> (ø)

... and 1 file with indirect coverage changes

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

@roomrys roomrys marked this pull request as ready for review October 10, 2023 15:08
@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2023

Walkthrough

The changes revolve around the handling of ragged tensors in the CLI and export_cli function. The -u/--unrag option is replaced with -r/--ragged, altering the default behavior to convert ragged tensors into regular ones unless the -r option is specified. A new test function is added to validate these changes.

Changes

File Path Summary
docs/guides/cli.md The -u option is replaced with -r, changing the handling of ragged tensors. The --unrag argument is removed.
sleap/nn/.../inference.py The unrag_outputs argument is replaced with ragged in the export_cli function. The -u/--unrag option is replaced with -r/--ragged in the CLI parser.
tests/nn/test_inference.py Added test_make_export_cli function to test the _make_export_cli_parser function.

"In the land of code, changes are afoot,
🐇 hopped and skipped, making changes astute.
Tensors once ragged, now neatly arrayed,
Unless -r is flagged, then ragged they stayed.
Tests are added, to ensure all is right,
Celebrate the changes, in the soft moonlight." 🌙


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.

@roomrys roomrys requested a review from talmo October 10, 2023 15:09
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between ed77b49 and 2f7a1ad.
Files selected for processing (3)
  • docs/guides/cli.md (1 hunks)
  • sleap/nn/inference.py (2 hunks)
  • tests/nn/test_inference.py (15 hunks)
Files skipped from review due to trivial changes (1)
  • tests/nn/test_inference.py
Additional comments (Suppressed): 2
sleap/nn/inference.py (2)
  • 4939-4944: The argument unrag_outputs has been replaced with ragged and the logic has been inverted. Ensure that all calls to export_model function throughout the codebase have been updated to match the new argument and its behavior.

  • 4974-4981: The --unrag argument has been replaced with --ragged and the default value has been changed from True to False. This changes the behavior of the command-line interface. Make sure that this change is communicated to the users and the documentation is updated accordingly.

Comment on lines 99 to 107
-e [EXPORT_PATH], --export_path [EXPORT_PATH]
Path to output directory where the frozen model will be exported to.
Defaults to a folder named 'exported_model'.
-u, --unrag UNRAG
Convert ragged tensors into regular tensors with NaN padding.
Defaults to True.
-r, --raggged RAGGED
Keep tensors tensors ragged if present. If ommited, convert
ragged tensors into regular tensors with NaN padding.
-n, --max_instances MAX_INSTANCES
Limit maximum number of instances in multi-instance models.
Not available for ID models. Defaults to None.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new -r or --ragged option is well explained. However, there are two typos in line 102 and 103. The word "ragged" is misspelled in line 102 and the word "tensors" is repeated in line 103. Here is the corrected version:

- 102:   -r, --raggged RAGGED
+ 102:   -r, --ragged RAGGED
- 103:                         Keep tensors tensors ragged if present. If ommited, convert 
+ 103:                         Keep tensors ragged if present. If omitted, convert 

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 2f7a1ad and 8d1de19.
Files selected for processing (2)
  • docs/guides/cli.md (1 hunks)
  • sleap/nn/inference.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • docs/guides/cli.md
Additional comments (Suppressed): 2
sleap/nn/inference.py (2)
  • 4939-4944: The function call to export_model has been updated to use the new args.ragged argument instead of the old args.unrag argument. The logic has been inverted with not args.ragged to maintain the original behavior. Ensure that the args.ragged argument is correctly set in the calling context.

  • 4974-4982: The -u/--unrag argument has been replaced with -r/--ragged. The default value has been changed from True to False, and the help message has been updated accordingly. Make sure that all instances of -u/--unrag in the codebase and documentation have been replaced with -r/--ragged.

@roomrys
Copy link
Collaborator Author

roomrys commented Oct 11, 2023

Although not "official", this review was discussed and verbally approved on Tuesday's meeting, so merging.

@roomrys roomrys merged commit 6b14bca into develop Oct 11, 2023
9 checks passed
@roomrys roomrys deleted the liezl/replace-unrag-with-ragged branch October 11, 2023 19:55
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