From 0bfefce17916301b5f26404ff150d176da529b3b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 17:28:11 +0000 Subject: [PATCH 1/9] Update dependency httpx to v0.25.1 --- poetry.lock | 11 ++++++----- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/poetry.lock b/poetry.lock index 07b80eac..bb0ff7d4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -821,19 +821,20 @@ socks = ["socksio (>=1.0.0,<2.0.0)"] [[package]] name = "httpx" -version = "0.25.0" +version = "0.25.1" description = "The next generation HTTP client." category = "main" optional = false python-versions = ">=3.8" files = [ - {file = "httpx-0.25.0-py3-none-any.whl", hash = "sha256:181ea7f8ba3a82578be86ef4171554dd45fec26a02556a744db029a0a27b7100"}, - {file = "httpx-0.25.0.tar.gz", hash = "sha256:47ecda285389cb32bb2691cc6e069e3ab0205956f681c5b2ad2325719751d875"}, + {file = "httpx-0.25.1-py3-none-any.whl", hash = "sha256:fec7d6cc5c27c578a391f7e87b9aa7d3d8fbcd034f6399f9f79b45bcc12a866a"}, + {file = "httpx-0.25.1.tar.gz", hash = "sha256:ffd96d5cf901e63863d9f1b4b6807861dbea4d301613415d9e6e57ead15fc5d0"}, ] [package.dependencies] +anyio = "*" certifi = "*" -httpcore = ">=0.18.0,<0.19.0" +httpcore = "*" idna = "*" sniffio = "*" @@ -2720,4 +2721,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.13" -content-hash = "50f1c757ca89cb9d5f7c25b6ab2286abb75d9be61d6c633fe1de951c82562c4c" +content-hash = "03542c777f8802206a06a26fbb56b719859ab6607c8e254af4f3e4a45cc75715" diff --git a/pyproject.toml b/pyproject.toml index 2cd45882..36766eb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ falcon = "3.1.1" falcon-cors = "1.1.7" findpeaks = "2.5.5" gpsd-py3 = "0.3.0" -httpx = "0.25.0" +httpx = "0.25.1" Jinja2 = "3.1.2" matplotlib = "3.8.1" numpy = "1.26.1" From 7fdfed35fe9ea47ea25c5fb7f005053c03c403e3 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Mon, 6 Nov 2023 03:02:47 +0000 Subject: [PATCH 2/9] Build gamutRF image with bespoke torchsig libraries, for new augmentaton script. --- .github/workflows/docker-test.yml | 1 + .github/workflows/docker.yml | 9 +++++++++ docker/Dockerfile.torchsig | 14 ++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 docker/Dockerfile.torchsig diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 7f61bfac..9f6498fe 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -29,6 +29,7 @@ jobs: docker build -f Dockerfile.base . -t iqtlabs/gamutrf-base:latest cd .. docker build -f Dockerfile . -t iqtlabs/gamutrf:latest + docker build -f docker/Dockerfile.torchsig docker -t iqtlabs/gamutrf-torchsig:latest docker run -t iqtlabs/gamutrf:latest gamutrf-scan --help docker run -t iqtlabs/gamutrf:latest gamutrf-sigfinder --help docker run -t iqtlabs/gamutrf:latest gamutrf-api --help diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 23dfce09..fdc0e0a5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -84,3 +84,12 @@ jobs: push: true tags: iqtlabs/gamutrf:${{ steps.change_version.outputs.VERSION }} if: github.repository == 'iqtlabs/gamutrf' && github.event_name == 'push' + - name: Build and push gamutrf-torchsig + uses: docker/build-push-action@v5 + with: + context: docker + file: docker/Dockerfile.torchsig + platforms: linux/amd64,linux/arm64 + push: true + tags: iqtlabs/gamutrf-torchsig:${{ steps.change_version.outputs.VERSION }} + if: github.repository == 'iqtlabs/gamutrf' && github.event_name == 'push' diff --git a/docker/Dockerfile.torchsig b/docker/Dockerfile.torchsig new file mode 100644 index 00000000..b490d7ed --- /dev/null +++ b/docker/Dockerfile.torchsig @@ -0,0 +1,14 @@ +FROM ubuntu:22.04 as torchsig-builder +WORKDIR /root +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y --no-install-recommends build-essential ca-certificates cmake git python3-pip python3-dev && pip install -U pip +RUN pip install git+https://github.com/TorchDSP/torchsig@v0.4.1 + +FROM iqtlabs/gamutrf:latest +WORKDIR /root +ENV DEBIAN_FRONTEND noninteractive +# TODO: find a better way cherrypick just Torchsig itself, without Torch et al. +COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages/torchsig /usr/local/lib/python3.10/dist-packages/torchsig +RUN apt-get update && apt-get install -y --no-install-recommends python3-pip && pip3 install PyWavelets numba torch --extra-index-url https://download.pytorch.org/whl/cpu && apt-get purge -y python3-pip +RUN python3 -c "from torchsig.transforms import transforms" +RUN python3 -c "from gamutrf import grscan" From 10d83240b9e5a50028910ebc2e50340a8fa545ce Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Mon, 6 Nov 2023 03:31:04 +0000 Subject: [PATCH 3/9] hack torch pin. --- docker/Dockerfile.torchsig | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.torchsig b/docker/Dockerfile.torchsig index b490d7ed..77670121 100644 --- a/docker/Dockerfile.torchsig +++ b/docker/Dockerfile.torchsig @@ -2,13 +2,20 @@ FROM ubuntu:22.04 as torchsig-builder WORKDIR /root ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get install -y --no-install-recommends build-essential ca-certificates cmake git python3-pip python3-dev && pip install -U pip -RUN pip install git+https://github.com/TorchDSP/torchsig@v0.4.1 +# Cause torch CPU only to be installed, no cuda dependencies +RUN pip install torch --extra-index-url https://download.pytorch.org/whl/cpu +RUN git clone https://github.com/TorchDSP/torchsig -b v0.4.1 +WORKDIR /root/torchsig +RUN sed -i -E "s/torch==[0-9\.]+/torch/g" pyproject.toml +RUN pip install . FROM iqtlabs/gamutrf:latest WORKDIR /root ENV DEBIAN_FRONTEND noninteractive -# TODO: find a better way cherrypick just Torchsig itself, without Torch et al. +# TODO: find a better way cherrypick just Torchsig itself, without Torch et al. Torchsig transforms have dependencies on +# Torch, even though we don't need Torch for the standalone transforms we want. COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages/torchsig /usr/local/lib/python3.10/dist-packages/torchsig -RUN apt-get update && apt-get install -y --no-install-recommends python3-pip && pip3 install PyWavelets numba torch --extra-index-url https://download.pytorch.org/whl/cpu && apt-get purge -y python3-pip +COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages/torch /usr/local/lib/python3.10/dist-packages/torch +RUN apt-get update && apt-get install -y --no-install-recommends python3-pip && pip3 install PyWavelets numba && apt-get purge -y python3-pip RUN python3 -c "from torchsig.transforms import transforms" RUN python3 -c "from gamutrf import grscan" From a42d368cd2bfd63a4dcaff11f11b87a879012132 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Mon, 6 Nov 2023 03:42:39 +0000 Subject: [PATCH 4/9] smaller. --- docker/Dockerfile.torchsig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker/Dockerfile.torchsig b/docker/Dockerfile.torchsig index 77670121..94ab31a7 100644 --- a/docker/Dockerfile.torchsig +++ b/docker/Dockerfile.torchsig @@ -14,8 +14,6 @@ WORKDIR /root ENV DEBIAN_FRONTEND noninteractive # TODO: find a better way cherrypick just Torchsig itself, without Torch et al. Torchsig transforms have dependencies on # Torch, even though we don't need Torch for the standalone transforms we want. -COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages/torchsig /usr/local/lib/python3.10/dist-packages/torchsig -COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages/torch /usr/local/lib/python3.10/dist-packages/torch -RUN apt-get update && apt-get install -y --no-install-recommends python3-pip && pip3 install PyWavelets numba && apt-get purge -y python3-pip +COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages RUN python3 -c "from torchsig.transforms import transforms" RUN python3 -c "from gamutrf import grscan" From 2948f9b363f78e7c0afa72c926abd7cb1571d195 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Mon, 6 Nov 2023 23:07:47 +0000 Subject: [PATCH 5/9] torchsig augmentation script. --- .github/workflows/docker-test.yml | 2 +- .github/workflows/docker.yml | 2 +- augment/augment.py | 140 ++++++++++++++++++++++++++++++ docker/Dockerfile.torchsig | 2 + 4 files changed, 144 insertions(+), 2 deletions(-) create mode 100755 augment/augment.py diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 9f6498fe..d7b7cd66 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -29,7 +29,7 @@ jobs: docker build -f Dockerfile.base . -t iqtlabs/gamutrf-base:latest cd .. docker build -f Dockerfile . -t iqtlabs/gamutrf:latest - docker build -f docker/Dockerfile.torchsig docker -t iqtlabs/gamutrf-torchsig:latest + docker build -f docker/Dockerfile.torchsig . -t iqtlabs/gamutrf-torchsig:latest docker run -t iqtlabs/gamutrf:latest gamutrf-scan --help docker run -t iqtlabs/gamutrf:latest gamutrf-sigfinder --help docker run -t iqtlabs/gamutrf:latest gamutrf-api --help diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fdc0e0a5..8354b4f2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -87,7 +87,7 @@ jobs: - name: Build and push gamutrf-torchsig uses: docker/build-push-action@v5 with: - context: docker + context: . file: docker/Dockerfile.torchsig platforms: linux/amd64,linux/arm64 push: true diff --git a/augment/augment.py b/augment/augment.py new file mode 100755 index 00000000..1c5d36c5 --- /dev/null +++ b/augment/augment.py @@ -0,0 +1,140 @@ +#!/usr/bin/python3 + +from argparse import ArgumentParser +import os +import sigmf +from sigmf import SigMFFile +from sigmf.utils import get_data_type_str +import numpy as np +import torchsig.transforms.transforms as ST +from torchsig.transforms.functional import ( + to_distribution, + uniform_continuous_distribution, + uniform_discrete_distribution, +) +from torchsig.utils.types import SignalData, SignalDescription +from gamutrf.sample_reader import read_recording +from gamutrf.waterfall_samples import parse_filename + + +def make_signal(samples, sample_rate, center_frequency): + num_iq_samples = samples.shape[0] + desc = SignalDescription( + sample_rate=sample_rate, + num_iq_samples=num_iq_samples, + center_frequency=center_frequency, + ) + # TODO: subclass SignalData with alternate constructor that can take just numpy array + signal = SignalData(samples.tobytes(), np.float32, np.complex128, desc) + return signal + + +def get_nosigmf_file(filename): + meta = parse_filename(filename) + sample_rate = meta["sample_rate"] + sample_dtype = meta["sample_dtype"] + sample_len = meta["sample_len"] + center_frequency = meta["freq_center"] + samples = None + for samples_buffer in read_recording( + filename, sample_rate, sample_dtype, sample_len, max_sample_secs=None + ): + if samples is None: + samples = samples_buffer + else: + samples = np.concatenate([samples, samples_buffer]) + signal = make_signal(samples, sample_rate, center_frequency) + return filename, signal + + +def get_signal(filename): + if not os.path.exists(filename): + raise FileNotFoundError(filename) + meta_ext = filename.find(".sigmf-meta") + if meta_ext == -1: + return get_nosigmf_file(filename) + + meta = sigmf.sigmffile.fromfile(filename) + data_filename = filename[:meta_ext] + meta.set_data_file(data_filename) + # read_samples() always converts to host cf32. + samples = meta.read_samples() + global_meta = meta.get_global_info() + sample_rate = global_meta["core:sample_rate"] + sample_type = global_meta["core:datatype"] + captures_meta = meta.get_captures() + center_frequency = None + if captures_meta: + center_frequency = captures_meta[0].get("core:frequency", None) + signal = make_signal(samples, sample_rate, center_frequency) + return data_filename, signal + + +def write_signal(filename, signal, transforms_text): + first_desc = signal.signal_description[0] + signal.iq_data = signal.iq_data.astype(np.complex64) + signal.iq_data.tofile(filename) + + new_meta = SigMFFile( + data_file=filename, + global_info={ + SigMFFile.DATATYPE_KEY: get_data_type_str(signal.iq_data), + SigMFFile.SAMPLE_RATE_KEY: first_desc.sample_rate, + SigMFFile.VERSION_KEY: sigmf.__version__, + SigMFFile.DESCRIPTION_KEY: transforms_text, + }, + ) + new_meta.add_capture( + 0, + metadata={ + SigMFFile.FREQUENCY_KEY: first_desc.center_frequency, + }, + ) + new_meta.tofile(".".join([filename, "sigmf-meta"])) + + +def augment(signal, filename, output_dir, n, transforms_text): + # TODO: sadly, due to Torchsig complexity, literal_eval can't be used. + transforms = eval(transforms_text) # nosec + i = 0 + base_augment_name = os.path.basename(filename) + dot = base_augment_name.find(".") + if dot != "-1": + base_augment_name = base_augment_name[:dot] + for _ in range(n): + while True: + augment_name = os.path.join( + output_dir, f"augmented-{i}-{base_augment_name}" + ) + if not os.path.exists(augment_name): + break + i += 1 + new_signal = transforms(signal) + write_signal(augment_name, new_signal, transforms_text) + + +def argument_parser(): + parser = ArgumentParser() + parser.add_argument( + "filename", + type=str, + help="sigMF file or gamutRF zst recording", + ) + parser.add_argument("outdir", type=str, help="output directory") + parser.add_argument("n", type=int, help="number of augmentation passes") + parser.add_argument( + "transforms", + type=str, + help="transforms to eval, e.g. ST.Compose([ST.AddNoise((-40, -20)),ST.RandomPhaseShift(uniform_continuous_distribution(-1, 1))]) (use quotes)", + ) + return parser + + +def main(): + options = argument_parser().parse_args() + data_filename, signal = get_signal(options.filename) + augment(signal, data_filename, options.outdir, options.n, options.transforms) + + +if __name__ == "__main__": + main() diff --git a/docker/Dockerfile.torchsig b/docker/Dockerfile.torchsig index 94ab31a7..aac65d94 100644 --- a/docker/Dockerfile.torchsig +++ b/docker/Dockerfile.torchsig @@ -17,3 +17,5 @@ ENV DEBIAN_FRONTEND noninteractive COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages /usr/local/lib/python3.10/dist-packages RUN python3 -c "from torchsig.transforms import transforms" RUN python3 -c "from gamutrf import grscan" +COPY augment/augment.py /root/augment.py +ENTRYPOINT ["/root/augment.py"] From d231e298a414445d6f682df952778d65a88cb2ac Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Tue, 7 Nov 2023 02:50:04 +0000 Subject: [PATCH 6/9] very basic augment integration test. --- augment/augment.py | 2 +- docker/Dockerfile.torchsig | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/augment/augment.py b/augment/augment.py index 1c5d36c5..54fa1c9d 100755 --- a/augment/augment.py +++ b/augment/augment.py @@ -99,7 +99,7 @@ def augment(signal, filename, output_dir, n, transforms_text): i = 0 base_augment_name = os.path.basename(filename) dot = base_augment_name.find(".") - if dot != "-1": + if dot != -1: base_augment_name = base_augment_name[:dot] for _ in range(n): while True: diff --git a/docker/Dockerfile.torchsig b/docker/Dockerfile.torchsig index aac65d94..807e69a4 100644 --- a/docker/Dockerfile.torchsig +++ b/docker/Dockerfile.torchsig @@ -18,4 +18,6 @@ COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages /usr/local/ RUN python3 -c "from torchsig.transforms import transforms" RUN python3 -c "from gamutrf import grscan" COPY augment/augment.py /root/augment.py +RUN dd if=/dev/zero of=/tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw bs=8 count=1000 && /root/augment.py /tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw /tmp 1 "ST.Compose([ST.Identity()])" && diff -b /tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw /tmp/augmented-0-gamutrf_recording_ettus__gain40_1_1Hz_1000sps && rm -f /tmp/gamutrf* + ENTRYPOINT ["/root/augment.py"] From 449c39d3e6d9b43a2ee586845e7b5fde47d4976d Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Tue, 7 Nov 2023 03:07:22 +0000 Subject: [PATCH 7/9] help message. --- augment/augment.py | 6 ++++-- docker/Dockerfile.torchsig | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/augment/augment.py b/augment/augment.py index 54fa1c9d..d0edb679 100755 --- a/augment/augment.py +++ b/augment/augment.py @@ -95,7 +95,7 @@ def write_signal(filename, signal, transforms_text): def augment(signal, filename, output_dir, n, transforms_text): # TODO: sadly, due to Torchsig complexity, literal_eval can't be used. - transforms = eval(transforms_text) # nosec + transforms = eval(transforms_text) # nosec i = 0 base_augment_name = os.path.basename(filename) dot = base_augment_name.find(".") @@ -114,7 +114,9 @@ def augment(signal, filename, output_dir, n, transforms_text): def argument_parser(): - parser = ArgumentParser() + parser = ArgumentParser( + description="Run transforms on a recording from https://github.com/TorchDSP/torchsig/blob/main/torchsig/transforms/transforms.py" + ) parser.add_argument( "filename", type=str, diff --git a/docker/Dockerfile.torchsig b/docker/Dockerfile.torchsig index 807e69a4..4a027092 100644 --- a/docker/Dockerfile.torchsig +++ b/docker/Dockerfile.torchsig @@ -18,6 +18,6 @@ COPY --from=torchsig-builder /usr/local/lib/python3.10/dist-packages /usr/local/ RUN python3 -c "from torchsig.transforms import transforms" RUN python3 -c "from gamutrf import grscan" COPY augment/augment.py /root/augment.py -RUN dd if=/dev/zero of=/tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw bs=8 count=1000 && /root/augment.py /tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw /tmp 1 "ST.Compose([ST.Identity()])" && diff -b /tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw /tmp/augmented-0-gamutrf_recording_ettus__gain40_1_1Hz_1000sps && rm -f /tmp/gamutrf* +RUN dd if=/dev/zero of=/tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw bs=8 count=1000 && /root/augment.py /tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw /tmp 1 "ST.Compose([ST.Identity()])" && diff -b /tmp/gamutrf_recording_ettus__gain40_1_1Hz_1000sps.raw /tmp/augmented-0-gamutrf_recording_ettus__gain40_1_1Hz_1000sps && rm -f /tmp/gamutrf* ENTRYPOINT ["/root/augment.py"] From 4c934777aeb0425f73e26882d8b9607791da16c3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 Nov 2023 06:25:05 +0000 Subject: [PATCH 8/9] Update dependency black to v23.11.0 --- poetry.lock | 40 ++++++++++++++++++++-------------------- pyproject.toml | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/poetry.lock b/poetry.lock index bb0ff7d4..77f7d033 100644 --- a/poetry.lock +++ b/poetry.lock @@ -81,30 +81,30 @@ files = [ [[package]] name = "black" -version = "23.10.1" +version = "23.11.0" description = "The uncompromising code formatter." category = "dev" optional = false python-versions = ">=3.8" files = [ - {file = "black-23.10.1-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:ec3f8e6234c4e46ff9e16d9ae96f4ef69fa328bb4ad08198c8cee45bb1f08c69"}, - {file = "black-23.10.1-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:1b917a2aa020ca600483a7b340c165970b26e9029067f019e3755b56e8dd5916"}, - {file = "black-23.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c74de4c77b849e6359c6f01987e94873c707098322b91490d24296f66d067dc"}, - {file = "black-23.10.1-cp310-cp310-win_amd64.whl", hash = "sha256:7b4d10b0f016616a0d93d24a448100adf1699712fb7a4efd0e2c32bbb219b173"}, - {file = "black-23.10.1-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:b15b75fc53a2fbcac8a87d3e20f69874d161beef13954747e053bca7a1ce53a0"}, - {file = "black-23.10.1-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:e293e4c2f4a992b980032bbd62df07c1bcff82d6964d6c9496f2cd726e246ace"}, - {file = "black-23.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7d56124b7a61d092cb52cce34182a5280e160e6aff3137172a68c2c2c4b76bcb"}, - {file = "black-23.10.1-cp311-cp311-win_amd64.whl", hash = "sha256:3f157a8945a7b2d424da3335f7ace89c14a3b0625e6593d21139c2d8214d55ce"}, - {file = "black-23.10.1-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:cfcce6f0a384d0da692119f2d72d79ed07c7159879d0bb1bb32d2e443382bf3a"}, - {file = "black-23.10.1-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:33d40f5b06be80c1bbce17b173cda17994fbad096ce60eb22054da021bf933d1"}, - {file = "black-23.10.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:840015166dbdfbc47992871325799fd2dc0dcf9395e401ada6d88fe11498abad"}, - {file = "black-23.10.1-cp38-cp38-win_amd64.whl", hash = "sha256:037e9b4664cafda5f025a1728c50a9e9aedb99a759c89f760bd83730e76ba884"}, - {file = "black-23.10.1-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:7cb5936e686e782fddb1c73f8aa6f459e1ad38a6a7b0e54b403f1f05a1507ee9"}, - {file = "black-23.10.1-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:7670242e90dc129c539e9ca17665e39a146a761e681805c54fbd86015c7c84f7"}, - {file = "black-23.10.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5ed45ac9a613fb52dad3b61c8dea2ec9510bf3108d4db88422bacc7d1ba1243d"}, - {file = "black-23.10.1-cp39-cp39-win_amd64.whl", hash = "sha256:6d23d7822140e3fef190734216cefb262521789367fbdc0b3f22af6744058982"}, - {file = "black-23.10.1-py3-none-any.whl", hash = "sha256:d431e6739f727bb2e0495df64a6c7a5310758e87505f5f8cde9ff6c0f2d7e4fe"}, - {file = "black-23.10.1.tar.gz", hash = "sha256:1f8ce316753428ff68749c65a5f7844631aa18c8679dfd3ca9dc1a289979c258"}, + {file = "black-23.11.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dbea0bb8575c6b6303cc65017b46351dc5953eea5c0a59d7b7e3a2d2f433a911"}, + {file = "black-23.11.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:412f56bab20ac85927f3a959230331de5614aecda1ede14b373083f62ec24e6f"}, + {file = "black-23.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d136ef5b418c81660ad847efe0e55c58c8208b77a57a28a503a5f345ccf01394"}, + {file = "black-23.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:6c1cac07e64433f646a9a838cdc00c9768b3c362805afc3fce341af0e6a9ae9f"}, + {file = "black-23.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cf57719e581cfd48c4efe28543fea3d139c6b6f1238b3f0102a9c73992cbb479"}, + {file = "black-23.11.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:698c1e0d5c43354ec5d6f4d914d0d553a9ada56c85415700b81dc90125aac244"}, + {file = "black-23.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:760415ccc20f9e8747084169110ef75d545f3b0932ee21368f63ac0fee86b221"}, + {file = "black-23.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:58e5f4d08a205b11800332920e285bd25e1a75c54953e05502052738fe16b3b5"}, + {file = "black-23.11.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:45aa1d4675964946e53ab81aeec7a37613c1cb71647b5394779e6efb79d6d187"}, + {file = "black-23.11.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4c44b7211a3a0570cc097e81135faa5f261264f4dfaa22bd5ee2875a4e773bd6"}, + {file = "black-23.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2a9acad1451632021ee0d146c8765782a0c3846e0e0ea46659d7c4f89d9b212b"}, + {file = "black-23.11.0-cp38-cp38-win_amd64.whl", hash = "sha256:fc7f6a44d52747e65a02558e1d807c82df1d66ffa80a601862040a43ec2e3142"}, + {file = "black-23.11.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:7f622b6822f02bfaf2a5cd31fdb7cd86fcf33dab6ced5185c35f5db98260b055"}, + {file = "black-23.11.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:250d7e60f323fcfc8ea6c800d5eba12f7967400eb6c2d21ae85ad31c204fb1f4"}, + {file = "black-23.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5133f5507007ba08d8b7b263c7aa0f931af5ba88a29beacc4b2dc23fcefe9c06"}, + {file = "black-23.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:421f3e44aa67138ab1b9bfbc22ee3780b22fa5b291e4db8ab7eee95200726b07"}, + {file = "black-23.11.0-py3-none-any.whl", hash = "sha256:54caaa703227c6e0c87b76326d0862184729a69b73d3b7305b6288e1d830067e"}, + {file = "black-23.11.0.tar.gz", hash = "sha256:4c68855825ff432d197229846f971bc4d6666ce90492e5b02013bcaca4d9ab05"}, ] [package.dependencies] @@ -2721,4 +2721,4 @@ cffi = ["cffi (>=1.11)"] [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.13" -content-hash = "03542c777f8802206a06a26fbb56b719859ab6607c8e254af4f3e4a45cc75715" +content-hash = "3175b91e4dbf9d69e2f3e96a67e432ec79c92d6d212d33959098bd3bff82d1a5" diff --git a/pyproject.toml b/pyproject.toml index 36766eb2..81813700 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,7 @@ pyzmq = "^25.1.0" [tool.poetry.dev-dependencies] attr = "0.3.2" attrs = "23.1.0" -black = "23.10.1" +black = "23.11.0" docker = "6.1.3" pylint = "3.0.2" pytest = "7.4.3" From c79842f763198d9c325650c0a20d13ce42b33c34 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Wed, 8 Nov 2023 19:23:09 +0000 Subject: [PATCH 9/9] Rename API container to worker, which is actually what it is. --- .github/workflows/docker-test.yml | 2 +- bin/gamutrf | 4 ++-- docs/BUILD.md | 4 ++-- gamutrf/__main__.py | 8 ++++---- gamutrf/{api.py => worker.py} | 0 pyproject.toml | 2 +- tests/test_api.py | 12 ++++++------ tests/test_birdseye_rssi.py | 2 +- tests/test_main.py | 6 +++--- worker.yml | 4 ++-- 10 files changed, 22 insertions(+), 22 deletions(-) rename gamutrf/{api.py => worker.py} (100%) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index d7b7cd66..9a01443a 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -32,7 +32,7 @@ jobs: docker build -f docker/Dockerfile.torchsig . -t iqtlabs/gamutrf-torchsig:latest docker run -t iqtlabs/gamutrf:latest gamutrf-scan --help docker run -t iqtlabs/gamutrf:latest gamutrf-sigfinder --help - docker run -t iqtlabs/gamutrf:latest gamutrf-api --help + docker run -t iqtlabs/gamutrf:latest gamutrf-worker --help docker run -t iqtlabs/gamutrf:latest gamutrf-samples2raw --help docker run -t iqtlabs/gamutrf:latest gamutrf-freqxlator --help docker run -t iqtlabs/gamutrf:latest gamutrf-waterfall --help diff --git a/bin/gamutrf b/bin/gamutrf index 94794be8..77211bea 100644 --- a/bin/gamutrf +++ b/bin/gamutrf @@ -9,7 +9,7 @@ Options: -h, help print this help -i, install install GamutRF repo, optionally supply a version, tag, branch, or tarball -l, logs tail GamutRF logs - -r, run specify GamutRF tool to run (and any additional args for the tools), options include: 'api', 'freqxlator', 'samples2raw', 'scan', 'sigfinder', 'specgram' + -r, run specify GamutRF tool to run (and any additional args for the tools), options include: 'worker', 'freqxlator', 'samples2raw', 'scan', 'sigfinder', 'specgram' -R, restart specify 'orchestrator' or 'worker' to restart -s, start specify 'orchestrator' or 'worker' to start -S, stop specify 'orchestrator' or 'worker' to stop @@ -136,7 +136,7 @@ function check_args() ;; -r|run) if [ -z "$2" ]; then - echo "Specify 'api', 'freqxlator', 'samples2raw', 'scan', 'sigfinder', or 'specgram' to run" + echo "Specify 'worker', 'freqxlator', 'samples2raw', 'scan', 'sigfinder', or 'specgram' to run" exit fi docker run -it -v "$VOLUME_DIR":/data iqtlabs/gamutrf:"$VERS" gamutrf-"$2" "${@:3}" diff --git a/docs/BUILD.md b/docs/BUILD.md index 6caa6417..8c80e9d5 100644 --- a/docs/BUILD.md +++ b/docs/BUILD.md @@ -295,7 +295,7 @@ If run in `recorder` mode (the default) no changes on the worker are needed, but If run in `RSSI` mode the `worker.yml` file under the gamutrf directory needs to be updated to include the following options: ``` - gamutrf-api: + gamutrf-worker: restart: always image: iqtlabs/gamutrf:latest networks: @@ -319,7 +319,7 @@ If run in `RSSI` mode the `worker.yml` file under the gamutrf directory needs to - nice - '-n' - '-19' - - gamutrf-api + - gamutrf-worker - --no-agc - --rxb=62914560 - '--gain=${GAIN}' diff --git a/gamutrf/__main__.py b/gamutrf/__main__.py index 29c21fa6..7455f5d2 100644 --- a/gamutrf/__main__.py +++ b/gamutrf/__main__.py @@ -1,5 +1,5 @@ """Main entrypoint for GamutRF""" -from gamutrf.api import main as api_main +from gamutrf.worker import main as worker_main from gamutrf.compress_dirs import main as compress_dirs_main from gamutrf.freqxlator import main as freqxlator_main from gamutrf.samples2raw import main as samples2raw_main @@ -9,9 +9,9 @@ from gamutrf.waterfall import main as waterfall_main -def api(): - """Entrypoint for API""" - api_main() +def worker(): + """Entrypoint for worker""" + worker_main() def compress_dirs(): diff --git a/gamutrf/api.py b/gamutrf/worker.py similarity index 100% rename from gamutrf/api.py rename to gamutrf/worker.py diff --git a/pyproject.toml b/pyproject.toml index 36766eb2..cb7ac36f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,7 @@ pytype = "2023.10.31" pdbpp = "^0.10.3" [tool.poetry.scripts] -gamutrf-api = 'gamutrf.__main__:api' +gamutrf-worker = 'gamutrf.__main__:worker' gamutrf-freqxlator = 'gamutrf.__main__:freqxlator' gamutrf-samples2raw = 'gamutrf.__main__:samples2raw' gamutrf-scan = 'gamutrf.__main__:scan' diff --git a/tests/test_api.py b/tests/test_api.py index 5206dc51..32826518 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -2,7 +2,7 @@ import pytest from falcon import testing -from gamutrf import api +from gamutrf import worker class FakeArgs: @@ -32,7 +32,7 @@ def __init__(self): @pytest.fixture(scope="module") def client(): - app = api.API(FakeArgs()) + app = worker.API(FakeArgs()) return testing.TestClient(app.app) @@ -46,21 +46,21 @@ def test_routes(client): def test_report_rssi(): - app = api.API(FakeArgs()) + app = worker.API(FakeArgs()) app.report_rssi({"center_freq": 1e6}, -35, time.time()) def test_serve_recording(): - app = api.API(FakeArgs()) + app = worker.API(FakeArgs()) app.q.put({"center_freq": 1e6, "sample_count": 1e6}) app.serve_recording(app.record) def test_serve_rssi(): - app = api.API(FakeArgs()) + app = worker.API(FakeArgs()) app.q.put({"center_freq": 1e6, "sample_count": 1e6, "sample_rate": 1e6}) app.serve_rssi() def test_argument_parse(): - api.argument_parser() + worker.argument_parser() diff --git a/tests/test_birdseye_rssi.py b/tests/test_birdseye_rssi.py index 0a006136..b4c1a71d 100644 --- a/tests/test_birdseye_rssi.py +++ b/tests/test_birdseye_rssi.py @@ -74,7 +74,7 @@ def test_birdseye_endtoend_rssi(self): command=[ "timeout", "60s", - "gamutrf-api", + "gamutrf-worker", "--rssi_threshold=-100", "--rssi", f"--sdr=file:{testraw}", diff --git a/tests/test_main.py b/tests/test_main.py index d869d25b..06d38c30 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,7 +1,7 @@ import pytest import sys -from gamutrf.__main__ import api +from gamutrf.__main__ import worker from gamutrf.__main__ import freqxlator from gamutrf.__main__ import samples2raw from gamutrf.__main__ import scan @@ -12,9 +12,9 @@ sys.argv.append("-h") -def test_main_api(): +def test_main_worker(): with pytest.raises(SystemExit) as pytest_wrapped_e: - api() + worker() assert pytest_wrapped_e.type == SystemExit assert pytest_wrapped_e.value.code == 0 diff --git a/worker.yml b/worker.yml index b9fcb791..358f44d9 100644 --- a/worker.yml +++ b/worker.yml @@ -4,7 +4,7 @@ version: "3.3" networks: gamutrf: services: - api: + worker: restart: always image: iqtlabs/gamutrf:latest networks: @@ -29,7 +29,7 @@ services: - nice - '-n' - '-19' - - gamutrf-api + - gamutrf-worker - --no-agc - --rxb=62914560 - '--gain=${GAIN}'