Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump minimum version of requests, add CI testing workflow with Tox #26

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/tox.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Tox

on:
workflow_dispatch:
push:
branches:
- master
paths:
- src
- tests
- pyproject.toml
- tox.ini
pull_request:
branches:
- master
paths:
- src
- tests
- pyproject.toml
- tox.ini

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
run-all-tests:
name: Py${{ matrix.py }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- windows-latest
py:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- name: Set up Python ${{ matrix.py }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Checkout NTIA/Preselector
uses: actions/checkout@v4
- name: Install tox-gh
run: python -m pip install tox-gh
- name: Set up test suite
run: tox r -vv --notest
- name: Run test suite
run: tox r --skip-pkg-install
env:
PYTEST_ADDOPTS: "-vv --durations=0"
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ default_language_version:
python: python3.8
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-ast
types: [file, python]
@@ -18,24 +18,24 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.16.0
hooks:
- id: pyupgrade
args: ["--py3-plus"]
args: ["--py38-plus"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 24.8.0
hooks:
- id: black
types: [file, python]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
rev: v0.41.0
hooks:
- id: markdownlint
types: [file, markdown]
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
# NTIA/ITS Preselector API

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/NTIA/Preselector?display_name=tag&sort=semver)
![GitHub all releases](https://img.shields.io/github/downloads/NTIA/Preselector/total)
![GitHub issues](https://img.shields.io/github/issues/NTIA/Preselector)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![GitHub release (latest SemVer)][latest-release-semver-badge]][github-releases]
[![GitHub Actions Test Status][github-actions-test-badge]][github-actions-tox-link]
[![GitHub all releases][github-download-count-badge]][github-releases]
[![GitHub issues][github-issue-count-badge]][github-issues]
[![Code style: black][code-style-badge]][code-style-repo]

[github-actions-tox-link]: https://github.com/NTIA/Preselector/actions/workflows/tox.yaml
[github-actions-test-badge]: https://github.com/NTIA/Preselector/actions/workflows/tox.yaml/badge.svg
[code-style-badge]: https://img.shields.io/badge/code%20style-black-000000.svg
[code-style-repo]: https://github.com/psf/black
[latest-release-semver-badge]: https://img.shields.io/github/v/release/NTIA/Preselector?display_name=tag&sort=semver
[github-releases]: https://github.com/NTIA/Preselector/releases
[github-download-count-badge]: https://img.shields.io/github/downloads/NTIA/Preselector/total
[github-issue-count-badge]: https://img.shields.io/github/issues/NTIA/Preselector
[github-issues]: https://github.com/NTIA/Preselector/issues

This repository provides a general software API to control preselectors regardless of their
components and control mechanisms.
@@ -163,7 +174,7 @@ preselector.set_state('antenna')
## Development

Set up a development environment using a tool like [Conda](https://docs.conda.io/en/latest/)
or [venv](https://docs.python.org/3/library/venv.html#module-venv), with `python>=3.7`. Then,
or [venv](https://docs.python.org/3/library/venv.html#module-venv), with `python>=3.8`. Then,
from the cloned directory, install the development dependencies by running:

```bash
@@ -207,4 +218,4 @@ See [LICENSE](LICENSE.md)

## Contact

For technical questions, contact Doug Boulware, dboulware@ntia.gov
For technical questions, contact <code@ntia.gov>
15 changes: 10 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -30,24 +30,29 @@ classifiers = [
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

dependencies = [
"requests>=2.31.0",
"requests>=2.32.0",
"defusedxml>=0.7.1"
]

[project.optional-dependencies]
tests = [
"pytest>=7.1.2",
"pytest-cov>=3.0.0",
"tox>=4.16.0,<5.0", # Keep in sync with tox.ini minimum_version
]
dev = [
"hatchling>=1.6.0,<2.0",
"pre-commit>=2.20.0",
"pytest>=7.1.2",
"pytest-cov>=3.0.0",
"twine>=4.0.1,<5.0"
"twine>=4.0.1,<5.0",
"its_preselector[tests]",
]

[project.urls]
2 changes: 1 addition & 1 deletion src/its_preselector/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.1.0"
__version__ = "3.1.1"
16 changes: 6 additions & 10 deletions src/its_preselector/preselector.py
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ def get_frequency_low_passband(self, rf_path_name: str) -> float:
if preselector_filter:
return preselector_filter.frequency_low_passband
else:
raise ConfigurationException("Filter {id} is None.".format(id=filter))
raise ConfigurationException(f"Filter {filter} is None.")
else:
raise ConfigurationException(
"Unable to get frequency_low for the passband filter. There is no RF_PATH named {path_name}".format(
@@ -124,9 +124,7 @@ def get_frequency_high_passband(self, rf_path_name: str) -> float:
if preselector_filter:
return preselector_filter.frequency_high_passband
else:
raise ConfigurationException(
"Filter {id} is None.".format(id=filter_id)
)
raise ConfigurationException(f"Filter {filter_id} is None.")
else:
raise ConfigurationException(
"Unable to get frequency_high for the passband filter. There is no RF_PATH named {path_name}".format(
@@ -147,9 +145,7 @@ def get_frequency_low_stopband(self, rf_path_name: str):
if preselector_filter:
return preselector_filter.frequency_low_stopband
else:
raise ConfigurationException(
"Filger {id} is None.".format(id=filter_id)
)
raise ConfigurationException(f"Filter {filter_id} is None.")
else:
raise ConfigurationException(
"Unable to get frequency_low for the stopband filter. There is no RF_PATH named {path_name}".format(
@@ -210,7 +206,7 @@ def get_amplifier_noise_figure(self, rf_path_name: str) -> float:
if amplifier:
return amplifier.noise_figure
else:
raise ConfigurationException("Amplifier {id} is None".format(id=amp_id))
raise ConfigurationException(f"Amplifier {amp_id} is None")
else:
raise ConfigurationException(
"Unable to get amplifier noise figure. There is no RF_PATH named {path_name}".format(
@@ -232,15 +228,15 @@ def __get_filter(self, filter_id):
if f.filter_spec.id == filter_id:
return f

raise ConfigurationException("Filter {id} does not exist.".format(id=filter_id))
raise ConfigurationException(f"Filter {filter_id} does not exist.")

def __get_amplifier(self, amp_id):
if amp_id:
for amp in self.amplifiers:
if amp.amplifier_spec.id == amp_id:
return amp

raise ConfigurationException("Amplifier {id} does not exist.".format(id=amp_id))
raise ConfigurationException(f"Amplifier {amp_id} does not exist.")

@abstractmethod
def get_sensor_value(self, sensor) -> float:
25 changes: 25 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[tox]
env_list =
py38
py39
py310
py311
py312
min_version = 4.16.0
skip_missing_interpreters = true
no_package = false

[testenv]
description = Run tests with pytest and generate coverage report
package = wheel
wheel_build_env = .pkg
extras = tests
commands = pytest --cov-report term-missing --no-cov-on-fail --cov {posargs}

[gh] ; GitHub Actions CI with tox-gh
python =
3.8 = py38
3.9 = py39
3.10 = py310
3.11 = py311
3.12 = py312