Skip to content

Conversation

simpkins
Copy link
Contributor

@simpkins simpkins commented Feb 5, 2021

Stack from ghstack:

Summary:
This updates python/core.py to explicitly define all of the DataType
values rather than dynamically defining them at runtime from the
caffe2_pb2 values.

This allows type checkers like Pyre and Mypy to see the members of the
DataType class. Otherwise the type checkers report errors such as
"core.DataType" has no attribute "INT64".

This code does keep a run-time check that all of the data types defined
by caffe2_pb2.proto are defined correctly in this file. This way if
someone does add a new type to caffe2_pb2.proto it should be very
quickly apparent that this file needs to be updated and kept in sync.

Test Plan:
Confirmed that various caffe2/python test still pass. Will check CI
test results.

Differential Revision: D26271725

Summary:
This updates python/core.py to explicitly define all of the `DataType`
values rather than dynamically defining them at runtime from the
`caffe2_pb2` values.

This allows type checkers like Pyre and Mypy to see the members of the
`DataType` class.  Otherwise the type checkers report errors such as
`"core.DataType" has no attribute "INT64"`.

This code does keep a run-time check that all of the data types defined
by `caffe2_pb2.proto` are defined correctly in this file.  This way if
someone does add a new type to `caffe2_pb2.proto` it should be very
quickly apparent that this file needs to be updated and kept in sync.

Test Plan:
Confirmed that various caffe2/python test still pass.  Will check CI
test results.

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Feb 5, 2021

💊 CI failures summary and remediations

As of commit 5e12bde (more details on the Dr. CI page):


  • 1/1 failures introduced in this PR

1 failure not recognized by patterns:

Job Step Action
CircleCI pytorch_linux_xenial_py3_clang5_asan_test2 Run tests 🔁 rerun

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Summary:
This updates python/core.py to explicitly define all of the `DataType`
values rather than dynamically defining them at runtime from the
`caffe2_pb2` values.

This allows type checkers like Pyre and Mypy to see the members of the
`DataType` class.  Otherwise the type checkers report errors such as
`"core.DataType" has no attribute "INT64"`.

This code does keep a run-time check that all of the data types defined
by `caffe2_pb2.proto` are defined correctly in this file.  This way if
someone does add a new type to `caffe2_pb2.proto` it should be very
quickly apparent that this file needs to be updated and kept in sync.

Test Plan:
Confirmed that various caffe2/python test still pass.  Will check CI
test results.

Differential Revision: [D26271725](https://our.internmc.facebook.com/intern/diff/D26271725)

[ghstack-poisoned]
simpkins added a commit that referenced this pull request Feb 11, 2021
Pull Request resolved: #51768



This updates python/core.py to explicitly define all of the `DataType`
values rather than dynamically defining them at runtime from the
`caffe2_pb2` values.

This allows type checkers like Pyre and Mypy to see the members of the
`DataType` class.  Otherwise the type checkers report errors such as
`"core.DataType" has no attribute "INT64"`.

This code does keep a run-time check that all of the data types defined
by `caffe2_pb2.proto` are defined correctly in this file.  This way if
someone does add a new type to `caffe2_pb2.proto` it should be very
quickly apparent that this file needs to be updated and kept in sync.

Differential Revision: [D26271725](https://our.internmc.facebook.com/intern/diff/D26271725/)
ghstack-source-id: 121107704
Summary:
This updates python/core.py to explicitly define all of the `DataType`
values rather than dynamically defining them at runtime from the
`caffe2_pb2` values.

This allows type checkers like Pyre and Mypy to see the members of the
`DataType` class.  Otherwise the type checkers report errors such as
`"core.DataType" has no attribute "INT64"`.

This code does keep a run-time check that all of the data types defined
by `caffe2_pb2.proto` are defined correctly in this file.  This way if
someone does add a new type to `caffe2_pb2.proto` it should be very
quickly apparent that this file needs to be updated and kept in sync.

Test Plan:
Confirmed that various caffe2/python test still pass.  Will check CI
test results.

Differential Revision: [D26271725](https://our.internmc.facebook.com/intern/diff/D26271725)

[ghstack-poisoned]
simpkins added a commit that referenced this pull request Feb 18, 2021
Pull Request resolved: #51768



This updates python/core.py to explicitly define all of the `DataType`
values rather than dynamically defining them at runtime from the
`caffe2_pb2` values.

This allows type checkers like Pyre and Mypy to see the members of the
`DataType` class.  Otherwise the type checkers report errors such as
`"core.DataType" has no attribute "INT64"`.

This code does keep a run-time check that all of the data types defined
by `caffe2_pb2.proto` are defined correctly in this file.  This way if
someone does add a new type to `caffe2_pb2.proto` it should be very
quickly apparent that this file needs to be updated and kept in sync.

Differential Revision: [D26271725](https://our.internmc.facebook.com/intern/diff/D26271725/)

**NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D26271725/)!
ghstack-source-id: 121936201
@facebook-github-bot
Copy link
Contributor

@simpkins merged this pull request in f7aa88b.

@facebook-github-bot facebook-github-bot deleted the gh/simpkins/4/head branch February 21, 2021 15:16
xsacha pushed a commit to xsacha/pytorch that referenced this pull request Mar 31, 2021
…1768)

Summary:
Pull Request resolved: pytorch#51768

This updates python/core.py to explicitly define all of the `DataType`
values rather than dynamically defining them at runtime from the
`caffe2_pb2` values.

This allows type checkers like Pyre and Mypy to see the members of the
`DataType` class.  Otherwise the type checkers report errors such as
`"core.DataType" has no attribute "INT64"`.

This code does keep a run-time check that all of the data types defined
by `caffe2_pb2.proto` are defined correctly in this file.  This way if
someone does add a new type to `caffe2_pb2.proto` it should be very
quickly apparent that this file needs to be updated and kept in sync.
ghstack-source-id: 121936201

Test Plan:
Confirmed that various caffe2/python tests still pass.
Verified that this allows many `pyre-fixme` comments to be removed in
downstream projects, and that Pyre is still clean for these projects.

Reviewed By: jeffdunn

Differential Revision: D26271725

Pulled By: simpkins

fbshipit-source-id: f9e95795de60aba67d7d3872d0c141ed82ba8e39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants