Skip to content

Commit

Permalink
Merge pull request #57 from hephy-dd/devel-0.11.x
Browse files Browse the repository at this point in the history
0.11.0
  • Loading branch information
arnobaer authored Sep 20, 2024
2 parents 1ee571c + 2d0c3e9 commit 5cbce30
Show file tree
Hide file tree
Showing 22 changed files with 898 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python 3
uses: actions/setup-python@v2
uses: actions/setup-python@v5

- name: Install dependencies
run: |
Expand Down
23 changes: 7 additions & 16 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
os: [ubuntu-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
- uses: actions/cache@v4
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
- uses: actions/cache@v2
- uses: actions/cache@v4
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
Expand All @@ -35,20 +35,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel flake8 pylint pytest
pip install tox
pip install -e .
- name: Lint with flake8
- name: Test with tox
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Lint with pylint
run: |
pylint -E src
- name: Test with pytest
run: |
pytest
tox -epy
- name: Run application
run: |
python -m sqc --version
15 changes: 12 additions & 3 deletions .github/workflows/windows-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
Expand All @@ -27,7 +27,16 @@ jobs:
run: |
pyinstaller pyinstaller/windows_app.spec
- name: Publish
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: sqc-artifact
path: dist
- name: Build installer
run: |
$VERSION = python -c "import sqc; print(sqc.__version__)"
ISCC.exe /DVersion=$VERSION innosetup.iss
- name: Publish installer
uses: actions/upload-artifact@v4
with:
name: sqc-setup-artifact
path: dist/sqc*.exe
13 changes: 12 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.11.0] - 2024-09-16

### Added
- New bad strip detection (#25).

### Changed
- Improved non-modal edit strips dialog.
- Switched to pyproject.toml config.
- Switched to ruff linter.

## [0.10.2] - 2024-04-26

### Fixed
Expand Down Expand Up @@ -165,7 +175,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Documentation of measurement configuration parameters.

[Unreleased]: https://github.com/hephy-dd/sqc/compare/0.10.2...HEAD
[Unreleased]: https://github.com/hephy-dd/sqc/compare/0.11.0...HEAD
[0.11.0]: https://github.com/hephy-dd/sqc/compare/0.10.2...0.11.0
[0.10.2]: https://github.com/hephy-dd/sqc/compare/0.10.1...0.10.2
[0.10.1]: https://github.com/hephy-dd/sqc/compare/0.10.0...0.10.1
[0.10.0]: https://github.com/hephy-dd/sqc/compare/0.9.1...0.10.0
Expand Down
41 changes: 41 additions & 0 deletions innosetup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
; Inno Setup template

#ifndef Version
#error The define variable Version is not set! Use /D Version=value to set it.
#endif

#define Organization "HEPHY"
#define Name "SQC"
#define ExeName "sqc.exe"

[Setup]
AppId={#Organization}_{#Name}_{#Version}
AppName={#Name}
AppVersion={#Version}
AppPublisher=HEPHY Detector Development
AppPublisherURL=https://github.com/hephy-dd/
DefaultDirName={userappdata}\{#Organization}\sqc\{#Version}
DefaultGroupName={#Name}
OutputDir=dist
OutputBaseFilename=sqc-{#Version}-win-x64-setup
SetupIconFile=src\sqc\assets\icons\sqc.ico
UninstallDisplayIcon={app}\{#ExeName}
Compression=lzma
SolidCompression=yes
PrivilegesRequired=lowest

[Files]
Source: "dist\sqc\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs

[Icons]
Name: "{userdesktop}\{#Name} {#Version}"; Filename: "{app}\{#ExeName}"
Name: "{group}\{#Name} {#Version}"; Filename: "{app}\{#ExeName}"; WorkingDir: "{app}"

[Run]
Filename: "{app}\{#ExeName}"; Description: "{cm:LaunchProgram,{#Name} {#Version}}"; Flags: nowait postinstall skipifsilent

[UninstallDelete]
Type: filesandordirs; Name: "{app}"

[UninstallRun]
Filename: "{app}\uninstall.exe"
16 changes: 16 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[mypy]

[mypy-pyueye.*]
ignore_missing_imports = True

[mypy-pint.*]
ignore_missing_imports = True

[mypy-scipy.*]
ignore_missing_imports = True

[mypy-schema.*]
ignore_missing_imports = True

[mypy-comet.*]
ignore_missing_imports = True
2 changes: 1 addition & 1 deletion pyinstaller/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ wheel
pyusb==1.2.1
pyserial==3.5
gpib-ctypes==0.3.0
pyinstaller==5.13.2
pyinstaller==6.7.0
pyinstaller-versionfile==2.1.1
21 changes: 16 additions & 5 deletions pyinstaller/windows_app.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ from pyinstaller_versionfile import create_versionfile
import sqc

version = sqc.__version__
filename = f"sqc-{version}.exe"
bundle = "sqc"
filename = "sqc.exe"
console = False
debug = False
block_cipher = None

package_root = os.path.join(os.path.dirname(sqc.__file__))
Expand Down Expand Up @@ -58,13 +60,11 @@ pyz = PYZ(
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
exclude_binaries=True,
name=filename,
version=version_info,
debug=False,
debug=debug,
bootloader_ignore_signals=False,
strip=False,
upx=True,
Expand All @@ -73,3 +73,14 @@ exe = EXE(
console=console,
icon=package_icon,
)

coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name=bundle,
)
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
[project]
name = "sqc"
description = "Sensor Quality Control"
readme = "README.md"
authors = [
{name = "Bernhard Arnold", email = "bernhard.arnold@oeaw.ac.at"},
]
requires-python = ">=3.9"
dependencies = [
"comet @ git+https://github.com/hephy-dd/comet.git@main",
"PyQt5==5.15.10",
"PyQtChart==5.15.6",
"PyYAML==6.0.1",
"numpy==1.26.4",
"scipy==1.12.0",
"schema==0.7.5",
"pyueye==4.95.0",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/hephy-dd/sqc"
Documentation = "https://hephy-dd.github.io/sqc/"

[project.scripts]
sqc = "sqc.__main__:main"

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
"sqc.assets.icons" = ["*.svg", "*.png", "*.ico"]
56 changes: 0 additions & 56 deletions setup.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion src/sqc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.10.2"
__version__ = "0.11.0"
7 changes: 7 additions & 0 deletions src/sqc/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import json
import logging
import os
import sys
Expand Down Expand Up @@ -28,6 +29,7 @@
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(prog="sqc", description="Sensor Quality Control (SQC) for CMS Outer Tracker.")
parser.add_argument('--browser', metavar="<path>", nargs="?", const=os.path.expanduser("~"), help="run data browser")
parser.add_argument('--import-json', metavar="<file>", help="import JSON measurement file (testing)")
parser.add_argument('--debug-no-table', action='store_true', help="disable sequence table movements")
parser.add_argument('--debug-no-tango', action='store_true', help="disable sequence tango movements")
parser.add_argument('--debug', action='store_true', help="show debug messages")
Expand Down Expand Up @@ -109,6 +111,11 @@ def run_main_window(args):
window.readSettings()
window.show()

if args.import_json:
with open(args.import_json, "rt") as fp:
data = json.load(fp)
context.import_data(data.get("namespace", ""), data.get("data", {}))

QtWidgets.QApplication.exec()

window.writeSettings()
Expand Down
11 changes: 11 additions & 0 deletions src/sqc/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class Context(QtCore.QObject):

exception_raised = QtCore.pyqtSignal(Exception)

lock_profile = QtCore.pyqtSignal(bool)

def __init__(self, station: Station, parent: Optional[QtCore.QObject] = None) -> None:
super().__init__(parent)
self._station: Station = station
Expand Down Expand Up @@ -176,6 +178,15 @@ def insert_data(self, namespace: str, type: str, name: str, data: dict, sortkey:
logger.debug("inserted data: namespace=%r, type=%r, name=%r, data=%r", namespace, type, name, data)
self.data_changed.emit(namespace, type, name)

def import_data(self, namespace: str, data: dict) -> None:
for type, type_data in data.items():
for name, name_data in type_data.items():
for item in name_data:
items: Dict[str, Dict] = self._data.setdefault(namespace, {}).setdefault(type, {}).get(name, [])
self._data.setdefault(namespace, {}).setdefault(type, {})[name] = auto_insert_item(items, item, sortkey="strip_index")
self.data_changed.emit(namespace, type, name)
logger.debug("imported data: namespace=%r, type=%r, name=%r", namespace, type, name)

# Statistics

@property
Expand Down
5 changes: 4 additions & 1 deletion src/sqc/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def create_slices(all: List[str], selected: List[str]) -> List[List[str]]:

def normalize_strip_expression(expression: str) -> str:
"""Return normalized version of strip expression."""
return re.sub(r"\s*", "", expression).strip().replace(",", ", ")
tokens = re.findall(r'\b\d+\s*-\s*\d+\b|[^\s,]+', expression)
tokens = [re.sub(r'\s*-\s*', "-", token).strip() for token in tokens]
tokens = [token.strip("-") for token in tokens] # strip open ranges
return ", ".join(filter(None, tokens))


def parse_strip_expression(expression: str) -> Generator[Tuple[str, str], None, None]:
Expand Down
Loading

0 comments on commit 5cbce30

Please sign in to comment.