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

create type hint stub files for module torch #12500

Closed
wants to merge 45 commits into from
Closed

Commits on Oct 9, 2018

  1. create type hint stub files for module torch

    This is more a basis for discussion that a ready solution,
    as it does lots of funny things, and for many of them
    a better solution will be found.
    
    - Initial stab at creating a type torch/__init__.pyi .
    - We only do this for Python 3 because we want to
      use type hint introspection.
    - So far, we only aim at doing this for torch functions
      and torch.Tensor.
    - We need to import the newly build torch. Thus we
      do this at the end of the build.
      We use os.fork to only import the module in a child
      process.
    - We use an annotate decorator to be able to put
      type hints on the native python functions in a way that
      a) they're available in the usual place for Python 3
      b) we stay Python 2 compatible
    - Some annotatons in torch/functional.py are provided
      as examples, but the remaining ones still need to be done.
    
    This could end up fixing pytorch#7318
    t-vi committed Oct 9, 2018
    Copy the full SHA
    7eefb10 View commit details
    Browse the repository at this point in the history
  2. the future...

    t-vi committed Oct 9, 2018
    Copy the full SHA
    2e3ee60 View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2018

  1. Improve type mapping, add manual annotations

    - Add manual tensor() annotation, thank you, @elliotwite.
    - Create class stubs for device etc.
    - Improve type mapping. Thank you, Simon, for the review comments.
    t-vi committed Oct 10, 2018
    Copy the full SHA
    a327e18 View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2018

  1. Copy the full SHA
    813f7fa View commit details
    Browse the repository at this point in the history
  2. Merge branch 'master' into pyi

    t-vi committed Oct 16, 2018
    Copy the full SHA
    66eae2b View commit details
    Browse the repository at this point in the history
  3. add Tensor/Storage subclasses

    t-vi committed Oct 16, 2018
    Copy the full SHA
    4920bed View commit details
    Browse the repository at this point in the history
  4. more updates

    t-vi committed Oct 16, 2018
    Copy the full SHA
    a15126f View commit details
    Browse the repository at this point in the history
  5. add blacklist

    t-vi committed Oct 16, 2018
    Copy the full SHA
    5a07b21 View commit details
    Browse the repository at this point in the history

Commits on Oct 18, 2018

  1. Merge branch 'master' into pyi

    t-vi committed Oct 18, 2018
    Copy the full SHA
    df4f553 View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2018

  1. Add test and update generation

    - Add test_type_hints.py: For testing we compile the docstring
      examples into one large file and run mypy over it.
    - Make the test pass by adding lots of cases to gen_pyi.py.
    t-vi committed Oct 19, 2018
    Copy the full SHA
    bd89d71 View commit details
    Browse the repository at this point in the history
  2. Typo

    t-vi committed Oct 19, 2018
    Copy the full SHA
    03b6ec1 View commit details
    Browse the repository at this point in the history
  3. Merge branch 'master' into pyi

    t-vi committed Oct 19, 2018
    Copy the full SHA
    c3890fd View commit details
    Browse the repository at this point in the history
  4. adapt to master

    t-vi committed Oct 19, 2018
    Copy the full SHA
    48534ee View commit details
    Browse the repository at this point in the history
  5. no typehint testing for python2

    t-vi committed Oct 19, 2018
    Copy the full SHA
    f9e9527 View commit details
    Browse the repository at this point in the history
  6. python 3.5 compat

    t-vi committed Oct 19, 2018
    Copy the full SHA
    c8ba192 View commit details
    Browse the repository at this point in the history
  7. test for mypy

    t-vi committed Oct 19, 2018
    Copy the full SHA
    01be0be View commit details
    Browse the repository at this point in the history

Commits on Oct 20, 2018

  1. add docstr

    t-vi committed Oct 20, 2018
    Copy the full SHA
    4538b13 View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2018

  1. Merge branch 'master' into pyi

    t-vi committed Dec 17, 2018
    Copy the full SHA
    2d12164 View commit details
    Browse the repository at this point in the history

Commits on Jan 10, 2019

  1. Copy the full SHA
    74d5226 View commit details
    Browse the repository at this point in the history

Commits on Jan 15, 2019

  1. Merge branch 'pr_12500' into pyi

    t-vi committed Jan 15, 2019
    Copy the full SHA
    8a5fe13 View commit details
    Browse the repository at this point in the history
  2. Merge branch 'master' into pyi

    t-vi committed Jan 15, 2019
    Copy the full SHA
    4da0468 View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    1dba716 View commit details
    Browse the repository at this point in the history

Commits on Jan 17, 2019

  1. Generate pyi in-place, also general formatting and commenting

    - Previously, type hints didn't work for 'develop' builds,
      because the pyi was put into a generated directory and
      consequently not picked up by the Python interpreter.
      It's a lot easier, and consistent with how we generate
      other files in PyTorch, to just generate the file in place.
      I need to test if the pyi file actually gets installed.
    
    - I figured out why mypy didn't work in the default directory;
      it's because we had a mypy.ini which specified Python 2.
      I fixed this by making our test file Python 2 syntax compatible.
    
    - I added some more comments, and adjusted formatting to my
      taste.
    
    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 17, 2019
    Copy the full SHA
    8ba524e View commit details
    Browse the repository at this point in the history
  2. Don't assume data exists, and comment about mypy bug workaround

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 17, 2019
    Copy the full SHA
    efe9f36 View commit details
    Browse the repository at this point in the history
  3. Don't install mypy in environments where it doesn't work

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 17, 2019
    Copy the full SHA
    fb42c2c View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2019

  1. Restructure so that it works with Python 2

    This is done by deleting all of annotation based inference; instead
    we'll just write those signatures out manually.
    
    A bit of code reorging happened along the way.
    
    I still need to add back the direct Python implementations;
    incoming soon!
    
    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 22, 2019
    Copy the full SHA
    152aa97 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2019

  1. Fix some errors

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    5b879a2 View commit details
    Browse the repository at this point in the history
  2. Make reexporting work

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    b36711b View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    17042b6 View commit details
    Browse the repository at this point in the history
  4. cmake update

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    d6e3cca View commit details
    Browse the repository at this point in the history
  5. Well, maybe this fixes the build

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    67c0b12 View commit details
    Browse the repository at this point in the history
  6. Test script fix

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    f6e795f View commit details
    Browse the repository at this point in the history
  7. Bring back py2.7 filter

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    4b1d1f2 View commit details
    Browse the repository at this point in the history
  8. Try to make the file write more robust

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    6daedff View commit details
    Browse the repository at this point in the history
  9. Appease lint

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    fb3c020 View commit details
    Browse the repository at this point in the history
  10. Try to fix it more

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    baf90c7 View commit details
    Browse the repository at this point in the history
  11. Improve docblock

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 23, 2019
    Copy the full SHA
    5781760 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2019

  1. Remove torch dependency entirely

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 24, 2019
    Copy the full SHA
    586ff9f View commit details
    Browse the repository at this point in the history
  2. Swizzle the cmake a little

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 24, 2019
    Copy the full SHA
    1f51ad2 View commit details
    Browse the repository at this point in the history
  3. Fwizzle the cmake again

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 24, 2019
    Copy the full SHA
    3a79546 View commit details
    Browse the repository at this point in the history
  4. Use add_dependencies instead

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 24, 2019
    Copy the full SHA
    1454af4 View commit details
    Browse the repository at this point in the history

Commits on Jan 28, 2019

  1. Fix cmake dependency tracking

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 28, 2019
    Copy the full SHA
    5a052cd View commit details
    Browse the repository at this point in the history
  2. More buildfixes

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 28, 2019
    Copy the full SHA
    eef0f05 View commit details
    Browse the repository at this point in the history
  3. Handle the rest of the problems, I think

    Signed-off-by: Edward Z. Yang <ezyang@fb.com>
    ezyang committed Jan 28, 2019
    Copy the full SHA
    b0d4971 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    a299207 View commit details
    Browse the repository at this point in the history