Skip to content

Commit

Permalink
Merge pull request #101 from anarkiwi/ghae2e
Browse files Browse the repository at this point in the history
enable end to end test in gha
  • Loading branch information
anarkiwi authored Oct 3, 2024
2 parents c799659 + 4d8744c commit 39c9d91
Show file tree
Hide file tree
Showing 8 changed files with 653 additions and 582 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ jobs:
- name: Install poetry and dependencies
# TODO: remove workaround for https://github.com/pytorch/pytorch/issues/100974 once torch upgraded.
run: |
sudo apt-get -yq update && sudo apt-get install -yq libnvidia-compute-535-server nvidia-cuda-dev
git submodule init && \
git submodule update && \
poetry config virtualenvs.create false && \
poetry install && \
for i in torch ; do poetry run pip install --no-cache-dir "$i"=="$(grep $i pyproject.toml | grep -Eo '\"[0-9\.]+' | sed 's/\"//g')" || exit 1 ; done
python3 -c "import torch" && \
for i in torch torchvision ; do poetry run pip install --no-cache-dir "$i"=="$(grep $i\\s pyproject.toml | grep -Eo '\"[0-9\.]+' | sed 's/\"//g')" || exit 1 ; done
python -c 'import torch' && \
python -c 'import rfml.annotation_utils as annotation_utils' && \
poetry run black . --check --force-exclude torchsig
- name: Run e2e test
run: |
mkdir -p testdata && DATA=$(realpath testdata) PYTHON=$(which python3) ./utils/end_to_end_siggen.sh
11 changes: 7 additions & 4 deletions experiments/siggen_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

torch.set_float32_matmul_precision("medium")
from rfml.experiment import *
import sys

root = sys.argv[1]

#
# python rfml/siggen_experiments.py
Expand All @@ -16,12 +19,12 @@
"siggen_experiment": {
"class_list": ["am", "fm"],
"train_dir": [
"/data/siggen/fm.sigmf-meta",
"/data/siggen/am.sigmf-meta",
f"{root}/fm.sigmf-meta",
f"{root}/am.sigmf-meta",
],
"val_dir": [
"/data/siggen/fm.sigmf-meta",
"/data/siggen/am.sigmf-meta",
f"{root}/fm.sigmf-meta",
f"{root}/am.sigmf-meta",
],
"iq_epochs": 10,
"iq_train_limit": 0.5,
Expand Down
7 changes: 5 additions & 2 deletions label_scripts/label_siggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@

import rfml.annotation_utils as annotation_utils
import rfml.data as data_class
import sys

root = sys.argv[1]

# generated with
# $ for i in am fm ; do /scratch/iqtlabs/rfml/utils/siggen.py --samp_rate 1000000 --siggen $i --int_count 1000 ; done
data_globs = {
"am": ["/data/siggen/am.sigmf-meta"],
"fm": ["/data/siggen/fm.sigmf-meta"],
"am": [f"{root}/am.sigmf-meta"],
"fm": [f"{root}/fm.sigmf-meta"],
}


Expand Down
1,151 changes: 597 additions & 554 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ python-on-whales = "^0.73.0"
sigmf = "^1.2.0"
tqdm = "^4.66.4"
torch = "2.0.1"
torchvision = "0.15.2"
torch-model-archiver = "^0.12.0"
torchsig = {path = "torchsig"}
cupy-cuda12x = "^13.2.0"
cupy-cuda11x = "13.3.0"
ultralytics = "^8.2.79"


Expand Down
2 changes: 1 addition & 1 deletion rfml/train_iq.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def train_iq(
),
checkpoint_callback,
],
accelerator="gpu",
accelerator="auto",
devices=1,
logger=logger,
# profiler="simple",
Expand Down
32 changes: 21 additions & 11 deletions utils/end_to_end_siggen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,40 @@ if [ "$0" != "./utils/end_to_end_siggen.sh" ] ; then
exit 1
fi

if [ ! -w /data ] ; then
echo /data must exist and be writable
DATA="${DATA:=/data}"

if [ ! -w $DATA ] ; then
echo $DATA must exist and be writable
exit 1
fi

rm -rf /data/siggen
mkdir -p /data/siggen
mkdir -p /data/siggen/test
mkdir -p /data/model_store
PYTHON="${PYTHON:=python3}"
NUMBERS="${NUMBERS:=4}"
SRATE="${SRATE:=500000}"

echo using python $PYTHON

git clone https://github.com/iqtlabs/gamutrf-deploy /data/gamutrf-deploy
rm -rf $DATA/siggen
mkdir -p $DATA/siggen
mkdir -p $DATA/siggen/test
mkdir -p $DATA/model_store

git clone https://github.com/iqtlabs/gamutrf-deploy $DATA/gamutrf-deploy

# generate both training and test data
docker build -f utils/Dockerfile.siggen utils -t iqtlabs/rfml-siggen
for i in am fm ; do
for o in /data/siggen/$i /data/siggen/test/$i ; do
docker run -v /data/siggen:/data/siggen -u $(id -u ${USER}):$(id -g ${USER}) -t iqtlabs/rfml-siggen /siggen.py --samp_rate 1000000 --siggen $i --int_count 100 --sample_file $o
docker run -v $DATA/siggen:/data/siggen -t iqtlabs/rfml-siggen /siggen.py --samp_rate $SRATE --siggen $i --int_count $NUMBERS --sample_file $o
done
done

sudo chown -R $(id -u):$(id -g) $DATA/siggen

# label data and produce model
python label_scripts/label_siggen.py
python experiments/siggen_experiments.py
cp models/siggen_experiment.mar /data/model_store/torchsig_model.mar
$PYTHON label_scripts/label_siggen.py $DATA/siggen
$PYTHON experiments/siggen_experiments.py $DATA/siggen
cp models/siggen_experiment.mar $DATA/model_store/torchsig_model.mar

# run inference
./utils/gamutrf_offline_siggen.sh
20 changes: 13 additions & 7 deletions utils/gamutrf_offline_siggen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

set -e

docker compose -f /data/gamutrf-deploy/offline.yml down --remove-orphans
docker compose -f /data/gamutrf-deploy/torchserve-cuda.yml down --remove-orphans
VOL_PREFIX=/data docker compose -f /data/gamutrf-deploy/torchserve-cuda.yml up -d
PYTHON="${PYTHON:=python3}"
TORCHSERVE="${TORCHSERVE:=torchserve.yml}"
OFFLINE="${OFFLINE:=offline.yml}"
DATA="${DATA:=/data}"


docker compose -f $DATA/gamutrf-deploy/$OFFLINE down --remove-orphans
docker compose -f $DATA/gamutrf-deploy/$TORCHSERVE down --remove-orphans
VOL_PREFIX=$DATA docker compose -f $DATA/gamutrf-deploy/$TORCHSERVE up -d

for i in am fm ; do
sudo rm -rf /data/samples
VOL_PREFIX=/data RECORDING=/logs/siggen/test/$i.sigmf-meta docker compose -f /data/gamutrf-deploy/offline.yml up gamutrf
sudo rm -rf $DATA/samples
VOL_PREFIX=$DATA RECORDING=/logs/siggen/test/$i.sigmf-meta docker compose -f $DATA/gamutrf-deploy/$OFFLINE up gamutrf
echo $i
./utils/count_labels.py /data/samples/*/*sigmf-meta $i
$PYTHON ./utils/count_labels.py $DATA/samples/*/*sigmf-meta $i
done

VOL_PREFIX=/data docker compose -f /data/gamutrf-deploy/torchserve-cuda.yml down
VOL_PREFIX=$DATA docker compose -f $DATA/gamutrf-deploy/$TORCHSERVE down

0 comments on commit 39c9d91

Please sign in to comment.