-
Notifications
You must be signed in to change notification settings - Fork 239
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
Make NNCF common accuracy aware training code pass mypy checks #2637
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2637 +/- ##
============================================
- Coverage 89.84% 77.96% -11.89%
============================================
Files 494 493 -1
Lines 45374 45468 +94
============================================
- Hits 40768 35450 -5318
- Misses 4606 10018 +5412
... and 109 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@alexsu52 fyi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend against using explicit cast(...)
calls. For cases where you get(...)
something from a Dict
and assign it to a variable, it should be sufficient to add an inline type hint via var_name : type_name = ....get(...)
syntax, since a plain Dict
would be implicitly a Dict[Any, Any]
, and we have an implicit cast that mypy
won't complain about.
Also, completely decoupling the new Image
typevar from PIL.Image
may not be the best solution, see if you can implement one of the variants from this suggestion instead:
https://stackoverflow.com/questions/61384752/how-to-type-hint-with-an-optional-import
Sure, I will get on it and try to couple the Image TypeVar from the optional import. I will also iterate through every cast instance and adjust it as suggested. |
@vshampor @alexsu52 I just realised that I had used cast for values returned from As for the remaining use of cast, it was necessary due to the values being For the Image Type Variable, I have searched online for optional imports and there seems to be no proper way to do it or they don't work. For this, I have initialized an Image type with Any before the imports which was later used to bound the ImageType |
… history dictionary keys and values.
Looks like some of the backend-specific unit tests are failing: PT:
TF
Please run the associated tests locally ( @property
def compression_rate_target(self) -> float:
if self._compression_rate_target is None:
... |
Sure, I will look into it and get back to you. Hopefully by Saturday, since I am busy with my end of semester examinations. |
@vshampor I believe the pre-commit issues have been resolved. Can you please run the mypy tests and review it? |
Changes:
mypy checks for accuracy_aware_training pass.
type: ignore is used in some places due to one of the following reasons:
self._train_epoch_fn
Extra Changes:
configure_accuracy_aware_paths
were changed to include pathlib.Path.initialize_training_loop_fns
due to mypy bug regarding a mismatch of the function type.Reasons for changes:
Passing mypy checks in issue #2492
Related tickets:
Closes #2492