Skip to content

Commit 680e598

Browse files
authored
Travis update (#292)
* Update Travis CI * Update versions of pylint, flake8, and mypy * Fix mypy error * Fix pylint error
1 parent e685cfe commit 680e598

File tree

21 files changed

+108
-46
lines changed

21 files changed

+108
-46
lines changed

.pylintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ disable=invalid-name,too-many-branches,too-many-statements,too-many-arguments,
7979
no-self-use, # (cannot ignore overridden methods)
8080
unused-wildcard-import, # (https://github.com/rogalski/astroid/commit/82c6ef644a2efb77217a23d9b8a6cfb5caffb4ba)
8181
duplicate-code, # (will be fixed in next release)
82+
import-outside-toplevel,
8283

8384

8485
[REPORTS]

.travis.yml

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sudo: required
1+
os: linux
22
language: python
33
dist: xenial # Required for Python 3.7
44
cache: pip
@@ -14,27 +14,15 @@ env:
1414
- TORCH_VER="1.3.0"
1515
- TORCH_VER="1.4.0"
1616

17-
matrix:
18-
fast_finish: true
19-
exclude:
20-
- python: "3.6"
21-
env: TORCH_VER="1.0.1"
22-
- python: "3.6"
23-
env: TORCH_VER="1.2.0"
24-
- python: "3.6"
25-
env: TORCH_VER="1.3.0"
26-
- python: "3.6"
27-
env: TORCH_VER="1.4.0"
28-
2917
install:
3018
- pip install --upgrade pip
3119
- pip install --progress-bar off torch==$TORCH_VER
3220
- pip install --progress-bar off .[extras]
3321
- if [[ $TORCH_VER == "1.4.0" ]]; then
34-
pip install pylint==2.3.1 flake8==3.7.7;
22+
pip install pylint==2.4.4 flake8==3.7.9;
3523
fi
3624
- if [[ $TORCH_VER != "1.0.1" ]]; then
37-
pip install mypy==0.720;
25+
pip install mypy==0.761;
3826
fi
3927
- pip install pytest
4028
- pip install coverage codecov
@@ -86,5 +74,16 @@ jobs:
8674
# Check for typos
8775
- sphinx-build -W -b spelling -d _build/doctrees . _build/spelling
8876

77+
fast_finish: true
78+
exclude:
79+
- python: "3.6"
80+
env: TORCH_VER="1.0.1"
81+
- python: "3.6"
82+
env: TORCH_VER="1.2.0"
83+
- python: "3.6"
84+
env: TORCH_VER="1.3.0"
85+
- python: "3.6"
86+
env: TORCH_VER="1.4.0"
87+
8988
notifications:
9089
email: false

examples/bert/data/download_glue_data.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,21 @@ def main(arguments) -> None:
129129
for task in tasks:
130130
if task == 'MRPC':
131131
import subprocess
132-
if not os.path.exists("data/MRPC"):
133-
subprocess.run("mkdir data/MRPC", shell=True)
134132
# pylint: disable=line-too-long
133+
if not os.path.exists("data/MRPC"):
134+
subprocess.run("mkdir data/MRPC", shell=True, check=False)
135135
subprocess.run(
136136
'wget -P data/MRPC/ https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_train.txt',
137-
shell=True)
137+
shell=True, check=False)
138138
subprocess.run(
139139
'wget -P data/MRPC/ https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_test.txt',
140-
shell=True)
140+
shell=True, check=False)
141141
# pylint: enable=line-too-long
142142
format_mrpc(args.data_dir, args.path_to_mrpc)
143-
subprocess.run('rm data/MRPC/msr_paraphrase_train.txt', shell=True)
144-
subprocess.run('rm data/MRPC/msr_paraphrase_test.txt', shell=True)
143+
subprocess.run('rm data/MRPC/msr_paraphrase_train.txt',
144+
shell=True, check=False)
145+
subprocess.run('rm data/MRPC/msr_paraphrase_test.txt',
146+
shell=True, check=False)
145147
elif task == 'diagnostic':
146148
download_diagnostic(args.data_dir)
147149
else:

examples/gpt-2/gpt2_generate_main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""
1616
import argparse
1717
import random
18+
import sys
1819

1920
import numpy as np
2021
import torch
@@ -114,7 +115,7 @@ def _get_helper(start_tokens):
114115
raw_text = input("Model input >>> ")
115116
except EOFError:
116117
print("EOF entered, quitting.")
117-
exit(0)
118+
sys.exit()
118119

119120
context_tokens = tokenizer.map_text_to_id(raw_text)
120121
context = torch.tensor(

examples/xlnet/xlnet_generation_main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"""
1616

1717
import argparse
18+
import sys
19+
1820
import torch
1921

2022
import texar.torch as tx
@@ -142,7 +144,7 @@ def sample(text: str, length: int = 100, n_samples=3, **kwargs):
142144
n_samples=batch_size)
143145
except EOFError:
144146
print("EOF entered, quitting.")
145-
exit(0)
147+
sys.exit()
146148
else:
147149
# Generate samples from scratch
148150
for _ in range(nsamples // batch_size):

stubs/torch/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ from .storage import _StorageBase
99
from .tensor import Tensor as TensorBase
1010
from .utils.hooks import RemovableHandle
1111

12+
from . import backends as backends
13+
from . import cuda as cuda
1214
from . import optim as optim
1315

1416

@@ -105,6 +107,7 @@ double = float64 = _float64()
105107
short = int16 = _int16()
106108
long = int64 = _int64()
107109
uint8 = _uint8()
110+
int8 = _int8()
108111
float = float32 = _float32()
109112
int = int32 = _int32()
110113

stubs/torch/backends/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import cudnn as cudnn
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
benchmark: bool = ...
2+
deterministic: bool = ...
3+
verbose: bool = ...

stubs/torch/cuda/__init__.pyi

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from typing import Optional, Tuple, Union
2+
import ctypes
3+
from .. import device as _device
4+
5+
def is_available() -> bool: ...
6+
def init() -> None: ...
7+
8+
class cudaStatus:
9+
SUCCESS: int
10+
ERROR_NOT_READY: int
11+
12+
class CudaError:
13+
def __init__(self, code: int) -> None: ...
14+
15+
class _CudaDeviceProperties:
16+
name: str
17+
major: int
18+
minor: int
19+
multi_processor_count: int
20+
total_memory: int
21+
is_integrated: int
22+
is_multi_gpu_board: int
23+
24+
_device_t = Union[_device, int]
25+
26+
def check_error(res: int) -> None: ...
27+
def device_count() -> int: ...
28+
def empty_cache() -> None: ...
29+
def synchronize(device: _device_t) -> None: ...
30+
def set_device(device: _device_t) -> None: ...
31+
def get_device_capability(device: Optional[_device_t]=...) -> Tuple[int, int]: ...
32+
def get_device_name(device: Optional[_device_t]=...) -> str: ...
33+
def get_device_properties(device: _device_t) -> _CudaDeviceProperties: ...
34+
def current_device() -> int: ...
35+
def memory_allocated(device: Optional[_device_t]=...) -> int: ...
36+
def max_memory_allocated(device: Optional[_device_t]=...) -> int: ...
37+
def reset_max_memory_allocated(device: Optional[_device_t]=...) -> None: ...
38+
def memory_cached(device: Optional[_device_t]=...) -> int: ...
39+
def max_memory_cached(device: Optional[_device_t]=...) -> int: ...
40+
def reset_max_memory_cached(device: Optional[_device_t]=...) -> None: ...
41+
def cudart() -> ctypes.CDLL: ...
42+
def find_cuda_windows_lib() -> Optional[ctypes.CDLL]: ...
43+
def set_rng_state(new_state): ...
44+
def get_rng_state(): ...
45+
46+
def manual_seed(seed: int): ...
47+
def manual_seed_all(seed: int): ...

texar/torch/data/data/data_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def __iter__(self) -> Iterator[Dict[str, RawExample]]:
179179
keys = list(self._sources.keys())
180180
iterator = zip(*[iter(source) for source in self._sources.values()])
181181
for values in iterator:
182-
yield {key: value for key, value in zip(keys, values)}
182+
yield dict(zip(keys, values))
183183

184184
def __len__(self) -> int:
185185
return min(len(source) for source in self._sources.values())

0 commit comments

Comments
 (0)