Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 121 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,37 +130,61 @@ jobs:
if: tag IS blank
workspaces:
create:
name: aqua1
paths: aqua1.dat
name: aqua137
paths:
- aqua1.dat
- aqua137.dep
before_script:
- pip install cvxopt
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/aqua run --blacklist-file selection.txt && coverage3 combine && mv .coverage aqua1.dat
script:
- stestr --test-path test/aqua run --blacklist-file selection.txt 2>&1 | tee out.txt
- coverage3 combine
- mv .coverage aqua1.dat
- python tools/extract_deprecation.py -file out.txt -output aqua137.dep
- name: "Test Aqua 1 Python 3.8"
<<: *stage_test_aqua
if: tag IS blank
workspaces:
create:
name: aqua138
paths: aqua138.dep
python: 3.8
before_script:
- pip install cvxopt
script: stestr --test-path test/aqua run --blacklist-file selection.txt
script:
- stestr --test-path test/aqua run --blacklist-file selection.txt 2>&1 | tee out.txt
- python tools/extract_deprecation.py -file out.txt -output aqua138.dep
- name: "Test Aqua 2 Python 3.7"
<<: *stage_test_aqua
if: tag IS blank
workspaces:
create:
name: aqua2
paths: aqua2.dat
name: aqua237
paths:
- aqua2.dat
- aqua237.dep
before_script:
- pip install cvxopt
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/aqua run --whitelist-file selection.txt && coverage3 combine && mv .coverage aqua2.dat
script:
- stestr --test-path test/aqua run --whitelist-file selection.txt 2>&1 | tee out.txt
- coverage3 combine
- mv .coverage aqua2.dat
- python tools/extract_deprecation.py -file out.txt -output aqua237.dep
- name: "Test Aqua 2 Python 3.8"
<<: *stage_test_aqua
if: tag IS blank
workspaces:
create:
name: aqua238
paths: aqua238.dep
python: 3.8
before_script:
- pip install cvxopt
script: stestr --test-path test/aqua run --whitelist-file selection.txt
script:
- stestr --test-path test/aqua run --whitelist-file selection.txt 2>&1 | tee out.txt
- python tools/extract_deprecation.py -file out.txt -output aqua238.dep
- name: "Test Chemistry Python 3.7"
<<: *stage_dependencies
if: tag IS blank
Expand All @@ -169,8 +193,10 @@ jobs:
- OPENBLAS_NUM_THREADS=1
workspaces:
create:
name: chemistry
paths: chemistry.dat
name: chemistry37
paths:
- chemistry.dat
- chemistry37.dep
install:
# install gaussian dependency libgfortran 5
- sudo apt-get -y update
Expand All @@ -179,10 +205,18 @@ jobs:
- pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off
before_script:
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/chemistry run && coverage3 combine && mv .coverage chemistry.dat
script:
- stestr --test-path test/chemistry run 2>&1 | tee out.txt
- coverage3 combine
- mv .coverage chemistry.dat
- python tools/extract_deprecation.py -file out.txt -output chemistry37.dep
- name: "Test Chemistry Python 3.8"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: chemistry38
paths: chemistry38.dep
python: 3.8
env: OPENBLAS_NUM_THREADS=1
install:
Expand All @@ -191,70 +225,127 @@ jobs:
- sudo apt-get -y install libgfortran5
# Installing pyquante2 master branch...
- pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off
script: stestr --test-path test/chemistry run
script:
- stestr --test-path test/chemistry run 2>&1 | tee out.txt
- python tools/extract_deprecation.py -file out.txt -output chemistry38.dep
- name: "Test Finance Python 3.7"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: finance
paths: finance.dat
name: finance37
paths:
- finance.dat
- finance37.dep
before_script:
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/finance run && coverage3 combine && mv .coverage finance.dat
script:
- stestr --test-path test/finance run 2>&1 | tee out.txt
- coverage3 combine
- mv .coverage finance.dat
- python tools/extract_deprecation.py -file out.txt -output finance37.dep
- name: "Test Finance Python 3.8"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: finance38
paths: finance38.dep
python: 3.8
script: stestr --test-path test/finance run
script:
- stestr --test-path test/finance run 2>&1 | tee out.txt
- python tools/extract_deprecation.py -file out.txt -output finance38.dep
- name: "Test Machine Learning Python 3.7"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: ml
paths: ml.dat
name: ml37
paths:
- ml.dat
- ml37.dep
before_script:
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/ml run && coverage3 combine && mv .coverage ml.dat
script:
- stestr --test-path test/ml run 2>&1 | tee out.txt
- coverage3 combine
- mv .coverage ml.dat
- python tools/extract_deprecation.py -file out.txt -output ml37.dep
- name: "Test Machine Learning Python 3.8"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: ml38
paths: ml38.dep
python: 3.8
script: stestr --test-path test/ml run
script:
- stestr --test-path test/ml run 2>&1 | tee out.txt
- python tools/extract_deprecation.py -file out.txt -output ml38.dep
- name: "Test Optimization Python 3.7"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: optimization
paths: optimization.dat
name: optimization37
paths:
- optimization.dat
- optimization37.dep
before_script:
- export PYTHON="coverage3 run --source qiskit/aqua,qiskit/chemistry,qiskit/finance,qiskit/ml,qiskit/optimization --omit */gauopen/* --parallel-mode"
script: stestr --test-path test/optimization run && coverage3 combine && mv .coverage optimization.dat
script:
- stestr --test-path test/optimization run 2>&1 | tee out.txt
- coverage3 combine
- mv .coverage optimization.dat
- python tools/extract_deprecation.py -file out.txt -output optimization37.dep
- name: "Test Optimization Python 3.8"
<<: *stage_dependencies
if: tag IS blank
workspaces:
create:
name: optimization38
paths: optimization38.dep
python: 3.8
script: stestr --test-path test/optimization run
script:
- stestr --test-path test/optimization run 2>&1 | tee out.txt
- python tools/extract_deprecation.py -file out.txt -output optimization38.dep
- name: "Run pip check"
<<: *stage_dependencies
if: tag IS blank
script:
- pip install cvxopt
- pip install https://github.com/rpmuller/pyquante2/archive/master.zip --progress-bar off
- pip check
- stage: Deprecation Messages
name: "Print deprecation messages"
if: tag IS blank
workspaces:
use:
- aqua137
- aqua138
- aqua237
- aqua238
- chemistry37
- chemistry38
- finance37
- finance38
- ml37
- ml38
- optimization37
- optimization38
script:
- 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
- stage: Coverage
name: "Combine all coverages and upload to Coveralls"
if: tag IS blank
workspaces:
use:
- aqua1
- aqua2
- chemistry
- finance
- ml
- optimization
- aqua137
- aqua237
- chemistry37
- finance37
- ml37
- optimization37
install:
- pip install -U coverage coveralls diff-cover
script:
Expand Down
2 changes: 1 addition & 1 deletion qiskit/aqua/algorithms/eigen_solvers/numpy_eigen_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _run(self):
Returns:
dict: Dictionary of results
Raises:
AquaError: if no operator has been provided
AquaError: if no operator has been provided
"""
if self._operator is None:
raise AquaError("Operator was never provided")
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ddt>=1.2.0
pycodestyle
pylint>=2.4.3
pylintfileheader>=0.0.2
Sphinx>=1.8.3
Sphinx>=1.8.3,<3.0
sphinx-rtd-theme>=0.4.0
sphinx-tabs>=1.1.11
sphinx-autodoc-typehints
Expand Down
103 changes: 103 additions & 0 deletions tools/extract_deprecation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-

# This code is part of Qiskit.
#
# (C) Copyright IBM 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

""" Extract deprecation messages from input """

import sys
import os
import argparse


class DeprecationExtractor:
""" Extract deprecation messages """

def __init__(self, in_file: str, out_file: str) -> None:
self._input_filename = in_file
self._output_filename = out_file
self._messages = None

def extract_messages(self) -> bool:
"""
extract deprecation
Returns:
bool: if messages were found
"""

self._messages = None
messages = set()
with open(self._input_filename, 'rt', encoding="utf8", errors='ignore') as file:
for line in file:
if line.find('DeprecationWarning:') > 0:
messages.add(line.strip())

if messages:
self._messages = sorted(messages)
return True

return False

def save_to_output(self, force_create: bool) -> bool:
"""
save messages to file if they exist
Args:
force_create: create file even if it is empty
Returns:
bool: if messages were saved
"""
if self._output_filename:
# create file even if it is empty
if self._messages or force_create:
with open(self._output_filename, 'w') as file:
if self._messages:
file.write('\n'.join(self._messages))
return True

return False

def print_messages(self) -> None:
""" print messages """
if self._messages:
print('---------------------')
print('Deprecation Messages:')
print('---------------------')
for line in self._messages:
print(line)


def _check_file(path) -> str:
if not os.path.isfile(path):
raise argparse.ArgumentTypeError("file: '{}' doesn't exist.".format(path))

return path


if __name__ == '__main__':
PARSER = argparse.ArgumentParser(description='Qiskit Extract Deprecation Messages Tool')
PARSER.add_argument('-file',
type=_check_file,
required=True,
metavar='file',
help='Input file.')
PARSER.add_argument('-output',
metavar='output',
help='Output file.')

ARGS = PARSER.parse_args()

OBJ = DeprecationExtractor(ARGS.file, ARGS.output)
OBJ.extract_messages()
OBJ.save_to_output(True)
OBJ.print_messages()

sys.exit(os.EX_OK)