19 Commits

Author SHA1 Message Date
72c51c5744 dont try to stop the RST 2023-03-18 16:55:25 +01:00
1e203873c9 disable RPC thread where not needed 2023-03-18 16:44:01 +01:00
a80b568894 enable PYTHONFAULTHANDLER for segfault tracebacks 2023-03-18 11:48:03 +01:00
2edc68151d Merge branch 'gitlab-ci-update' into 'master'
ci: improved ci pipeline; added 3.6 to 3.11 tests

See merge request augustin_s/grum!6
2023-03-14 20:26:39 +00:00
aa03291e42 Merge branch 'tests' into 'master'
Tests

See merge request augustin_s/grum!7
2023-03-14 20:26:23 +00:00
5d97dd6224 added test report artifact 2023-03-14 11:52:03 +01:00
bed086f95f do not test the default 3.8 twice 2023-03-14 11:06:10 +01:00
aa79f1b0a1 removed the version check again 2023-03-14 10:58:31 +01:00
bbb6d6c00c lower the required version 2023-03-14 10:47:06 +01:00
c6f034f2d3 require PyQtWebEngine only for Python version were it exists 2023-03-14 10:42:34 +01:00
a624cf37a4 added some more versions 2023-03-14 09:40:32 +01:00
efd023ae3a a bit of formatting and naming 2023-03-14 09:35:44 +01:00
d65e97c9a7 neater 2023-02-10 12:31:42 +01:00
4fcc10f3da added possibility to extend data 2023-02-10 11:21:54 +01:00
c781601246 added set_data; refactored sync_item_and_plots 2023-02-10 10:10:12 +01:00
831b03a744 added data setter 2023-02-10 10:09:43 +01:00
b94294b579 fixed __dir__ 2023-02-10 10:09:22 +01:00
b14f6e68b4 allow tab completion for the exposed functions on the client side 2023-02-08 21:03:03 +01:00
7d169fdd53 ci: improved ci pipeline; added 3.9 and 3.10 tests 2023-01-28 17:29:56 +01:00
10 changed files with 105 additions and 68 deletions

View File

@@ -1,29 +1,62 @@
stages:
- Test
- Tests
- OptionalTests
.install-grum-test: &install-grum-test
- pip install pytest pytest-random-order pytest-cov
- pip install -e ./
- apt-get update
- apt-get install -y ffmpeg libnss3 libxcomposite1 libxtst6
tests:
stage: Test
stage: Tests
image: python:3.8
variables:
QT_QPA_PLATFORM: "offscreen"
XDG_RUNTIME_DIR: "/tmp/runtime-root"
PYTHONFAULTHANDLER: 1
script:
- pip install pytest pytest-random-order pytest-cov
- pip install -e ./
- pip install PyQtWebEngine
- apt-get update
- apt-get install -y ffmpeg libnss3 libxcomposite1 libxtst6
# - python -m unittest discover -f ./tests
# - coverage run --source=./grum -m unittest discover -f ./tests
- coverage run --source=./grum -m pytest ./tests
- *install-grum-test
- coverage run --source=./grum -m pytest ./tests --junitxml=report-junit.xml
- coverage report
- coverage xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
when: always
reports:
cobertura: coverage.xml
junit: report-junit.xml
tests-3.6:
stage: OptionalTests
image: python:3.6
needs: ["tests"]
allow_failure: true
variables:
QT_QPA_PLATFORM: "offscreen"
XDG_RUNTIME_DIR: "/tmp/runtime-root"
PYTHONFAULTHANDLER: 1
script:
- *install-grum-test
- pytest ./tests
tests-3.7:
extends: "tests-3.6"
image: python:3.7
#tests-3.8:
# extends: "tests-3.6"
# image: python:3.8
tests-3.9:
extends: "tests-3.6"
image: python:3.9
tests-3.10:
extends: "tests-3.6"
image: python:3.10
tests-3.11:
extends: "tests-3.6"
image: python:3.11

View File

@@ -86,6 +86,8 @@ class MainWindow(QMainWindow):
rst.start()
rst.server.register_function(self.new_plot)
rst.server.register_function(self.append_data)
rst.server.register_function(self.extend_data)
rst.server.register_function(self.set_data)
self.sig_make_new_plot.connect(self.on_make_new_plot)
@@ -116,14 +118,27 @@ class MainWindow(QMainWindow):
item = self.lst.get(name)
desc = item.value
desc.append(point)
alarm = True
for sub in self.mdi.subWindowList():
if name in sub.plots:
plot = sub.plots[name]
plot.setData(*desc.data)
alarm = False
item.timestamps.modification.update()
item.set_alarm(alarm)
self.sync_item_and_plots(item)
def extend_data(self, name, data):
"""
Extend the current data of the (existing) plot <name>.by <data>
The data is forwarded to the extend method of PlotDescription.
"""
item = self.lst.get(name)
desc = item.value
desc.extend(data)
self.sync_item_and_plots(item)
def set_data(self, name, data):
"""
Set <data> as the data of the (existing) plot <name>.
The data is assigned to the data attribute of PlotDescription.
"""
item = self.lst.get(name)
desc = item.value
desc.data = data
self.sync_item_and_plots(item)
# Signal callbacks
@@ -196,6 +211,17 @@ class MainWindow(QMainWindow):
self.lst.set(name, desc)
return desc
def sync_item_and_plots(self, item):
name, desc = item.key, item.value
alarm = True
for sub in self.mdi.subWindowList():
if name in sub.plots:
plot = sub.plots[name]
plot.setData(*desc.data)
alarm = False
item.timestamps.modification.update()
item.set_alarm(alarm)
def plot_single_item(self, item):
item.timestamps.access.update()
item.set_alarm(False)

View File

@@ -14,12 +14,21 @@ class PlotDescription:
def data(self):
return (self.xs, self.ys)
@data.setter
def data(self, value):
self.xs, self.ys = value
def append(self, xy):
x, y = xy
self.xs.append(x)
self.ys.append(y)
def extend(self, data):
xs, ys = data
self.xs.extend(xs)
self.ys.extend(ys)
def make_plot(self, plotwidget, style):
res = plotwidget.plot(self.xs, self.ys, name=self.name, **style)

View File

@@ -16,4 +16,10 @@ class RPCClient(xrc.ServerProxy):
return head + help
def __dir__(self):
d1 = super().__dir__()
d2 = self.utils.info().keys()
return [*d1, *d2]

View File

@@ -6,7 +6,7 @@ long_description = file: README.md
long_description_content_type = text/markdown
url = https://gitlab.psi.ch/augustin_s/grum
project_urls =
Bug Tracker = https://gitlab.psi.ch/augustin_s/grum/issues
Bug Tracker = https://gitlab.psi.ch/augustin_s/grum/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
@@ -16,7 +16,7 @@ classifiers =
package_dir =
= .
packages = find:
python_requires = >=3.8
python_requires = >=3.6
[options.packages.find]
where = .

View File

@@ -2,7 +2,7 @@ from setuptools import setup
if __name__ == "__main__":
setup(
install_requires=["pyqt5", "pyqtgraph", "h5py"],
install_requires=["pyqt5", "pyqtgraph", "h5py", "PyQtWebEngine"],
entry_points={"console_scripts": ["grum=grum:main"]},
)

View File

@@ -1,27 +0,0 @@
from grum.dictlist.dictlistwidget import DictListWidget
from grum.menus.rclickmenu import RClickMenu
class DictListWidgetMock(DictListWidget):
def __init__(self) -> None:
self.items = {}
self.nkeep = None
def get_DictListWidgetMock():
return DictListWidgetMock()
# def test_defaults():
# dlw = get_DictListWidgetMock()
# assert dlw.items == {}
# assert dlw.nkeep == None
# def test_add_menu():
# dlw = get_DictListWidgetMock()
# dlw._add_menu()
# assert dlw.menu == RClickMenu(dlw)

View File

@@ -21,6 +21,7 @@ from grum.rpc import RPCServerThread
class TestMainWin:
def setup_method(self):
print("setup")
self.app = QApplication(sys.argv)
theme.apply(self.app)
# ctrl_c.setup(self.app)
@@ -29,8 +30,10 @@ class TestMainWin:
def teardown_method(self):
print("teardown")
self.mw.rst.wait_for_stop()
self.app.quit()
print("app quit called")
del self.mw
del self.app
@@ -164,19 +167,6 @@ class TestMainWin:
mw.on_plot_selected()
mw.plot_multiple_items.assert_called_once_with([sine_item, cosine_item])
def test_on_sort_by_name(self):
mw = self.mw
mw.lst = DictList()
mw.new_plot("bb", {})
mw.new_plot("dd", {})
mw.new_plot("aa", {})
mw.new_plot("cc", {})
assert mw.lst.lst.items == 111
assert [key for key in mw.lst.lst.items.keys()] == ['bb', 'dd', 'aa', 'cc']
mw.on_sort_by_name()
assert mw.lst.lst.items == 111
def test_plot_single_item(self):
mw = self.mw

View File

@@ -15,13 +15,13 @@ class TestMDIArea:
def setup_method(self):
print("setup")
self.app = QApplication(sys.argv)
self.mw = MainWindow(add_examples=True)
self.mw = MainWindow(add_examples=True, offline=True)
self.mw.show()
def teardown_method(self):
print("teardown")
self.mw.rst.wait_for_stop()
# self.mw.rst.wait_for_stop()
self.app.quit()
print("app quit called")
del self.mw

View File

@@ -53,7 +53,7 @@ def test_make_plot():
)
app = QApplication(sys.argv)
theme.apply(app)
mw = MainWindow(add_examples=True)
mw = MainWindow(add_examples=True, offline=True)
mdi_sub = MDISubPlot("mdi", pd)
pw = pg.PlotWidget()