Skip to content

Commit

Permalink
Merge pull request #24 from NTIA/update_scos_actions_version
Browse files Browse the repository at this point in the history
Update scos actions version
  • Loading branch information
jhazentia committed Nov 30, 2022
2 parents 0998fa4 + 17fcf7a commit 401e474
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 37,212 deletions.
7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions .ml_style.rb

This file was deleted.

51 changes: 31 additions & 20 deletions .pre-commit-config.yaml
@@ -1,31 +1,42 @@
default_language_version:
python: python3.8
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
types: [file, python]
- id: check-case-conflict
- id: check-docstring-first
types: [file, python]
- id: check-merge-conflict
- id: check-yaml
types: [file, yaml]
- id: debug-statements
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
types: [file, python]
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: seed-isort-config
language_version: python3.8
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
- id: pyupgrade
args: ["--py3-plus"]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
language_version: python3.8
- repo: https://github.com/ambv/black
rev: 22.6.0
name: isort (python)
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language_version: python3.8
# TODO markdownlint broken
# - repo: https://github.com/markdownlint/markdownlint
# rev: v0.9.0
# hooks:
# - id: markdownlint
# args: [-s, .ml_style.rb, README.md]
# exclude: GitHubRepoPublicReleaseApproval.md|LICENSE.md
types: [file, python]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.2
hooks:
- id: markdownlint
types: [file, markdown]
exclude: GitHubRepoPublicReleaseApproval.md|LICENSE.md
84 changes: 45 additions & 39 deletions README.md
Expand Up @@ -10,8 +10,8 @@ https://github.com/NTIA/scos-sensor/blob/master/README.md#actions-and-hardware-s
) sections which explain the scos-sensor plugin architecture.

This repository includes many 700MHz band actions in [scos_usrp/configs/actions](
scos_usrp/configs/actions). Action classes, SignalAnalyzerInterface, GPSInterface, and
signals are used from [scos_actions](https://github.com/NTIA/scos-actions).
scos_usrp/configs/actions). Action classes, SignalAnalyzerInterface,
GPSInterface, and signals are used from [scos_actions](https://github.com/NTIA/scos-actions).

For information on adding actions, see the [scos_actions documentation](
https://github.com/NTIA/scos-actions/blob/master/README.md#adding-actions).
Expand All @@ -26,8 +26,8 @@ https://github.com/NTIA/scos-actions/blob/master/README.md#adding-actions).

## Overview of Repo Structure

- scos_usrp/configs: This folder contains the yaml files with the parameters used to
initialize the USRP supported actions and sample calibration files.
- scos_usrp/configs: This folder contains the yaml files with the parameters
used to initialize the USRP supported actions and sample calibration files.
- scos_usrp/discover: This includes the code to read yaml files and make actions
available to scos-sensor.
- scos_usrp/hardware: This includes the USRP implementation of the signal analyzer
Expand Down Expand Up @@ -55,54 +55,49 @@ Below are steps to run scos-sensor with the scos-usrp plugin:

### Requirements and Configuration

Requires pip>=18.1 (upgrade using `python3 -m pip install --upgrade pip`) and
python>=3.7.

It is highly recommended that you first initialize a virtual development environment
using a tool such a `conda` or `venv`. The following commands create a virtual
environment using `venv` and install the required dependencies for development and
testing.
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.8`. This repository dependends on the Python UHD library. In
Ubuntu, you can get this by installing the `python3-uhd` package. Then, you can
get access to this package in your 'venv' virtual environment using the
`--system-site-packages` option. Then, from the cloned directory, install the
development dependencies by running:

```bash
python3 -m venv ./venv
source venv/bin/activate
python3 -m pip install --upgrade pip # upgrade to pip>=18.1
python3 -m pip install -r requirements-dev.txt
pip install .[dev]
```

#### Using pip-tools

It is recommended to keep direct dependencies in a separate file. The direct
dependencies are in the requirements.in and requirements-dev.in files. Then pip-tools
can be used to generate files with all the dependencies and transitive dependencies
(sub-dependencies). The files containing all the dependencies are in requirements.txt
and requirements-dev.txt. Run the following in the virtual environment to install
pip-tools.
This will install the project itself, along with development dependencies for pre-commit
hooks, building distributions, and running tests. Set up pre-commit, which runs
auto-formatting and code-checking automatically when you make a commit, by running:

```bash
python -m pip install pip-tools
pre-commit install
```

To update requirements.txt after modifying requirements.in:
The pre-commit tool will auto-format Python code using [Black](https://github.com/psf/black)
and [isort](https://github.com/pycqa/isort). Other pre-commit hooks are also
enabled, and can be found in [`.pre-commit-config.yaml`](.pre-commit-config.yaml).

```bash
pip-compile requirements.in
```
### Building New Releases

To update requirements-dev.txt after modifying requirements.in or requirements-dev.in:
This project uses [Hatchling](https://github.com/pypa/hatch/tree/master/backend)
as a backend. Hatchling makes versioning and building new releases easy. The
package version can be updated easily by using any of the following commands.

```bash
pip-compile requirements-dev.in
hatchling version major # 1.0.0 -> 2.0.0
hatchling version minor # 1.0.0 -> 1.1.0
hatchling version micro # 1.0.0 -> 1.0.1
hatchling version "X.X.X" # 1.0.0 -> X.X.X
```

Use pip-sync to match virtual environment to requirements-dev.txt:
To build a new release (both wheel and sdist/tarball), run:

```bash
pip-sync requirements.txt requirements-dev.txt
hatchling build
```

For more information about pip-tools, see <https://pip-tools.readthedocs.io/en/latest/#>

### Running Tests

Since the UHD drivers are required, a docker container is used for testing. [Install
Expand All @@ -124,8 +119,8 @@ sorting is handled by isort.
There are several ways to autoformat your code before committing. First, IDE
integration with on-save hooks is very useful. Second, if you've already pip-installed
the dev requirements from the section above, you already have a utility called
pre-commit installed that will automate setting up this project's git pre-commit hooks.
Simply type the following once, and each time you make a commit, it will be
pre-commit installed that will automate setting up this project's git pre-commit
hooks. Simply type the following once, and each time you make a commit, it will be
appropriately autoformatted.

```bash
Expand All @@ -139,9 +134,20 @@ pre-commit run --all-files
```

In addition to Black and isort, various other pre-commit tools are enabled including
markdownlint. Markdownlint will show an error message if it detects any style issues in
markdown files. See [.pre-commit-config.yaml](.pre-commit-config.yaml) for the list of
pre-commit tools enabled for this repository.
markdownlint. Markdownlint will show an error message if it detects any style
issues in markdown files. See [.pre-commit-config.yaml](.pre-commit-config.yaml)
for the list of pre-commit tools enabled for this repository.

### Updating the scos_usrp_uhd package

Run the following commands to build, tag, and push the docker image to the Github
Container Registry. Replace X.X.X with the desired version number.

```bash
docker build -f docker/Dockerfile-uhd -t scos_usrp_uhd .
docker tag scos_usrp_uhd ghcr.io/ntia/scos-usrp/scos_usrp_uhd:X.X.X
docker push ghcr.io/ntia/scos-usrp/scos_usrp_uhd:X.X.X.
```

## License

Expand Down
4 changes: 2 additions & 2 deletions debug_iq_action.py
Expand Up @@ -2,7 +2,7 @@
import time

import numpy as np
from scos_actions.actions.interfaces.signals import measurement_action_completed
from scos_actions.signals import measurement_action_completed

from scos_usrp.discover import actions

Expand Down Expand Up @@ -38,7 +38,7 @@ def callback(sender, **kwargs):


measurement_action_completed.connect(callback)
iq_action(schedule_entry_json, 1, sensor)
iq_action(schedule_entry_json, 1)
number_of_zeros = len([x for x in _data if x == 0.0])
print(f"number_of_zeros = {number_of_zeros}")
print("metadata:")
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile-test
Expand Up @@ -15,6 +15,6 @@ COPY ./ /src

ARG DOCKER_GIT_CREDENTIALS
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r requirements-dev.txt
RUN python3 -m pip install --no-cache-dir .[test]

ENTRYPOINT ["pytest"]
73 changes: 73 additions & 0 deletions pyproject.toml
@@ -0,0 +1,73 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "scos-usrp"
dynamic = ["version"]
description = "USRP support for scos-sensor"
readme = "README.md"
requires-python = ">=3.8"
license = { file = "LICENSE.md" }

authors = [
{ name = "The Institute for Telecommunication Sciences" },
]


maintainers = [
{ name = "Doug Boulware", email = "dboulware@ntia.gov" },
{ name = "Justin Haze", email = "jhaze@ntia.gov" },
{ name = "Anthony Romaniello", email = "aromaniello@ntia.gov" },
]

keywords = [
"SCOS", "SDR", "spectrum monitoring", "radio", "sensor",
"spectrum", "monitoring", "remote", "distributed", "sensing",
"NTIA", "ITS", "telecommunications", "USRP",
]

classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: Telecommunications Industry",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Environment :: Plugins",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
]

dependencies = [
"django>=3.2.15,<4.0",
"environs>=9.0, <10.0",
"numpy>=1.22.0",
"scos_actions @ git+https://github.com/NTIA/scos-actions@4.0.2",
]

[project.optional-dependencies]
test = [
"pytest>=7.1.2",
]
dev = [
"scos-usrp[test]",
"hatchling>=1.6.0,<2.0",
"pre-commit>=2.20.0",
]

[project.urls]
"Repository" = "https://github.com/NTIA/scos-usrp"
"Bug Tracker" = "https://github.com/NTIA/scos-usrp/issues"
"SCOS Sensor" = "https://github.com/NTIA/scos-sensor"
"NTIA GitHub" = "https://github.com/NTIA"
"ITS Website" = "https://its.ntia.gov"

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.version]
path = "scos_usrp/__init__.py"

[tool.isort]
known_third_party = ["django", "environs", "numpy", "pytest", "scos_actions"]
5 changes: 0 additions & 5 deletions requirements-dev.in

This file was deleted.

0 comments on commit 401e474

Please sign in to comment.