Commit Graph

19 Commits

Author SHA1 Message Date
Adam Simpkins
c4eb22009e Drop some Python 2 compatibility code (#51769)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51769

Remove some Python 2 compatibility code that otherwise causes errors to
be reported from static type checkers.

Static type checkers complain that the old Python 2 modules and
functions referenced by this code do not exist.  Given that Python 2
support is entirely deprecated now we can simply remove the
compatibility code.
ghstack-source-id: 121313191

Test Plan:
Was able to get Pyre to successfully type check the `caffe2/python`
directory with this and some other changes.

Reviewed By: Tianshu-Bao

Differential Revision: D26271723

Pulled By: simpkins

fbshipit-source-id: fec8a09466be6867388832380480aafd36616aa1
2021-02-11 11:02:33 -08:00
Bugra Akyildiz
27c7158166 Remove __future__ imports for legacy Python2 supports (#45033)
Summary:
There is a module called `2to3` which you can target for future specifically to remove these, the directory of `caffe2` has the most redundant imports:

```2to3 -f future -w caffe2```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/45033

Reviewed By: seemethere

Differential Revision: D23808648

Pulled By: bugra

fbshipit-source-id: 38971900f0fe43ab44a9168e57f2307580d36a38
2020-09-23 17:57:02 -07:00
Nikita Shulga
952e0f00a4 Skip c2_ref_tests on network failures (#37972)
Summary:
Skip the tests if network is unaccessible and model can not be downloaded
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37972

Differential Revision: D21441996

Pulled By: malfet

fbshipit-source-id: 5ce59764584974aee9195572338ada1fa0351a75
2020-05-06 22:19:28 -07:00
Michael Antonov
7655b857f7 Add debug logic to c2_ref_test and its helpers (#19359)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19359

Even with file IO exception handling, some of the sandcastle c2_ref_tests are still failing in length-check assert, as can be seen here:
https://our.intern.facebook.com/intern/test/844424932589974?ref_report_id=0

This is an attempt to add printing logic to debug what's going on.

Reviewed By: dzhulgakov

Differential Revision: D14966274

fbshipit-source-id: adce6d4780d664c5ef59f9341b6133b0d09324cb
2019-04-22 12:08:55 -07:00
Min Ni
c3e3c5cc39 Skip tests if C2/ONNX models cannot be read (#18494)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18494

Today we have some C2 end2end test run requiring reading model data from external filesystem (for example, Gluster and AWS). This could be a source for flaky test when the external filesystems are not reachable during the tests.

In this diff, we add try/catch logic around where we download models and open model files from external system. In case such attempts fails, we will catch the excption and let the unittest skip the current test instead of failure.

I also refactor the code a little bit by removing some duplicated logic on downloading and build the c2 model data. It has been duplicated in two classes and a few functions...

Reviewed By: yinghai

Differential Revision: D14442241

fbshipit-source-id: da8bf56c8d096efa34ca2070de5cd10a18aad70c
2019-03-27 11:21:44 -07:00
ttup7777
54ef852d7f Fix unclosed files in download.py, test_onnxifi.py, test_trt.py (#18017)
Summary:
According to https://docs.python.org/3/tutorial/inputoutput.html, it is good practice to use the "with" keyword when dealing with file objects. If not, you should call f.close() to close the file and immediately free up any system resources used by it.  Thus, I adjust the open file function to "with open() as f".
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18017

Differential Revision: D14475112

Pulled By: ezyang

fbshipit-source-id: d1c0821e39cb8a09f86d6d08b437b4a99746416c
2019-03-15 07:29:46 -07:00
Yinghai Lu
e9f6f14555
[Caffe2] Revamp the convnet benchmark code by using models from model zoo (#7351)
* Revamp the convnet benchmark code by using models from model zoo

* Move ModelDownloader to caffe2/python/models

* Remove convnet_benchmarks.py
2018-05-08 08:53:52 -07:00
Orion Reblitz-Richardson
1d5780d42c Remove Apache headers from source.
* LICENSE file contains details, so removing from individual source files.
2018-03-27 13:10:18 -07:00
Yinghai Lu
efe1c2bd13 hypen as a valid part of model names (#2312) 2018-03-20 08:52:54 -07:00
Orion Reblitz-Richardson
d3ea7e260b Allow for all of the names we have in our model zoo.
Summary:
* We now allow subdirectories as well as numbers in the name.
* Also fixed an error case.
Closes https://github.com/caffe2/caffe2/pull/1875

Reviewed By: pjh5

Differential Revision: D6894401

Pulled By: orionr

fbshipit-source-id: 6a9938bc7d2ba6b8f094ed7b8a02664120a10626
2018-02-05 08:52:55 -08:00
Yangqing Jia
8286ce1e3a Re-license to Apache
Summary: Closes https://github.com/caffe2/caffe2/pull/1260

Differential Revision: D5906739

Pulled By: Yangqing

fbshipit-source-id: e482ba9ba60b5337d9165f28f7ec68d4518a0902
2017-09-28 16:22:00 -07:00
Junjie Bai
c231ac2253 Add an argument for suppressing download progress
Summary: In some cases (e.g. CI), showing progress bar will mess up the log.

Reviewed By: jerryzh168

Differential Revision: D5850918

fbshipit-source-id: 2da9d020832264cef977391dc2fd8d1e2677d159
2017-09-17 20:15:51 -07:00
Junjie Bai
86a9a06878 HTTPMessage in Python 3 does not have getheader
Summary: get and getheader are the same in Python 2

Reviewed By: akyrola

Differential Revision: D5836486

fbshipit-source-id: 3bacfccc872c44741d7f26c68ba967093fce45c2
2017-09-14 13:59:06 -07:00
Aaron Markham
784ba07bf3 updated downloader to use s3 url without a redirect via the vanity url
Summary:
Model downloader was broken after the move on s3 to the vanity url, download.caffe2.ai. Using this as the url base hits a redirect, and will result in the script throwing a 403 error.  Rather than upgrading to urllib2 or putting in a bunch of code to handle a redirect on urllib, we can just use the non-vanity base url.
Closes https://github.com/caffe2/caffe2/pull/1020

Reviewed By: Yangqing

Differential Revision: D5568686

Pulled By: aaronmarkham

fbshipit-source-id: d88a6b3e1b7955835fc03b036dc54dec48316e7f
2017-08-09 12:25:30 -07:00
Jun Luan
95f123a83e fix download progress bar's percentage exceed 100%
Summary:
downloaded_size need to be added with the length of returned data_chunk.
When the last block's size less than chunk, the percentage should exceed 100%
Closes https://github.com/caffe2/caffe2/pull/329

Differential Revision: D4922227

Pulled By: Yangqing

fbshipit-source-id: 7d05d9bbf2dad0a9d330be96b60e658908185a46
2017-04-20 10:41:06 -07:00
Bram Wasti
04bd41a4f2 Downloader fix
Summary:
This fixes some bugs in the downloader.  TODO: fix the URL
Closes https://github.com/caffe2/caffe2/pull/255

Reviewed By: Yangqing

Differential Revision: D4851555

Pulled By: bwasti

fbshipit-source-id: 56d01617ccaddcd40b0fb8e4be137cb4c7a52e91
2017-04-07 10:16:58 -07:00
Aaron Markham
58f7f2b441 doxygen python block added
Summary: Closes https://github.com/caffe2/caffe2/pull/226

Differential Revision: D4793550

Pulled By: JoelMarcey

fbshipit-source-id: cc33e58186304fa8dcac2ee9115dcc271d785b1e
2017-03-29 06:46:16 -07:00
Bram Wasti
396ebb0546 exec_net --> predict_net
Summary: Change the naming convention back for maintainability.

Reviewed By: Yangqing

Differential Revision: D4741875

fbshipit-source-id: 044051e772383e81812ae7064a921e97d63615dc
2017-03-23 16:31:49 -07:00
Bram Wasti
c7ed091633 Added model downloader
Summary: Closes https://github.com/caffe2/caffe2/pull/156

Reviewed By: Yangqing

Differential Revision: D4574588

Pulled By: bwasti

fbshipit-source-id: a0f2da0b13358157c7d7322257a9c4f1c61aae12
2017-02-22 12:47:15 -08:00