Skip to content

Commit

Permalink
Automatic PyPi deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jupfi committed Apr 18, 2024
1 parent 303884b commit d2a0545
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 15 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
Expand All @@ -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.
Expand Down
31 changes: 28 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]" },
{ name="jupfi", email="[email protected]" },
]

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",
Expand All @@ -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"]
7 changes: 5 additions & 2 deletions src/nqrduck_pulseprogrammer/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand All @@ -21,6 +22,7 @@ def on_loading(self, pulse_parameter_options : dict) -> None:
@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.
"""
Expand All @@ -34,6 +36,7 @@ def delete_event(self, event_name : str) -> None:
@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.
Expand Down Expand Up @@ -84,7 +87,7 @@ def on_move_event_left(self, event_name: str) -> None:

@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.
Expand Down Expand Up @@ -123,7 +126,7 @@ def load_pulse_sequence(self, path : str) -> None:
"""
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)
Expand Down
2 changes: 1 addition & 1 deletion src/nqrduck_pulseprogrammer/model.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 9 additions & 6 deletions src/nqrduck_pulseprogrammer/view.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -519,7 +518,8 @@ def checkbox_result():
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)
Expand Down Expand Up @@ -719,7 +719,8 @@ def create_message_box(self, message: str, information: str) -> None:
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)
Expand Down Expand Up @@ -777,14 +778,16 @@ def get_name(self) -> str:
"""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:
Expand Down

0 comments on commit d2a0545

Please sign in to comment.