Automatic PyPi deployment.

This commit is contained in:
jupfi 2024-04-18 19:45:45 +02:00
parent 303884b034
commit d2a05452f9
8 changed files with 98 additions and 15 deletions

44
.github/workflows/python-publish.yml vendored Normal file
View file

@ -0,0 +1,44 @@
name: Build, Test, and Upload Python Package
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: read
jobs:
# test:
# uses: ./.github/workflows/ubuntu-python-package.yml # use the callable tests job to run tests
deploy:
runs-on: ubuntu-latest
# needs: [test]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
- name: Publish to PyPI
run: |
python -m venv venv
. ./venv/bin/activate
pip install -U twine build
python -m build .
python -m twine upload --repository pypi --username __token__ --password ${{ secrets.PYPI }} dist/*
env:
PYPI: ${{ secrets.PYPI }}

View file

@ -1,4 +1,7 @@
# Changelog
### Version 0.0.2 (18-04-2024)
- Automatic deployment to PyPI
### Version 0.0.1 (15-04-2024)
- Initial release

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Julia Pfitzer
Copyright (c) 2023 jupfi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -22,6 +22,11 @@ You can install this module and the dependencies by running the following comman
pip install .
```
Alternatively, you can install the module and the dependencies by running the following command in the terminal while the virtual environment is activated:
```bash
pip install nqrduck-pulseprogrammer
```
## Usage
The module is used with the [Spectrometer](https://github.com/nqrduck/nqrduck-spectrometer) module. However you need to use an actual submodule of the spectromter module like:
@ -32,7 +37,7 @@ The pulse programmer provides an event based graphical user interface for progra
The following picture depicts an exemplary Free Induction Decay (FID) pulse sequence.
<img src="docs/img/pulseprogrammer_labeled.png" alt="drawing" width="800">
<img src="https://raw.githubusercontent.com/nqrduck/nqrduck-pulseprogrammer/303884b034dadc6d88ee8160b4870af64b15a7b7/docs/img/pulseprogrammer_labeled.png" alt="drawing" width="800">
- a.) The different pulse sequence events. The events can be added to the pulse sequence by clicking on the '+ New Event' button.
- b.) The different 'Pulse Parameter Options' provided by the spectrometer module. The active spectrometer in the picture is the LimeNQR spectrometer. It provides 'Pulse Parameter Options' for 'TX' (Transmit) and 'RX' (Receive) events.
@ -42,7 +47,7 @@ The following picture depicts an exemplary Free Induction Decay (FID) pulse sequ
When clicking on the 'Pulse Parameter Options' of a certain column and row, a dialog window opens. The dialog window provides the user with the possibility to adjust the 'Pulse Parameter Options' of the event. The dialog window is different for each 'Pulse Parameter Option'.
<img src="docs/img/pulseprogrammer_tx_labeled.png" alt="drawing" width="800">
<img src="https://raw.githubusercontent.com/nqrduck/nqrduck-pulseprogrammer/303884b034dadc6d88ee8160b4870af64b15a7b7/docs/img/pulseprogrammer_tx_labeled.png" alt="drawing" width="800">
- a.) A numerical input field for the 'Relative TX Amplitude' of the 'TX' Pulse Parameter Option.
- b.) A numerical input field for the 'TX Phase' of the 'TX' Pulse Parameter Option.

View file

@ -4,15 +4,15 @@ build-backend = "hatchling.build"
[project]
name = "nqrduck-pulseprogrammer"
version = "0.0.1"
version = "0.0.2"
authors = [
{ name="Julia Pfitzer", email="git@jupfi.me" },
{ name="jupfi", email="support@nqrduck.cool" },
]
description = "A module for the NQRduck program (a simple python script™) to do pulse programming."
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.8"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
@ -28,3 +28,28 @@ dependencies = [
[project.entry-points."nqrduck"]
"nqrduck-pulseprogrammer" = "nqrduck_pulseprogrammer.pulseprogrammer:pulse_programmer"
[tool.ruff]
exclude = [
"widget.py",
]
[tool.ruff.lint]
extend-select = [
"UP", # pyupgrade
"D", # pydocstyle
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[project.urls]
"Homepage" = "https://nqrduck.cool"
"Bug Tracker" = "https://github.com/nqrduck/nqrduck-pulseprogrammer/issues"
"Source Code" = "https://github.com/nqrduck/nqrduck-pulseprogrammer"
[tool.hatch.build.targets.wheel]
packages = ["src/nqrduck_pulseprogrammer"]

View file

@ -12,6 +12,7 @@ class PulseProgrammerController(ModuleController):
def on_loading(self, pulse_parameter_options : dict) -> None:
"""This method is called when the module is loaded. It sets the pulse parameter options in the model.
Args:
pulse_parameter_options (dict): The pulse parameter options.
"""
@ -21,6 +22,7 @@ class PulseProgrammerController(ModuleController):
@pyqtSlot(str)
def delete_event(self, event_name : str) -> None:
"""This method deletes an event from the pulse sequence.
Args:
event_name (str): The name of the event to be deleted.
"""
@ -34,6 +36,7 @@ class PulseProgrammerController(ModuleController):
@pyqtSlot(str, str)
def change_event_name(self, old_name : str, new_name : str) -> None:
"""This method changes the name of an event.
Args:
old_name (str): The old name of the event.
new_name (str): The new name of the event.
@ -84,7 +87,7 @@ class PulseProgrammerController(ModuleController):
@pyqtSlot(str)
def on_move_event_right(self, event_name : str) -> None:
""" This method moves the event one position to the right if possible.
"""This method moves the event one position to the right if possible.
Args:
event_name (str): The name of the event to be moved.
@ -123,7 +126,7 @@ class PulseProgrammerController(ModuleController):
"""
logger.debug("Loading pulse sequence from %s", path)
sequence = None
with open(path, "r") as file:
with open(path) as file:
sequence = file.read()
sequence = json.loads(sequence)

View file

@ -1,7 +1,7 @@
import logging
from decimal import Decimal
from collections import OrderedDict
from PyQt6.QtCore import pyqtSignal, pyqtSlot
from PyQt6.QtCore import pyqtSignal
from nqrduck.module.module_model import ModuleModel
from nqrduck_spectrometer.pulsesequence import PulseSequence

View file

@ -1,9 +1,8 @@
import logging
import functools
from collections import OrderedDict
from pathlib import Path
from decimal import Decimal
from PyQt6.QtGui import QIcon, QValidator
from PyQt6.QtGui import QValidator
from PyQt6.QtWidgets import (
QMessageBox,
QGroupBox,
@ -519,7 +518,8 @@ class OptionsDialog(QDialog):
class FunctionOptionWidget(QWidget):
"""This class is a widget that can be used to set the options for a pulse parameter.
It plots the given function in time and frequency domain.
One can also select the function from a list of functions represented as buttons."""
One can also select the function from a list of functions represented as buttons.
"""
def __init__(self, function_option, event, parent=None):
super().__init__(parent)
@ -719,7 +719,8 @@ class FunctionOptionWidget(QWidget):
Args:
message (str): The message to be shown in the message box
information (str): The information to be shown in the message box"""
information (str): The information to be shown in the message box
"""
msg = QMessageBox(parent=self.parent)
msg.setIcon(QMessageBox.Icon.Warning)
msg.setText(message)
@ -777,14 +778,16 @@ class AddEventDialog(QDialog):
"""Returns the name entered by the user.
Returns:
str: The name entered by the user"""
str: The name entered by the user
"""
return self.name_input.text()
def get_duration(self) -> Decimal:
"""Returns the duration entered by the user, or a fallback value."
Returns:
Decimal: The duration value provided by the user, or 20"""
Decimal: The duration value provided by the user, or 20
"""
return Decimal(self.duration_lineedit.text() or 20)
def check_input(self) -> None: