Helpful error message when accessing non-existent variables#638
Helpful error message when accessing non-existent variables#638freddyaboulton wants to merge 6 commits intogoogle:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #638 +/- ##
==========================================
+ Coverage 80.59% 80.65% +0.05%
==========================================
Files 56 56
Lines 4241 4259 +18
==========================================
+ Hits 3418 3435 +17
- Misses 823 824 +1
Continue to review full report at Codecov.
|
|
Hi @freddyaboulton -- a few comments:
I also want a second review from @jheek who original proposed this idea on #513 |
|
(Oh I forgot to say thank you for jumping on this issue so quickly!) |
03f72df to
8cbb423
Compare
|
@avital Thank you for the feedback! I've addressed your comments. The CI passes locally but the github action is stuck installing dependencies. It's quite confusing since this PR does not change any dependencies. Yesterday it failed on a |
|
We fixed the tensorflow_text problem, it was a bad version dependency. If you rebase and push now tests should pass. |
4afd0af to
1f39fcd
Compare
|
I think this is a good idea! I wonder though if we can simplify to make this more widely applicable. Essentially we want a FrozenDict to have a helpful error message on missing keys (and potentially when mutating). However, if we do this by subclasssing we need to make a subclass for each case. How about adding a missing_key_handler (and perhaps mutation_handler) to a FrozenDict? Let me know what you think We would probably also want error handlers like this on other frozen structures and an interface like this would allow it to be consistent. |
|
@freddyaboulton any update on this? |
|
Closing due to inactivity |
Fixes #513. Following the discussion in #513, Scope
variablesandapplynow return variables as instances ofNonFinalVariablesDictas opposed toFrozenDict. This will give users a helpful error message that explains that variables (if they exist) should be accessed after shape inference and shows the existing variable names.#513 explicitly mentions the variables returned by
Scope.variablesbut I thought it would be good to apply this change to the variables returned byModule.applysince users are likely to access those as well and would benefit from the same useful error message. Happy to walk that back though.