Skip to content

Commit

Permalink
Merge pull request #398 from linien-org/release/v2.0.2
Browse files Browse the repository at this point in the history
Release v2.0.2
  • Loading branch information
bleykauf authored May 14, 2024
2 parents 34c6f15 + e918ced commit 16dee16
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Linien
uses: ./.github/actions/install-linien
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
lfs: "true"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
lfs: "true"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pyinstaller-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
- run: pyinstaller pyinstaller.spec
working-directory: linien-gui

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: linien-gui-linux
path: linien-gui/dist/*
4 changes: 2 additions & 2 deletions .github/workflows/pyinstaller-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -28,7 +28,7 @@ jobs:
- run: pyinstaller pyinstaller.spec
working-directory: linien-gui

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: linien-gui-windows
path: linien-gui/dist/*
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Linien
uses: ./.github/actions/install-linien
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 24.3.0
rev: 24.4.2
hooks:
- id: black
exclude: ^(gateware/logic/|gateware/lowlevel/|gateware/linien_module.py|linien-server/linien_server/csrmap.py)
Expand All @@ -12,7 +12,7 @@ repos:
name: isort (python)

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
exclude: linien-server/linien_server/csrmap.py
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.2] - 2024-05-14

### Fixed
* Improved performance of server CLI by @bleykauf in https://github.com/linien-org/linien/pull/396
* API token for InfluxDB is now checked by @bleykauf in https://github.com/linien-org/linien/pull/397

## [2.0.1] - 2024-05-13

### Fixed
Expand Down Expand Up @@ -210,7 +216,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* **Bug fixes and performance improvements**


[Unreleased]: https://github.com/linien-org/linien/compare/v2.0.1...v2.0.2
[2.0.1]: https://github.com/linien-org/linien/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/linien-org/linien/compare/v1.0.2...v2.0.0
[1.0.2]: https://github.com/linien-org/linien/compare/v1.0.1...v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions linien-client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-client"
version = "2.0.1"
version = "2.0.2"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand All @@ -25,7 +25,7 @@ requires-python = ">=3.8"
dependencies = [
"fabric>=2.7.0,<3.0",
"typing_extensions>=4.5.0,<5.0",
"linien-common==2.0.1",
"linien-common==2.0.2",
]

[project.readme]
Expand Down
2 changes: 1 addition & 1 deletion linien-common/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-common"
version = "2.0.1"
version = "2.0.2"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand Down
30 changes: 13 additions & 17 deletions linien-gui/linien_gui/ui/logging_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

class LoggingPanel(QtWidgets.QWidget):
set_parameter_log = pyqtSignal(str, bool)
influx_credentials_update = pyqtSignal(bool, int, str)
influx_credentials_update = pyqtSignal(bool, str)

logParametersToolButton: "LoggedParametersToolButton"
lineEditURL: QtWidgets.QLineEdit
Expand Down Expand Up @@ -78,6 +78,10 @@ def on_connection_established(self) -> None:
self.lineEditBucket.setText(credentials.bucket)
self.lineEditMeas.setText(credentials.measurement)

# hide test indicator that might be set from previous connection to a different
# device
self.influxTestIndicator.setText("")

# getting the logging status from the remote
log_status = self.control.exposed_get_logging_status()
button_text = STOP_LOG_BUTTON_TEXT if log_status else START_LOG_BUTTON_TEXT
Expand Down Expand Up @@ -106,28 +110,20 @@ def on_influx_update_button_clicked(self) -> None:
bucket=self.lineEditBucket.text(),
measurement=self.lineEditMeas.text(),
)
(
success,
status_code,
message,
) = self.control.exposed_update_influxdb_credentials(credentials)
update_msg = f"Update of InfluxDB credentials successful: {success}"
if not success:
update_msg += f" (Status {status_code}): {message}"
(success, message) = self.control.exposed_update_influxdb_credentials(
credentials
)
update_msg = f"Update of InfluxDB credentials successful: {success}: {message}"
logger.info(update_msg)
self.influx_credentials_update.emit(success, status_code, message)
self.influx_credentials_update.emit(success, message)

def on_influxdb_credentials_updated(
self, success: bool, status_code: int, message: str
) -> None:
def on_influxdb_credentials_updated(self, success: bool, message: str) -> None:
if success:
self.influxTestIndicator.setText("✅")
self.influxTestIndicator.setToolTip("Connection successful")
self.influxTestIndicator.setToolTip(f"Connection successful: {message}")
else:
self.influxTestIndicator.setText("❌")
self.influxTestIndicator.setToolTip(
f"Connection failed: {message} (Status {status_code})"
)
self.influxTestIndicator.setToolTip(f"Connection failed: {message}.")


# checkable menu for logged parameters, inspired by
Expand Down
4 changes: 2 additions & 2 deletions linien-gui/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-gui"
version = "2.0.1"
version = "2.0.2"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand All @@ -28,7 +28,7 @@ dependencies = [
"PyQt5>=5.12.0,<6.0",
"requests>=2.31.0,<3.0",
"superqt>=0.2.3",
"linien_client==2.0.1",
"linien_client==2.0.2",
]

[project.readme]
Expand Down
23 changes: 13 additions & 10 deletions linien-server/linien_server/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@
from typing import Optional

import fire
from linien_common.communication import (
no_authenticator,
username_and_password_authenticator,
)
from linien_server import __version__, mdio_tool
from linien_server.server import (
FakeRedPitayaControlService,
RedPitayaControlService,
run_threaded_server,
)

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand All @@ -49,6 +39,8 @@ def copy_systemd_service_file() -> None:
class LinienServerCLI:
def version(self) -> str:
"""Return the version of the Linien server."""
from linien_server import __version__

return __version__

def start(self) -> None:
Expand Down Expand Up @@ -76,6 +68,17 @@ def run(self, fake: bool = False, host: Optional[str] = None) -> None:
fake: Whether to run a fake server.
host: The hostname of the Red Pitaya.
"""
from linien_common.communication import (
no_authenticator,
username_and_password_authenticator,
)
from linien_server import mdio_tool
from linien_server.server import (
FakeRedPitayaControlService,
RedPitayaControlService,
run_threaded_server,
)

if fake:
control = FakeRedPitayaControlService()
else:
Expand Down
40 changes: 26 additions & 14 deletions linien-server/linien_server/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from influxdb_client import InfluxDBClient
from influxdb_client.client.write_api import SYNCHRONOUS
from influxdb_client.rest import ApiException
from linien_common.communication import ParameterValues
from linien_common.influxdb import InfluxDBCredentials, save_credentials
from linien_server.parameters import Parameters
Expand All @@ -29,7 +30,7 @@ class InfluxDBLogger:
def __init__(
self, credentials: InfluxDBCredentials, parameters: Parameters
) -> None:
self.credentials: InfluxDBClient = credentials
self.credentials: InfluxDBCredentials = credentials
self.parameters: Parameters = parameters
self.stop_event = Event()
self.stop_event.set()
Expand All @@ -53,7 +54,7 @@ def update_connection(self) -> InfluxDBClient:
self.write_api = client.write_api(write_options=SYNCHRONOUS)

def start_logging(self, interval: float) -> None:
conn_success, status_code, message = self.test_connection(self.credentials)
conn_success, message = self.test_connection(self.credentials)
self.thread = Thread(
target=self._logging_loop,
args=(interval,),
Expand All @@ -63,10 +64,7 @@ def start_logging(self, interval: float) -> None:
self.stop_event.clear()
self.thread.start()
else:
raise ConnectionError(
"Failed to connect to InfluxDB database: "
f" {message} (Status code: {status_code})"
)
raise ConnectionError(f"Failed to connect to InfluxDB database: {message}")

def stop_logging(self) -> None:
self.stop_event.set()
Expand All @@ -85,21 +83,35 @@ def _logging_loop(self, interval: float) -> None:
self.write_data(self.credentials, data)
sleep(interval)

def test_connection(
self, credentials: InfluxDBCredentials
) -> tuple[bool, int, str]:
def test_connection(self, credentials: InfluxDBCredentials) -> tuple[bool, str]:
"""Write empty data to the server to test the connection"""
client = InfluxDBClient(
url=credentials.url,
token=credentials.token,
org=credentials.org,
)

# FIXME: This does not test the credentials, yet.
status_code = 0
message = ""
success = client.ping()
return success, status_code, message
health = client.health()
message = health.message
success = health.status == "pass"
if success:
try:
client.write_api(write_options=SYNCHRONOUS).write(
bucket=credentials.bucket,
org=credentials.org,
record={
"measurement": credentials.measurement,
"fields": {},
},
)
except ApiException as e:
success = False
message = e.message
except Exception:
success = False
message = "Exception occurred. Check server log file for details."

return success, message

def write_data(
self, credentials: InfluxDBCredentials, fields: dict[str, ParameterValues]
Expand Down
10 changes: 3 additions & 7 deletions linien-server/linien_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,18 @@ def exposed_get_parameter_log(self, param_name: str) -> bool:

def exposed_update_influxdb_credentials(
self, credentials: InfluxDBCredentials
) -> tuple[bool, int, str]:
) -> tuple[bool, str]:
credentials = copy(credentials)
(
connection_succesful,
status_code,
message,
) = self.influxdb_logger.test_connection(credentials)
if connection_succesful:
self.influxdb_logger.credentials = credentials
logger.info("InfluxDB credentials updated successfully")
else:
logger.info(
"InfluxDB credentials update failed. Error message: "
f" {message} (Status Code {status_code})"
)
return connection_succesful, status_code, message
logger.info(f"InfluxDB credentials update failed. Error message: {message}")
return connection_succesful, message

def exposed_get_influxdb_credentials(self) -> InfluxDBCredentials:
return self.influxdb_logger.credentials
Expand Down
4 changes: 2 additions & 2 deletions linien-server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "linien-server"
version = "2.0.1"
version = "2.0.2"
authors = [
{ name = "Benjamin Wiegand", email = "[email protected]" },
{ name = "Bastian Leykauf", email = "[email protected]" },
Expand All @@ -28,7 +28,7 @@ dependencies = [
"influxdb-client[ciso]>=1.9,<2.0",
"pylpsd>=0.1.4",
"pyrp3>=2.0.1,<3.0;platform_machine=='armv7l'",
"linien-common==2.0.1",
"linien-common==2.0.2",
]

[project.readme]
Expand Down

0 comments on commit 16dee16

Please sign in to comment.