tensorflow: Add members from tensorflow.keras.metrics#11329
tensorflow: Add members from tensorflow.keras.metrics#11329JelleZijlstra merged 15 commits intopython:mainfrom
tensorflow: Add members from tensorflow.keras.metrics#11329Conversation
This comment has been minimized.
This comment has been minimized.
66f37c0 to
a8d82cc
Compare
This comment has been minimized.
This comment has been minimized.
61faa9e to
efbb44a
Compare
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
7788199 to
4ef4051
Compare
This comment has been minimized.
This comment has been minimized.
08ec9a5 to
155f910
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
|
@hmc-cs-mdrissi If you have time to review it. |
Taken from: https://github.com/hmc-cs-mdrissi/tensorflow_stubs/blob/main/stubs/tensorflow/keras/metrics.pyi [pre-commit.ci] auto fixes from pre-commit.com hooks fix CI errors [pre-commit.ci] auto fixes from pre-commit.com hooks fix CI errors TensorCompatible -> _TensorCompatible fix CI errors fix CI errors fix CI errors [pre-commit.ci] auto fixes from pre-commit.com hooks fix CI errors fix CI errors [pre-commit.ci] auto fixes from pre-commit.com hooks fix CI errors [pre-commit.ci] auto fixes from pre-commit.com hooks
[pre-commit.ci] auto fixes from pre-commit.com hooks
a7c6586 to
1c66747
Compare
This comment has been minimized.
This comment has been minimized.
|
FYI this has a merge conflict now. |
This comment has been minimized.
This comment has been minimized.
|
@JelleZijlstra The CI was passing before merging with main, but now there is an error with the imports that I do not understand. Would you have an idea of what is causing it ? |
|
There was a failing stubtest job with no output; I reran it. There is also a pytype crash: Which looks more mysterious, since I don't see how this PR relates to |
| def from_config(cls, config: dict[str, Any]) -> Self: ... | ||
| def get_config(self) -> dict[str, Any]: ... | ||
| @override | ||
| def add_weight( |
There was a problem hiding this comment.
This also looks like an inherited method so metrics class shouldn't have it defined. Add it to Layer class if it's not already there.
There was a problem hiding this comment.
Done in e9246aa. It was already inherited from Layer indeed.
There was a problem hiding this comment.
@hmc-cs-mdrissi The add_weight from keras.metrics.Metric is different from the one from keras.layers.Layer, so I need to redefine it. However I'm facing the same error I had in another PR with MultiHeadAttention. Even if I add the method to the stubtest_allowlist, mypy still reports an error.
There was a problem hiding this comment.
# type: ignore works for that. stubtest allowlist is for runtime vs stub checks. Before that happens there's also a mypy pass. And you can use normal # type: ignore to handle that.
There was a problem hiding this comment.
Generally get mypy passing first. No need to consider allowlist and then after mypy is green work on stubtest errors, and use allowlist when appropriate.
This comment has been minimized.
This comment has been minimized.
Yeah, this was a weird one! Turns out it was an issue with how pytype resolves module aliases. I have a fix out for review, but I might not be able to release a new version of pytype until sometime next week, as we have a few big changes in the pipeline. |
f53ff92 to
5e28825
Compare
This comment has been minimized.
This comment has been minimized.
5e28825 to
8db4a5d
Compare
This comment has been minimized.
This comment has been minimized.
See python/typeshed#11329 for a case in which the old approach failed. Hypothetically, this new approach could get quite expensive, with LookupExternalTypes called over and over, but I ran typeshed's pytype_test a few times with and without the change and noticed no difference in runtime. PiperOrigin-RevId: 603435155
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, this took longer than expected, but pytype-2024.02.09 is out with this fix. |
|
Thank you! |
These subs are taken from: https://github.com/hmc-cs-mdrissi/tensorflow_stubs/blob/main/stubs/tensorflow/keras/metrics.pyi