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

Smarter matching for default subcommands #33

Merged
merged 5 commits into from
Feb 20, 2023
Merged

Conversation

brentyi
Copy link
Owner

@brentyi brentyi commented Feb 6, 2023

From nerfstudio-project/nerfstudio#1281:

When we pass in a default for a type with subcommands, tyro needs to figure out which subcommand the default corresponds to (is this config yaml from ns-train nerfacto? ns-train depth-nerfacto? ns-train instant-ngp?). For the vast majority of cases this matching is straightforward, but nerfstudio's subcommands happen to not fall into this category.

The goal of this PR is to improve matching for default subcommands.

In order of priority, we now match against:

  • The hash of subcommand defaults. (via object.__hash__)
  • The value of subcommand defaults. (via equality comparison)
  • New: a notion of a type tree, of the specified default against subcommands with concrete defaults.
  • New: a type tree, of the specified default against the subcommand annotations.

Needs tests!

@codecov
Copy link

codecov bot commented Feb 6, 2023

Codecov Report

Base: 99.21% // Head: 99.21% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (27a7f0b) compared to base (59f64bc).
Patch coverage: 95.38% of modified lines in pull request are covered.

❗ Current head 27a7f0b differs from pull request most recent head 7644779. Consider uploading reports for the commit 7644779 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #33      +/-   ##
==========================================
- Coverage   99.21%   99.21%   -0.01%     
==========================================
  Files          21       22       +1     
  Lines        1654     1648       -6     
==========================================
- Hits         1641     1635       -6     
  Misses         13       13              
Flag Coverage Δ
unittests 99.21% <95.38%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tyro/_subcommand_matching.py 94.82% <94.82%> (ø)
tyro/_fields.py 98.89% <100.00%> (+0.99%) ⬆️
tyro/_parsers.py 100.00% <100.00%> (ø)
tyro/_instantiators.py 99.01% <0.00%> (-0.05%) ⬇️
tyro/_cli.py 100.00% <0.00%> (ø)
tyro/_argparse_formatter.py 97.36% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

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