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

Run tests in parallel #2040

Merged
merged 38 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3d858ac
Run tests in parallel
GateBuilder Jun 10, 2020
2aa86ca
Try with 4 cores
GateBuilder Jun 10, 2020
1f4ca90
Rename math to math_utils
GateBuilder Jun 10, 2020
f536b2f
Fix the paths
GateBuilder Jun 10, 2020
c022963
Fix the import
GateBuilder Jun 10, 2020
37bcd9a
Fix import in examples
GateBuilder Jun 10, 2020
61425b3
Fix api docs
GateBuilder Jun 10, 2020
be0494b
Fix docs
GateBuilder Jun 10, 2020
82a5410
Merge branch 'master' into run_tests_parallel
GateBuilder Jun 10, 2020
99bde04
Remove log.debug from data_set.py
GateBuilder Jun 11, 2020
f0e9900
Remove one more log from data_set.py
GateBuilder Jun 11, 2020
3b5e95c
Merge branch 'master' into run_tests_parallel
jenshnielsen Jun 12, 2020
1fbd772
Fix newly emerged location errors
GateBuilder Jun 15, 2020
b6f560a
Fix lonf lines
GateBuilder Jun 15, 2020
4b1c8cb
Try with load option and fix 2 workers
GateBuilder Jun 15, 2020
40559d2
Merge branch 'master' into run_tests_parallel
jenshnielsen Jun 15, 2020
b16fc56
try loadfile with 2 cores fixed
GateBuilder Jun 15, 2020
95f001c
Merge branch 'run_tests_parallel' of github.com:GateBuilder/Qcodes in…
GateBuilder Jun 15, 2020
82caccb
Use load
GateBuilder Jun 15, 2020
66d6b0e
Skip the test only in win
GateBuilder Jun 15, 2020
2c89c53
use loadfile
GateBuilder Jun 15, 2020
d733061
Use markers to select serial runs
GateBuilder Jun 16, 2020
4475fa5
Fix conftest
GateBuilder Jun 16, 2020
9866e6e
Try simple markers
GateBuilder Jun 16, 2020
412c477
Fix syntax
GateBuilder Jun 16, 2020
797c815
Remove brackets
GateBuilder Jun 16, 2020
29f3926
Separate serial in linux
GateBuilder Jun 17, 2020
692c0c0
Separate in travis
GateBuilder Jun 17, 2020
b09f874
add missing newline
jenshnielsen Jun 17, 2020
7c9b7ee
Connect tests in pipelines
GateBuilder Jun 17, 2020
491344e
Add a serial test
GateBuilder Jun 17, 2020
857bb89
Merge branch 'run_tests_parallel' of github.com:GateBuilder/Qcodes in…
GateBuilder Jun 17, 2020
2ff51f8
Rename code cov results for serial and parallel
GateBuilder Jun 17, 2020
736fae0
Add changelog
GateBuilder Jun 17, 2020
a8e974f
Make underline longer
GateBuilder Jun 17, 2020
dca01f8
Append serial cov to parallel
GateBuilder Jun 18, 2020
d5182ae
Appen in travis
GateBuilder Jun 18, 2020
c202468
Merge branch 'master' into run_tests_parallel
jenshnielsen Jun 18, 2020
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ script:
pip uninstall -y qcodes
pip install .
- cd qcodes
- py.test --cov=qcodes --cov-report xml --cov-config=.coveragerc
- py.test -m "not serial" --cov=qcodes --cov-report xml --cov-config=.coveragerc
- py.test -n 1 -m serial --cov-append --cov=qcodes --cov-report xml --cov-config=.coveragerc
- cd ..
- mypy qcodes
# check that line endings are correct avoiding mixed windows/unix style line endings
Expand Down
6 changes: 4 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@ jobs:
- bash: |
source activate qcodes &&
cd qcodes &&
pytest --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc
pytest -m "not serial" --junitxml=test-parallel-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc &&
pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov-append --cov=qcodes --cov-report=xml --cov-config=.coveragerc
displayName: "Pytest on Windows"
condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Windows_NT' ))
- bash: |
source activate qcodes &&
cd qcodes &&
xvfb-run --server-args="-screen 0 1024x768x24" \
pytest --junitxml=test-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc
pytest -m "not serial" --junitxml=test-parallel-results.xml --cov=qcodes --cov-report=xml --cov-config=.coveragerc &&
pytest -n 1 -m serial --junitxml=test-serial-results.xml --cov-append --cov=qcodes --cov-report=xml --cov-config=.coveragerc
displayName: "Pytest on Linux"
condition: and(succeededOrFailed(), eq( variables['Agent.OS'], 'Linux' ))
- task: PublishTestResults@2
Expand Down
2 changes: 1 addition & 1 deletion docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ QCoDeS API
instrument/index
parameters/index
logger/index
math/index
math_utils/index
monitor/index
station
utils/index
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
qcodes.math.field_vector
------------------------

.. automodule:: qcodes.math.field_vector
.. automodule:: qcodes.math_utils.field_vector
:members:
6 changes: 3 additions & 3 deletions docs/api/math/index.rst → docs/api/math_utils/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ qcodes.math

.. autosummary::

qcodes.math
qcodes.math.field_vector
qcodes.math_utils
qcodes.math_utils.field_vector


.. automodule:: qcodes.math
.. automodule:: qcodes.math_utils


.. toctree::
Expand Down
7 changes: 7 additions & 0 deletions docs/changes/0.16.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Changelog for QCoDeS 0.16.0 (not released yet)
==============================================

Breaking Changes:
_________________

* ``math`` has been renamed as ``math_utils`` (#2040).
1 change: 1 addition & 0 deletions docs/changes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Changelogs
0.13.0 <0.13.0>
0.14.0 <0.14.0>
0.15.0a1 <0.15.0a1>
0.16.0 <0.16.0>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"import matplotlib.pyplot as plt \n",
"\n",
"from qcodes.instrument_drivers.american_magnetics.AMI430 import AMI430, AMI430_3D\n",
"from qcodes.math.field_vector import FieldVector"
"from qcodes.math_utils.field_vector import FieldVector"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.7.5"
},
"nbsphinx": {
"execute": "never"
Expand Down
8 changes: 7 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[pytest]
junit_family=legacy
junit_family=legacy

addopts =
-n 2
--dist=loadfile

markers = serial
3 changes: 0 additions & 3 deletions qcodes/dataset/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ def _exhaust_queue(queue: Queue) -> List:
def _call_callback_on_queue_data(self) -> None:
result_list = self._exhaust_queue(self.data_queue)
self.callback(result_list, self._data_set_len, self.state)
self.log.debug(f"{self.callback} called with "
f"result_list: {result_list}.")

def _loop(self) -> None:
while True:
Expand All @@ -192,7 +190,6 @@ def _loop(self) -> None:
break

def done_callback(self) -> None:
self.log.debug("Done callback")
self._call_callback_on_queue_data()

def schedule_stop(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion qcodes/instrument_drivers/american_magnetics/AMI430.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from qcodes import Instrument, IPInstrument, InstrumentChannel
from qcodes.utils.deprecate import deprecate
from qcodes.math.field_vector import FieldVector
from qcodes.math_utils.field_vector import FieldVector
from qcodes.utils.validators import Bool, Numbers, Ints, Anything

log = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion qcodes/instrument_drivers/oxford/MercuryiPS_VISA.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from qcodes.instrument.channel import InstrumentChannel
from qcodes.instrument.visa import VisaInstrument
from qcodes.math.field_vector import FieldVector
from qcodes.math_utils.field_vector import FieldVector

log = logging.getLogger(__name__)
visalog = logging.getLogger('qcodes.instrument.visa')
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion qcodes/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def disable_telemetry():
finally:
qc.config.telemetry.enabled = original_state


@pytest.fixture(scope="session", autouse=True)
def disable_config_subscriber():
"""
We do not want the tests to send generate subscription events unless specifically
enabled in the test. So disable any default subscriber defined
enabled in the test. So disable any default subscriber defined.
"""

original_state = qc.config.subscription.default_subscribers
Expand Down
1 change: 1 addition & 0 deletions qcodes/tests/dataset/test_measurement_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ def collect_x_vals(results, length, state):
assert collected_x_vals == given_x_vals


@pytest.mark.serial
@pytest.mark.flaky(reruns=5)
@settings(deadline=None, max_examples=25)
@given(N=hst.integers(min_value=2000, max_value=3000))
Expand Down
1 change: 1 addition & 0 deletions qcodes/tests/dataset/test_subscribing.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def subscriber(results: List[Tuple[VALUE]], length: int,
return subscriber


@pytest.mark.serial
def test_basic_subscription(dataset, basic_subscriber):
xparam = ParamSpecBase(name='x',
paramtype='numeric',
Expand Down
2 changes: 1 addition & 1 deletion qcodes/tests/drivers/test_MercuryiPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from qcodes.instrument_drivers.oxford.MercuryiPS_VISA import MercuryiPS
import qcodes.instrument.sims as sims
from qcodes.math.field_vector import FieldVector
from qcodes.math_utils.field_vector import FieldVector

visalib = sims.__file__.replace('__init__.py', 'MercuryiPS.yaml@sim')

Expand Down
2 changes: 1 addition & 1 deletion qcodes/tests/drivers/test_ami430.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from qcodes.instrument_drivers.american_magnetics.AMI430 import AMI430_3D, \
AMI430Warning
from qcodes.instrument.ip_to_visa import AMI430_VISA
from qcodes.math.field_vector import FieldVector
from qcodes.math_utils.field_vector import FieldVector
from qcodes.utils.types import numpy_concrete_ints, numpy_concrete_floats, \
numpy_non_concrete_ints_instantiable, \
numpy_non_concrete_floats_instantiable
Expand Down
16 changes: 13 additions & 3 deletions qcodes/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pickle
import logging

from qcodes.data.location import FormatLocation
from qcodes.data.data_array import DataArray
from qcodes.data.io import DiskIO
from qcodes.data.data_set import load_data, new_data, DataSet
Expand Down Expand Up @@ -446,12 +447,18 @@ def test_write_copy(self):
def test_pickle_dataset(self):
# Test pickling of DataSet object
# If the data_manager is set to None, then the object should pickle.
m = DataSet2D()
loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}'
rcd = {'name': 'test_pickle_dataset'}
loc_provider = FormatLocation(fmt=loc_fmt, record=rcd)
m = DataSet2D(location=loc_provider)
pickle.dumps(m)

def test_default_parameter(self):
loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}'
rcd = {'name': 'test_default_parameter'}
loc_provider = FormatLocation(fmt=loc_fmt, record=rcd)
# Test whether the default_array function works
m = DataSet2D()
m = DataSet2D(location=loc_provider)

# test we can run with default arguments
name = m.default_parameter_name()
Expand Down Expand Up @@ -560,7 +567,10 @@ def test_complete(self):
self.assertEqual(log_index, len(logs), logs)

def test_remove_array(self):
m = DataSet2D()
loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}'
rcd = {'name': 'test_remove_array'}
loc_provider = FormatLocation(fmt=loc_fmt, record=rcd)
m = DataSet2D(location=loc_provider)
m.remove_array('z')
_ = m.__repr__()
self.assertFalse('z' in m.arrays)
2 changes: 1 addition & 1 deletion qcodes/tests/test_field_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from hypothesis.strategies import floats
from hypothesis.strategies import tuples

from qcodes.math.field_vector import FieldVector
from qcodes.math_utils.field_vector import FieldVector
from qcodes.utils.helpers import NumpyJSONEncoder

random_coordinates = {
Expand Down
6 changes: 5 additions & 1 deletion qcodes/tests/test_format.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import TestCase
import os

from qcodes.data.location import FormatLocation
from qcodes.data.format import Formatter
from qcodes.data.gnuplot_format import GNUPlotFormat

Expand All @@ -24,7 +25,10 @@ def tearDown(self):

def test_overridable_methods(self):
formatter = Formatter()
data = DataSet1D()
loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}'
rcd = {'name': 'test_overridable_methods'}
loc_provider = FormatLocation(fmt=loc_fmt, record=rcd)
data = DataSet1D(location=loc_provider)

with self.assertRaises(NotImplementedError):
formatter.write(data, data.io, data.location)
Expand Down
21 changes: 15 additions & 6 deletions qcodes/tests/test_measure.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import TestCase
from datetime import datetime

from qcodes.data.location import FormatLocation
from qcodes.instrument.parameter import Parameter
from qcodes.measure import Measure

Expand Down Expand Up @@ -55,7 +56,10 @@ def setUp(self):


def test_metadata(self):
c = Measure(self.p1).run()
loc_fmt = 'data/{date}/#{counter}_{name}_{date}_{time}'
rcd = {'name': 'test_metadata'}
loc_provider = FormatLocation(fmt=loc_fmt, record=rcd)
c = Measure(self.p1).run(location=loc_provider)
self.assertEqual(c.metadata['arrays']['this']['unit'], 'this unit')
self.assertEqual(c.metadata['arrays']['this']['name'], 'this')
self.assertEqual(c.metadata['arrays']['this']['label'], 'this label')
Expand All @@ -70,9 +74,14 @@ def test_metadata(self):
self.assertEqual(c.metadata['arrays']['that']['shape'], (5,))
assert_array_equal(c.that.ndarray, np.ones(5))

self.assertEqual(c.metadata['arrays']['this_setpoint_set']['unit'], 'this setpointunit')
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['name'], 'this_setpoint')
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['label'], 'this setpoint')
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['is_setpoint'], True)
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['shape'], (5,))
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['unit'],
'this setpointunit')
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['name'],
'this_setpoint')
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['label'],
'this setpoint')
self.assertEqual(c.metadata['arrays']['this_setpoint_set']
['is_setpoint'], True)
self.assertEqual(c.metadata['arrays']['this_setpoint_set']['shape'],
(5,))
assert_array_equal(c.this_setpoint_set.ndarray, np.linspace(5, 9, 5))
1 change: 1 addition & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ coverage!=4.5.0
pytest-cov
pytest
pytest-rerunfailures
pytest-xdist
codacy-coverage
hypothesis<5.6.0 # large number of warnings due to change in 5.6.0 https://hypothesis.readthedocs.io/en/latest/changes.html#v5-6-0
mypy==0.780
Expand Down