Skip to content

Commit

Permalink
format.
Browse files Browse the repository at this point in the history
  • Loading branch information
anarkiwi committed Jan 9, 2024
1 parent aba15b2 commit 1d764ac
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libvulkan-dev \
python3-numpy
WORKDIR /root
RUN ls -l && git clone https://github.com/anarkiwi/gr-iqtlabs -b s2
RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.63
COPY --from=iqtlabs/gamutrf-vkfft:latest /root /root/gr-iqtlabs
WORKDIR /root/gr-iqtlabs/build
COPY --from=sigmf-builder /usr/local /usr/local
Expand Down
2 changes: 1 addition & 1 deletion gamutrf/grscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def __init__(
self.connect_blocks(self.inference_blocks[0], self.inference_blocks[1:])
self.connect_blocks(
self.inference_blocks[0],
[zeromq.pub_sink(1, 1, inference_zmq_addr, 100, False, 8192, "")],
[zeromq.pub_sink(1, 1, inference_zmq_addr, 100, False, 65536, "")],
)
else:
self.connect((retune_fft, 1), (blocks.null_sink(gr.sizeof_float * nfft)))
Expand Down
51 changes: 22 additions & 29 deletions gamutrfwaterfall/gamutrfwaterfall/waterfall.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import argparse
import csv
import datetime
import glob
import json
import logging
import multiprocessing
import os
import shutil
import signal
import tempfile
import threading
import time
import warnings
import zmq
from pathlib import Path

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import zmq
from flask import Flask, current_app, send_file
from matplotlib.collections import LineCollection
from matplotlib.ticker import MultipleLocator, AutoMinorLocator
Expand Down Expand Up @@ -56,7 +54,7 @@ def draw_title(
freq_resolution,
):
title_text = {
"Time": str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
"Time": str(datetime.datetime.now().isoformat()),
"Scan time": "%.2fs" % scan_duration,
"Step FFTs": "%u" % tune_step_fft,
"Step size": "%.2fMHz" % (tune_step_hz / 1e6),
Expand Down Expand Up @@ -1102,7 +1100,7 @@ def poll_zmq(self):

def write_content(content):
tmpfile = os.path.join(self.static_folder, "." + self.predictions_file)
with open(tmpfile, "w") as f:
with open(tmpfile, "w", encoding="utf8") as f:
f.write(

Check warning on line 1104 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1101-L1104

Added lines #L1101 - L1104 were not covered by tests
'<html><head><meta http-equiv="refresh" content="%u"></head><body>%s</body></html>'
% (self.refresh, content)
Expand All @@ -1118,7 +1116,6 @@ def write_content(content):
json_buffer += sock_txt
except zmq.error.Again:
pass
new_predictions = False
while True:
delim_pos = json_buffer.find(DELIM)
if delim_pos == -1:
Expand All @@ -1127,38 +1124,34 @@ def write_content(content):
json_buffer = json_buffer[delim_pos + len(DELIM) :]
try:
item = json.loads(raw_item)
except json.decoder.JSONDecodeError as e:
except json.decoder.JSONDecodeError:
continue
ts = float(item["metadata"]["ts"])
if "predictions_image_path" not in item["metadata"]:
continue
item_buffer.append(item)
new_predictions = True

if new_predictions:
item_buffer = item_buffer[-self.predictions :]
predictions = sorted(
[(float(item["metadata"]["ts"]), item) for item in item_buffer]
)[-self.predictions :]
images = []
now = time.time()
for ts, item in sorted(predictions, reverse=True):
image = item["metadata"]["predictions_image_path"]
ctime = os.stat(image).st_ctime
images.append(
"%s (age %.1fs, ctime age %.1fs)<p><img src=%s></img></p>"
% (image, now - ts, now - ctime, image)
)
write_content("".join(images))
else:
time.sleep(0.1)
ts = float(item["metadata"]["ts"])
item_buffer.append((ts, item))
item_buffer = item_buffer[-self.predictions :]
predictions = sorted(item_buffer, key=lambda x: x[0], reverse=True)
images = []
now = time.time()
for ts, item in predictions:
image = item["metadata"]["predictions_image_path"]
images.append(

Check warning on line 1140 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1112-L1140

Added lines #L1112 - L1140 were not covered by tests
"%s (age %.1fs)<p><img src=%s></img></p>" % (image, now - ts, image)
)
if images:
write_content(

Check warning on line 1144 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1143-L1144

Added lines #L1143 - L1144 were not covered by tests
f"<p>{datetime.datetime.now().isoformat()}</p>" + "".join(images)
)
time.sleep(0.1)

Check warning on line 1147 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1147

Added line #L1147 was not covered by tests

def serve(self, path):
if path:
full_path = os.path.realpath(os.path.join("/", path))
if os.path.exists(full_path):
return send_file(full_path, mimetype="image/png")
else:
return "%s: not found" % full_path, 404
return "%s: not found" % full_path, 404

Check warning on line 1154 in gamutrfwaterfall/gamutrfwaterfall/waterfall.py

View check run for this annotation

Codecov / codecov/patch

gamutrfwaterfall/gamutrfwaterfall/waterfall.py#L1154

Added line #L1154 was not covered by tests
if os.path.exists(self.savefig_path):
return (
'<html><head><meta http-equiv="refresh" content="%u"></head><body><img src="%s"></img></body></html>'
Expand Down
6 changes: 3 additions & 3 deletions orchestrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ services:
- --inference_addr=0.0.0.0
- --inference_port=10001
- --inference_min_confidence=0.25
- --inference_min_db=-80
- --inference_min_db=-1e9
- --inference_model_name=mini2_snr
- --n_inference=20
- --n_image=20
- --n_inference=10
- --n_image=10
- --no-vkfft
- --rotate_secs=300
# - --external_gps_server=1.2.3.4
Expand Down

0 comments on commit 1d764ac

Please sign in to comment.