Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit e5fc67a

Browse files
committed
Show combined deprecation warnings on travis
1 parent d4e53c5 commit e5fc67a

File tree

3 files changed

+225
-31
lines changed

3 files changed

+225
-31
lines changed

.travis.yml

Lines changed: 121 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -130,37 +130,61 @@ jobs:
130130
if: tag IS blank
131131
workspaces:
132132
create:
133-
name: aqua1
134-
paths: aqua1.dat
133+
name: aqua137
134+
paths:
135+
- aqua1.dat
136+
- aqua137.dep
135137
before_script:
136138
- pip install cvxopt
137139
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
138-
script: stestr --test-path test/aqua run --blacklist-file selection.txt && coverage3 combine && mv .coverage aqua1.dat
140+
script:
141+
- stestr --test-path test/aqua run --blacklist-file selection.txt 2>&1 | tee out.txt
142+
- coverage3 combine
143+
- mv .coverage aqua1.dat
144+
- python tools/extract_deprecation.py -file out.txt -output aqua137.dep
139145
- name: "Test Aqua 1 Python 3.8"
140146
<<: *stage_test_aqua
141147
if: tag IS blank
148+
workspaces:
149+
create:
150+
name: aqua138
151+
paths: aqua138.dep
142152
python: 3.8
143153
before_script:
144154
- pip install cvxopt
145-
script: stestr --test-path test/aqua run --blacklist-file selection.txt
155+
script:
156+
- stestr --test-path test/aqua run --blacklist-file selection.txt 2>&1 | tee out.txt
157+
- python tools/extract_deprecation.py -file out.txt -output aqua138.dep
146158
- name: "Test Aqua 2 Python 3.7"
147159
<<: *stage_test_aqua
148160
if: tag IS blank
149161
workspaces:
150162
create:
151-
name: aqua2
152-
paths: aqua2.dat
163+
name: aqua237
164+
paths:
165+
- aqua2.dat
166+
- aqua237.dep
153167
before_script:
154168
- pip install cvxopt
155169
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
156-
script: stestr --test-path test/aqua run --whitelist-file selection.txt && coverage3 combine && mv .coverage aqua2.dat
170+
script:
171+
- stestr --test-path test/aqua run --whitelist-file selection.txt 2>&1 | tee out.txt
172+
- coverage3 combine
173+
- mv .coverage aqua2.dat
174+
- python tools/extract_deprecation.py -file out.txt -output aqua237.dep
157175
- name: "Test Aqua 2 Python 3.8"
158176
<<: *stage_test_aqua
159177
if: tag IS blank
178+
workspaces:
179+
create:
180+
name: aqua238
181+
paths: aqua238.dep
160182
python: 3.8
161183
before_script:
162184
- pip install cvxopt
163-
script: stestr --test-path test/aqua run --whitelist-file selection.txt
185+
script:
186+
- stestr --test-path test/aqua run --whitelist-file selection.txt 2>&1 | tee out.txt
187+
- python tools/extract_deprecation.py -file out.txt -output aqua238.dep
164188
- name: "Test Chemistry Python 3.7"
165189
<<: *stage_dependencies
166190
if: tag IS blank
@@ -169,8 +193,10 @@ jobs:
169193
- OPENBLAS_NUM_THREADS=1
170194
workspaces:
171195
create:
172-
name: chemistry
173-
paths: chemistry.dat
196+
name: chemistry37
197+
paths:
198+
- chemistry.dat
199+
- chemistry37.dep
174200
install:
175201
# install gaussian dependency libgfortran 5
176202
- sudo apt-get -y update
@@ -179,10 +205,18 @@ jobs:
179205
- pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off
180206
before_script:
181207
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
182-
script: stestr --test-path test/chemistry run && coverage3 combine && mv .coverage chemistry.dat
208+
script:
209+
- stestr --test-path test/chemistry run 2>&1 | tee out.txt
210+
- coverage3 combine
211+
- mv .coverage chemistry.dat
212+
- python tools/extract_deprecation.py -file out.txt -output chemistry37.dep
183213
- name: "Test Chemistry Python 3.8"
184214
<<: *stage_dependencies
185215
if: tag IS blank
216+
workspaces:
217+
create:
218+
name: chemistry38
219+
paths: chemistry38.dep
186220
python: 3.8
187221
env: OPENBLAS_NUM_THREADS=1
188222
install:
@@ -191,70 +225,127 @@ jobs:
191225
- sudo apt-get -y install libgfortran5
192226
# Installing pyquante2 master branch...
193227
- pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off
194-
script: stestr --test-path test/chemistry run
228+
script:
229+
- stestr --test-path test/chemistry run 2>&1 | tee out.txt
230+
- python tools/extract_deprecation.py -file out.txt -output chemistry38.dep
195231
- name: "Test Finance Python 3.7"
196232
<<: *stage_dependencies
197233
if: tag IS blank
198234
workspaces:
199235
create:
200-
name: finance
201-
paths: finance.dat
236+
name: finance37
237+
paths:
238+
- finance.dat
239+
- finance37.dep
202240
before_script:
203241
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
204-
script: stestr --test-path test/finance run && coverage3 combine && mv .coverage finance.dat
242+
script:
243+
- stestr --test-path test/finance run 2>&1 | tee out.txt
244+
- coverage3 combine
245+
- mv .coverage finance.dat
246+
- python tools/extract_deprecation.py -file out.txt -output finance37.dep
205247
- name: "Test Finance Python 3.8"
206248
<<: *stage_dependencies
207249
if: tag IS blank
250+
workspaces:
251+
create:
252+
name: finance38
253+
paths: finance38.dep
208254
python: 3.8
209-
script: stestr --test-path test/finance run
255+
script:
256+
- stestr --test-path test/finance run 2>&1 | tee out.txt
257+
- python tools/extract_deprecation.py -file out.txt -output finance38.dep
210258
- name: "Test Machine Learning Python 3.7"
211259
<<: *stage_dependencies
212260
if: tag IS blank
213261
workspaces:
214262
create:
215-
name: ml
216-
paths: ml.dat
263+
name: ml37
264+
paths:
265+
- ml.dat
266+
- ml37.dep
217267
before_script:
218268
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
219-
script: stestr --test-path test/ml run && coverage3 combine && mv .coverage ml.dat
269+
script:
270+
- stestr --test-path test/ml run 2>&1 | tee out.txt
271+
- coverage3 combine
272+
- mv .coverage ml.dat
273+
- python tools/extract_deprecation.py -file out.txt -output ml37.dep
220274
- name: "Test Machine Learning Python 3.8"
221275
<<: *stage_dependencies
222276
if: tag IS blank
277+
workspaces:
278+
create:
279+
name: ml38
280+
paths: ml38.dep
223281
python: 3.8
224-
script: stestr --test-path test/ml run
282+
script:
283+
- stestr --test-path test/ml run 2>&1 | tee out.txt
284+
- python tools/extract_deprecation.py -file out.txt -output ml38.dep
225285
- name: "Test Optimization Python 3.7"
226286
<<: *stage_dependencies
227287
if: tag IS blank
228288
workspaces:
229289
create:
230-
name: optimization
231-
paths: optimization.dat
290+
name: optimization37
291+
paths:
292+
- optimization.dat
293+
- optimization37.dep
232294
before_script:
233295
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
234-
script: stestr --test-path test/optimization run && coverage3 combine && mv .coverage optimization.dat
296+
script:
297+
- stestr --test-path test/optimization run 2>&1 | tee out.txt
298+
- coverage3 combine
299+
- mv .coverage optimization.dat
300+
- python tools/extract_deprecation.py -file out.txt -output optimization37.dep
235301
- name: "Test Optimization Python 3.8"
236302
<<: *stage_dependencies
237303
if: tag IS blank
304+
workspaces:
305+
create:
306+
name: optimization38
307+
paths: optimization38.dep
238308
python: 3.8
239-
script: stestr --test-path test/optimization run
309+
script:
310+
- stestr --test-path test/optimization run 2>&1 | tee out.txt
311+
- python tools/extract_deprecation.py -file out.txt -output optimization38.dep
240312
- name: "Run pip check"
241313
<<: *stage_dependencies
242314
if: tag IS blank
243315
script:
244316
- pip install cvxopt
245317
- pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off
246318
- pip check
319+
- stage: Deprecation Messages
320+
name: "Print deprecation messages"
321+
if: tag IS blank
322+
workspaces:
323+
use:
324+
- aqua137
325+
- aqua138
326+
- aqua237
327+
- aqua238
328+
- chemistry37
329+
- chemistry38
330+
- finance37
331+
- finance38
332+
- ml37
333+
- ml38
334+
- optimization37
335+
- optimization38
336+
script:
337+
- sort -f -u aqua137.dep aqua138.dep aqua237.dep aqua238.dep chemistry37.dep chemistry38.dep finance37.dep finance38.dep ml37.dep ml38.dep optimization37.dep optimization38.dep || true
247338
- stage: Coverage
248339
name: "Combine all coverages and upload to Coveralls"
249340
if: tag IS blank
250341
workspaces:
251342
use:
252-
- aqua1
253-
- aqua2
254-
- chemistry
255-
- finance
256-
- ml
257-
- optimization
343+
- aqua137
344+
- aqua237
345+
- chemistry37
346+
- finance37
347+
- ml37
348+
- optimization37
258349
install:
259350
- pip install -U coverage coveralls diff-cover
260351
script:

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ddt>=1.2.0
44
pycodestyle
55
pylint>=2.4.3
66
pylintfileheader>=0.0.2
7-
Sphinx>=1.8.3
7+
Sphinx>=1.8.3,<3.0
88
sphinx-rtd-theme>=0.4.0
99
sphinx-tabs>=1.1.11
1010
sphinx-autodoc-typehints

tools/extract_deprecation.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This code is part of Qiskit.
4+
#
5+
# (C) Copyright IBM 2020.
6+
#
7+
# This code is licensed under the Apache License, Version 2.0. You may
8+
# obtain a copy of this license in the LICENSE.txt file in the root directory
9+
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
10+
#
11+
# Any modifications or derivative works of this code must retain this
12+
# copyright notice, and modified files need to carry a notice indicating
13+
# that they have been altered from the originals.
14+
15+
""" Extract deprecation messages from input """
16+
17+
import sys
18+
import os
19+
import argparse
20+
21+
22+
class DeprecationExtractor:
23+
""" Extract deprecation messages """
24+
25+
def __init__(self, in_file: str, out_file: str) -> None:
26+
self._input_filename = in_file
27+
self._output_filename = out_file
28+
self._messages = None
29+
30+
def extract_messages(self) -> bool:
31+
"""
32+
extract deprecation
33+
Returns:
34+
bool: if messages were found
35+
"""
36+
37+
self._messages = None
38+
messages = set()
39+
with open(self._input_filename, 'rt', encoding="utf8", errors='ignore') as file:
40+
for line in file:
41+
if line.find('DeprecationWarning:') > 0:
42+
messages.add(line.strip())
43+
44+
if messages:
45+
self._messages = sorted(messages)
46+
return True
47+
48+
return False
49+
50+
def save_to_output(self, force_create: bool) -> bool:
51+
"""
52+
save messages to file if they exist
53+
Args:
54+
force_create: create file even if it is empty
55+
Returns:
56+
bool: if messages were saved
57+
"""
58+
if self._output_filename:
59+
# create file even if it is empty
60+
if self._messages or force_create:
61+
with open(self._output_filename, 'w') as file:
62+
if self._messages:
63+
file.write('\n'.join(self._messages))
64+
return True
65+
66+
return False
67+
68+
def print_messages(self) -> None:
69+
""" print messages """
70+
if self._messages:
71+
print('---------------------')
72+
print('Deprecation Messages:')
73+
print('---------------------')
74+
for line in self._messages:
75+
print(line)
76+
77+
78+
def _check_file(path) -> str:
79+
if not os.path.isfile(path):
80+
raise argparse.ArgumentTypeError("file: '{}' doesn't exist.".format(path))
81+
82+
return path
83+
84+
85+
if __name__ == '__main__':
86+
PARSER = argparse.ArgumentParser(description='Qiskit Extract Deprecation Messages Tool')
87+
PARSER.add_argument('-file',
88+
type=_check_file,
89+
required=True,
90+
metavar='file',
91+
help='Input file.')
92+
PARSER.add_argument('-output',
93+
metavar='output',
94+
help='Output file.')
95+
96+
ARGS = PARSER.parse_args()
97+
98+
OBJ = DeprecationExtractor(ARGS.file, ARGS.output)
99+
OBJ.extract_messages()
100+
OBJ.save_to_output(True)
101+
OBJ.print_messages()
102+
103+
sys.exit(os.EX_OK)

0 commit comments

Comments
 (0)