Skip to content

Commit

Permalink
fix: Fixes env, adds testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hui committed Nov 14, 2023
1 parent 708d8a5 commit f83569b
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 39 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/env_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, windows-latest, macos-12, macos-11]
python-version: ["3.8", "3.9"]
runs-on: ${{ matrix.os }}
runs-on: pyth
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -18,3 +18,6 @@ jobs:
run: |
python -m pip install --upgrade pip poetry
poetry install
- name: Run test
run: |
python -m pytest pyha_tests
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,5 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk

# End of https://www.toptal.com/developers/gitignore/api/jupyternotebooks,python,linux,macos,windows,visualstudiocode
# End of https://www.toptal.com/developers/gitignore/api/jupyternotebooks,python,linux,macos,windows,visualstudiocode
credentials.json
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"pyha_tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
161 changes: 126 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions pyha_tests/test_pyha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'''Tests PyHa environment
'''
import json
import os
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Dict

import pytest
from nas_unzip.nas import nas_unzip

from PyHa.IsoAutio import generate_automated_labels


@pytest.fixture(name='creds')
def create_creds() -> Dict[str, str]:
"""Obtains the credentials
Returns:
Dict[str, str]: Username and password dictionary
"""
if Path('credentials.json').is_file():
with open('credentials.json', 'r', encoding='ascii') as handle:
return json.load(handle)
else:
value = os.environ['NAS_CREDS'].splitlines()
assert len(value) == 2
return {
'username': value[0],
'password': value[1]
}


def test_pyha(creds):
"""Tests PyHa
"""
with TemporaryDirectory() as path:
nas_unzip(
network_path='smb://e4e-nas.ucsd.edu:6021/temp/github_actions/pyha/pyha_test.zip',
output_path=Path(path),
username=creds['username'],
password=creds['password']
)
isolation_parameters = {
"model": "tweetynet",
"tweety_output": True,
"technique": "steinberg",
"threshold_type": "median",
"threshold_const": 2.0,
"threshold_min": 0.0,
"window_size": 2.0,
"chunk_size": 5.0,
"verbose": True
}
generate_automated_labels(path, isolation_parameters)
isolation_parameters = {
"model": "birdnet",
"output_path": "outputs",
"lat": 35.4244,
"lon": -120.7463,
"week": 18,
"min_conf": 0.1,
"filetype": "wav",
"num_predictions": 1,
"write_to_csv": False,
}
generate_automated_labels(path, isolation_parameters)
isolation_parameters = {
"model": "microfaune",
"technique": "steinberg",
"threshold_type": "median",
"threshold_const": 2.0,
"threshold_min": 0.0,
"window_size": 2.0,
"chunk_size": 5.0,
"verbose": True
}
generate_automated_labels(path, isolation_parameters)
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry.group.dev.dependencies]
pylint = "^3.0.2"
pytest = "^7.4.3"
nas_unzip = { git="https://github.com/UCSD-E4E/synology-download.git", rev="dcca086" }
synology-api = "0.5.1"
autopep8 = "^2.0.4"

[tool.poetry.dependencies]
python = ">=3.8,<3.10"
Expand All @@ -36,13 +39,13 @@ jupyter = "^1.0.0"
scikit-learn = "^1.3.2"
seaborn = "^0.13.0"
keras = "^2.8.0"
pandas = "^1.2.3"
pandas = "^2.0.0"
matplotlib = "^3.4.1"
scipy = "^1.6.2"
torch = "^2.1.0"
tensorflow = {version = "^2.13.0" }
tensorflow-macos = { version = "^2.13.0", platform = "darwin", markers = "platform_machine=='arm64'" }
tensorflow-intel = { version = "^2.13.0", platform = "win32" }
tensorflow-intel = { version = "2.13.0", platform = "win32" }
tensorflow-cpu = [
{ version = "^2.13.0", platform = "linux", markers = "platform_machine!='arm64' and platform_machine!='aarch64'" },
{ version = "^2.13.0", platform = "darwin", markers = "platform_machine!='arm64' and platform_machine!='aarch64'" },
Expand Down

0 comments on commit f83569b

Please sign in to comment.