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

[JIT] add support for torch.jit.Final in python 3.6 #47393

Closed
wants to merge 5 commits into from

Conversation

Lilyjjo
Copy link
Contributor

@Lilyjjo Lilyjjo commented Nov 4, 2020

Stack from ghstack:

Python added support for typing.Final in 3.8, and there exists a backport for 3.7 and 3.6 in typing_extensions.Final

The 3.6 version of typing_extensions.Final doesn't support the getattr(x, '__origin__') to determine if an object is of the Final type while 3.7 does. This PR allows for the Final type of an object to be discoverable in 3.6

Differential Revision: D24739402

Lilyjjo added a commit that referenced this pull request Nov 4, 2020
ghstack-source-id: 14af2951e99cb236505356ef80c0eb34a901cd09
Pull Request resolved: #47393
@Lilyjjo Lilyjjo linked an issue Nov 4, 2020 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Nov 4, 2020

Codecov Report

Merging #47393 into gh/Lilyjjo/11/base will increase coverage by 0.20%.
The diff coverage is n/a.

@@                  Coverage Diff                   @@
##           gh/Lilyjjo/11/base   #47393      +/-   ##
======================================================
+ Coverage               81.26%   81.47%   +0.20%     
======================================================
  Files                    1792     1792              
  Lines                  186142   186142              
======================================================
+ Hits                   151275   151657     +382     
+ Misses                  34867    34485     -382     

@@ -717,7 +717,7 @@ def is_rref(ann):

def is_final(ann):
return ann.__module__ in {'typing', 'typing_extensions'} and \
(getattr(ann, '__origin__', None) is Final)
(getattr(ann, '__origin__', None) is Final or isinstance(ann, type(Final)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional:

Can you say a bit more about why this change is needed (in PR description)? I am curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added :)

@SplitInfinity
Copy link

Do we need a test for this? I think the issue that reported this issue has a small test case we can use.

Lilyjjo added a commit that referenced this pull request Nov 5, 2020
ghstack-source-id: 1a9a181c0b899598621bfaa226e653e857fe80b1
Pull Request resolved: #47393
@dr-ci
Copy link

dr-ci bot commented Nov 5, 2020

💊 CI failures summary and remediations

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


None of the CI failures appear to be your fault 💚



🚧 1 fixed upstream failure:

These were probably caused by upstream breakages that were already fixed.

Please rebase on the viable/strict branch (expand for instructions)

Since your merge base is older than viable/strict, run these commands:

git fetch https://github.com/pytorch/pytorch viable/strict
git rebase FETCH_HEAD

Check out the recency history of this "viable master" tracking branch.


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 on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 12 times.

Python added support for typing.Final in 3.8, and there exists a backport for 3.7 and 3.6 in typing_extensions.Final

The 3.6 version of typing_extensions.Final doesn't support the getattr(x, '__origin__') to determine if an object is of the Final type while 3.7 does. This PR allows for the Final type of an object to be discoverable in 3.6


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

[ghstack-poisoned]
Lilyjjo added a commit that referenced this pull request Nov 5, 2020
ghstack-source-id: 9928d3f32dffd4ea07d8493c3cd81e7e279533e0
Pull Request resolved: #47393
@@ -159,7 +158,6 @@ def a(x):
# Make sure that no entries are left over from the previous failure
FileCheck().check_count("is being compiled", 2).run(str(e))

@unittest.skipIf(sys.version_info[:2] < (3, 7), "Class annotations are a thing in > 3.5, need to fix for < 3.7")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment was out of date? Not totally sure, but this test now passes for python3.6 and python3.7 and checks the functionality of Final

Python added support for typing.Final in 3.8, and there exists a backport for 3.7 and 3.6 in typing_extensions.Final

The 3.6 version of typing_extensions.Final doesn't support the `getattr(x, '__origin__')` to determine if an object is of the Final type while 3.7 does. This PR allows for the Final type of an object to be discoverable in 3.6


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

[ghstack-poisoned]
Python added support for typing.Final in 3.8, and there exists a backport for 3.7 and 3.6 in typing_extensions.Final

The 3.6 version of typing_extensions.Final doesn't support the `getattr(x, '__origin__')` to determine if an object is of the Final type while 3.7 does. This PR allows for the Final type of an object to be discoverable in 3.6


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

[ghstack-poisoned]
Lilyjjo added a commit that referenced this pull request Nov 5, 2020
ghstack-source-id: 9928d3f32dffd4ea07d8493c3cd81e7e279533e0
Pull Request resolved: #47393
@facebook-github-bot
Copy link
Contributor

@Lilyjjo merged this pull request in 6377877.

@facebook-github-bot facebook-github-bot deleted the gh/Lilyjjo/11/head branch November 10, 2020 15:17
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.

torch.jit.Final does not work in Pytorch1.7 + Python3.6
4 participants