Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NTIA/scos-usrp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.1.0
Choose a base ref
...
head repository: NTIA/scos-usrp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 349 additions and 38,774 deletions.
  1. +0 −7 .isort.cfg
  2. +0 −6 .ml_style.rb
  3. +31 −20 .pre-commit-config.yaml
  4. +62 −49 README.md
  5. +2 −2 debug_iq_action.py
  6. +7 −11 docker/Dockerfile-test
  7. +7 −37 docker/Dockerfile-uhd
  8. +73 −0 pyproject.toml
  9. +0 −5 requirements-dev.in
  10. +0 −156 requirements-dev.txt
  11. +0 −4 requirements.in
  12. +0 −62 requirements.txt
  13. +1 −0 scos_usrp/__init__.py
  14. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_ATT_DL.yml
  15. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_ATT_UL.yml
  16. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_FirstNet_DL.yml
  17. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_FirstNet_UL.yml
  18. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_P-SafetyNB_DL.yml
  19. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_P-SafetyNB_UL.yml
  20. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_T-Mobile_DL.yml
  21. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_T-Mobile_UL.yml
  22. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_Verizon_DL.yml
  23. +2 −0 scos_usrp/configs/actions/acquire_iq_700MHz_Verizon_UL.yml
  24. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_ATT_DL.yml
  25. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_ATT_UL.yml
  26. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_FirstNet_DL.yml
  27. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_FirstNet_UL.yml
  28. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_P-SafetyNB_DL.yml
  29. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_P-SafetyNB_UL.yml
  30. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_T-Mobile_DL.yml
  31. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_T-Mobile_UL.yml
  32. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_Verizon_DL.yml
  33. +2 −0 scos_usrp/configs/actions/acquire_m4s_700MHz_Verizon_UL.yml
  34. +6 −44 scos_usrp/configs/actions/survey_700MHz_band_10dB_1000ms_iq.yml
  35. +6 −44 scos_usrp/configs/actions/survey_700MHz_band_10dB_80ms_iq.yml
  36. +6 −44 scos_usrp/configs/actions/survey_700MHz_band_20dB_1000ms_iq.yml
  37. +6 −44 scos_usrp/configs/actions/survey_700MHz_band_20dB_80ms_iq.yml
  38. +6 −44 scos_usrp/configs/actions/survey_700MHz_band_40dB_1000ms_iq.yml
  39. +6 −44 scos_usrp/configs/actions/survey_700MHz_band_40dB_80ms_iq.yml
  40. +5 −33 scos_usrp/configs/actions/survey_700MHz_band_iq.yml
  41. +0 −1,997 scos_usrp/configs/sensor_calibration.json.example
  42. +0 −34,857 scos_usrp/configs/sigan_calibration.json.example
  43. +6 −1 scos_usrp/discover/__init__.py
  44. +3 −0 scos_usrp/hardware/__init__.py
  45. +0 −224 scos_usrp/hardware/calibration.py
  46. +8 −8 scos_usrp/hardware/mocks/usrp_block.py
  47. 0 scos_usrp/hardware/tests/resources/__init__.py
  48. +0 −80 scos_usrp/hardware/tests/resources/utils.py
  49. +0 −574 scos_usrp/hardware/tests/test_calibration.py
  50. +10 −166 scos_usrp/hardware/tests/test_usrp.py
  51. +58 −166 scos_usrp/hardware/usrp_sigan.py
  52. +0 −10 scos_usrp/settings.py
  53. +0 −35 setup.py
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
Original file line number Diff line number Diff line change
@@ -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.5.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.15.0
hooks:
- id: seed-isort-config
language_version: python3.7
- 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.12.0
hooks:
- id: isort
language_version: python3.7
- repo: https://github.com/ambv/black
rev: 22.1.0
name: isort (python)
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black
language_version: python3.7
# 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.37.0
hooks:
- id: markdownlint
types: [file, markdown]
exclude: GitHubRepoPublicReleaseApproval.md|LICENSE.md
111 changes: 62 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).
@@ -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
@@ -40,69 +40,71 @@ Requires pip>=18.1 (upgrade using `python3 -m pip install --upgrade pip`).
Below are steps to run scos-sensor with the scos-usrp plugin:

1. Clone scos-sensor: `git clone https://github.com/NTIA/scos-sensor.git`
1. Navigate to scos-sensor: `cd scos-sensor`
1. If it does not exist, create env file while in the root scos-sensor directory:
2. Navigate to scos-sensor: `cd scos-sensor`
3. If it does not exist, create env file while in the root scos-sensor directory:
`cp env.template ./env`
1. Make sure the `scos_usrp` dependency is in `requirements.txt` in `scos-sensor/src`
folder. If you are using a different branch than master, change master in the
following line to the branch you are using:
`scos_usrp @ git+https://github.com/NTIA/scos-usrp@master#egg=scos_usrp.`
1. Make sure `BASE_IMAGE` is set to `BASE_IMAGE=smsntia/uhd_b2xx_py3` in env file.
1. Get environment variables: `source ./env`
1. Build and start containers: `docker-compose up -d --build --force-recreate`
4. Replace the line starting with `scos-tekrsa` in the `requirements.in` file in
scos-sensor/src with the following:
`scos_usrp @ git+https://github.com/NTIA/scos-usrp@master`.
If you are using a different branch than master, change `master` to the branch
or tag you are using. Make sure `pip-tools` package is installed in your Python
environment (`python -m pip install pip-tools`). Then run
`pip-compile requirements.in` and `pip-compile requirements-dev.in` to update
`requirements.txt` and `requirements-dev.txt` with the dependencies needed for
scos-usrp.
5. Make sure `BASE_IMAGE` is set to `BASE_IMAGE=ghcr.io/ntia/scos-usrp/scos_usrp_uhd:0.0.2`
in the env file. This is a publicly available docker image with the necessary
UHD drivers hosted within the GitHub container registry.
6. Get environment variables: `source ./env`
7. Build and start containers: `docker-compose up -d --build --force-recreate`

## Development

### 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
@@ -124,8 +126,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
@@ -139,14 +141,25 @@ 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

See [LICENSE](LICENSE.md).

## Contact

For technical questions about scos-usrp, contact Justin Haze, jhaze@ntia.gov
For technical questions about scos-usrp, contact Justin Haze, <jhaze@ntia.gov>
4 changes: 2 additions & 2 deletions debug_iq_action.py
Original file line number Diff line number Diff line change
@@ -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

@@ -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:")
18 changes: 7 additions & 11 deletions docker/Dockerfile-test
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
FROM smsntia/uhd_b2xx_py3
FROM ubuntu:20.04


RUN apt-get update -q && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -qy --no-install-recommends \
libboost-date-time1.65.1 libboost-filesystem1.65.1 \
libboost-python1.65.1 libboost-regex1.65.1 \
libboost-serialization1.65.1 libboost-system1.65.1 \
libboost-thread1.65.1 libusb-1.0-0 libpython3.7 \
libboost-program-options1.65.1 \
git python3.7 \
swig gcc python3.7-dev && \
apt-get install -qy --no-install-recommends \
git python3 python3-pip \
python3-dev python3-uhd && \
apt-get clean && rm -rf /var/lib/apt/lists/*

ENV PYTHONUNBUFFERED 1
@@ -18,7 +14,7 @@ WORKDIR /src
COPY ./ /src

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

ENTRYPOINT ["pytest"]
44 changes: 7 additions & 37 deletions docker/Dockerfile-uhd
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
FROM ubuntu as build
FROM ubuntu:20.04

# Everything AFTER the "v" in the GitHub tag
ARG UHD_TAG=3.13.1.0-rc1
RUN apt-get update -q && apt-get upgrade -yq

RUN apt-get update -q && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -qy --no-install-recommends \
wget libboost-all-dev libusb-1.0-0-dev python3-setuptools \
python3-pip python3-setuptools python3-numpy \
python3-mako python3-requests \
cmake build-essential ca-certificates

RUN wget https://github.com/EttusResearch/uhd/archive/v${UHD_TAG}.tar.gz \
-O uhd.tar.gz && tar -xvzf uhd.tar.gz

RUN mkdir uhd-${UHD_TAG}/host/build
WORKDIR uhd-${UHD_TAG}/host/build
RUN cmake -DENABLE_PYTHON_API=ON -DENABLE_PYTHON3=ON ../
RUN make && make test && make install
RUN python3 /usr/local/lib/uhd/utils/uhd_images_downloader.py

FROM ubuntu

# Copy just the necessities to run B2xx with python3
COPY --from=build /usr/local/lib/libuhd.so* /usr/local/lib/
COPY --from=build /usr/local/lib/uhd/ /usr/local/lib/uhd/
COPY --from=build /usr/local/lib/python3/dist-packages/uhd/ /usr/lib/python3/dist-packages/uhd/
COPY --from=build /usr/local/include/uhd.h /usr/local/include/
COPY --from=build /usr/local/include/uhd/ /usr/local/include/uhd/
COPY --from=build /usr/local/bin/uhd_* /usr/local/bin/
COPY --from=build /usr/local/share/uhd/images/usrp_b2* /usr/local/share/uhd/images/

RUN apt-get update -q && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -qy --no-install-recommends \
libboost-date-time1.65.1 libboost-filesystem1.65.1 \
libboost-python1.65.1 libboost-regex1.65.1 \
libboost-serialization1.65.1 libboost-system1.65.1 \
libboost-thread1.65.1 libboost-program-options1.65.1 \
libusb-1.0-0 libpython3.7 \
python3 python3-pip \
python3-dev python3-uhd uhd-host \
&& \
apt-get clean && rm -rf /var/lib/apt/lists/*

CMD /usr/bin/python3.7
RUN uhd_images_downloader

CMD /usr/bin/python3
Loading