Skip to content

Commit

Permalink
Merge pull request #3 from ddasilva/unit-tests
Browse files Browse the repository at this point in the history
Fix Unit Tests and Add Github Actions
  • Loading branch information
MSKirk authored Sep 3, 2024
2 parents 33b7cb1 + 38ddaa5 commit cabab34
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 22 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test Suncet Data Processing Pipeline

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Install dependencies
- name: Install requiremetns
run: pip install -r requirements.txt
# Run unit tests
- name: Run Unit Tests
run: pytest -v
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SunCET Data Processing Pipeline

## Instructions
The SunCET Data Processing Pipeline is written in Python. To use the software, the first step is to clone the repository and install the dependencies. The dependencies may be installed through one of two routes. First, one may use the `environment.yml` file with [Anaconda](https://www.anaconda.com/) or a compatible replacement (such as [Miniconda](https://docs.anaconda.com/miniconda/), [Mamba](https://mamba.readthedocs.io/en/latest/) or [Micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)). The `environment.yml` route only uses the free channels (conda-forge), which do not require a paid account. Alternatively, one can use the `requirements.txt` file directly with `pip`.
The SunCET Data Processing Pipeline is written in Python. To use the software, the first step is to clone the repository and install the dependencies. The dependencies may be installed through one of two routes. First, one may use the `environment.yml` file with [Anaconda](https://www.anaconda.com/) or a compatible replacement (such as [Miniconda](https://docs.anaconda.com/miniconda/), [Mamba](https://mamba.readthedocs.io/en/latest/) or [Micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html)). The `environment.yml` route only uses the free channels (conda-forge), which do not require a paid account. Alternatively, one can use the `requirements.txt` file directly with `pip` (Python 3.9 and 3.10 only).

To use the `environment.yml` route, run the following line. The `conda` command can be replaced with `mamba` or `micromamba` as needed.

Expand Down Expand Up @@ -37,6 +37,13 @@ To delete a run from disk, all thats needed is to delete its directory:
$ rm -r processing_runs/MYRUN`
```

## Running the tests
To run the tests, run the following command from the top-level directory:

```
$ pytest -v
```

## Discussion: Input
* To get to Level 0b: Raw binary files downlinked from the spacecraft
* To get to Level 0c, 1, and 2: the output of the preceding level
Expand Down
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ channels:
dependencies:
- pip >=22.1
- python=3.10
- pytest=7.1
- pytest-cov=3.0
- numpy=1.22
- matplotlib=3.5
Expand All @@ -21,5 +20,5 @@ dependencies:
- gnuradio=3.10.5.1
- gnuradio-satellites=5.2.0
- termcolor==2.4.0

- pytest==7.1.3
#prefix: ~/anaconda3
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
numpy==1.22
matplotlib==3.5
pytest==7.1
pytest-cov==3.0
jupyter==1.0
scipy==1.8.1
Expand All @@ -12,3 +11,4 @@ netCDF4==1.6.0
h5netcdf==1.1.0
bottleneck==1.3.7
termcolor==2.4.0
pytest==7.1.3
Empty file.
17 changes: 17 additions & 0 deletions suncet_processing_pipeline/tests/config_parser_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from .. import config_parser


def test_read_default_config():
default_config = os.path.join(
os.path.dirname(__file__), '..', 'config_files',
'config_default.ini'
)
config = config_parser.Config(default_config)

assert hasattr(config, 'make_level0_5')
assert hasattr(config, 'make_level1')
assert hasattr(config, 'make_level2')
assert hasattr(config, 'make_level3')
assert hasattr(config, 'make_level4')
12 changes: 12 additions & 0 deletions suncet_processing_pipeline/tests/make_level1_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
from .. import config_parser, make_level1


def test_Level1_object_instantiates():
default_config = os.path.join(
os.path.dirname(__file__), '..', 'config_files',
'config_default.ini'
)
config = config_parser.Config(default_config)
make_level1.Level1(config)

2 changes: 2 additions & 0 deletions suncet_processing_pipeline/tests/make_level2_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import os
from .. import config_parser, make_level2
12 changes: 12 additions & 0 deletions suncet_processing_pipeline/tests/make_level3_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
from .. import config_parser, make_level3


def test_Level3_object_instantiates():
default_config = os.path.join(
os.path.dirname(__file__), '..', 'config_files',
'config_default.ini'
)
config = config_parser.Config(default_config)
make_level3.Level3(config)

3 changes: 3 additions & 0 deletions suncet_processing_pipeline/tests/make_level4_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os
from .. import config_parser, make_level1

18 changes: 0 additions & 18 deletions tests/test_example.py

This file was deleted.

0 comments on commit cabab34

Please sign in to comment.