Skip to content

Commit 3e8df25

Browse files
authored
[MAINT] add tests and refactor (#11)
* start adding cli parser * rename variables * add smoke end to end test * add tests * add pyaml * use path * refactor * refactor * extract function * refactor * fix workflow * refactor
1 parent 957e01e commit 3e8df25

File tree

14 files changed

+372
-189
lines changed

14 files changed

+372
-189
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# ignoring this might speed up build
22
# by preventing passing extra content to the docker daemon
33

4-
54
# General
65
.DS_Store
76

.flake8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ exclude =
99
doc/_build
1010
docstring-convention = numpy
1111
max-line-length = 90
12-
max_complexity = 15
12+
max_complexity = 17
1313
max_function_length = 100
1414
per-file-ignores =
1515
**/__init__.py: D104
16+
./tests/*: D100, D103
1617
# for compatibility with black
1718
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
1819
extend-ignore = E203

.github/workflows/docker.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ jobs:
1717
steps:
1818
- name: Clone
1919
uses: actions/checkout@v3
20-
with:
21-
fetch-depth: 0
2220
- name: Build docker image
2321
run: docker build -t eye2bids:latest .

.github/workflows/tests.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: test
3+
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true
7+
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
branches: ['*']
13+
14+
jobs:
15+
test:
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
python-version: ['3.8', '3.9', '3.10', '3.11']
21+
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
26+
- name: Clone
27+
uses: actions/checkout@v3
28+
29+
- uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install dependencies
34+
run: |
35+
sudo add-apt-repository universe
36+
sudo apt-get update
37+
sudo apt-get install ca-certificates
38+
sudo apt-key adv --fetch-keys https://apt.sr-research.com/SRResearch_key
39+
sudo add-apt-repository 'deb [arch=amd64] https://apt.sr-research.com SRResearch main'
40+
sudo apt update
41+
sudo apt install eyelink-display-software
42+
python -m pip install --upgrade pip
43+
44+
- name: Install package
45+
run: pip install .[test]
46+
47+
- name: Install data
48+
run: make test_data
49+
50+
- name: unit tests
51+
run: python -m pytest tests --cov-report=xml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tests/data/test_data.zip
2+
tests/data/**/*.json
23
**/*.asc
34
**/*.edf
45
**/*.EDF

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ RUN apt-get update -qq \
66
ca-certificates \
77
curl \
88
gcc \
9+
git \
910
gnupg2 \
1011
pip \
1112
python3 \
@@ -45,15 +46,16 @@ RUN printf '{ \
4546
"ca-certificates", \
4647
"software-properties-common", \
4748
"python3", \
48-
"pip" \
49+
"pip", \
50+
"git" \
4951
], \
5052
"opts": null \
5153
} \
5254
}, \
5355
{ \
5456
"name": "run", \
5557
"kwds": { \
56-
"command": "apt-get update -qq \\\\\\n && apt-get install -y -q --no-install-recommends \\\\\\n ca-certificates \\\\\\n curl \\\\\\n gcc \\\\\\n gnupg2 \\\\\\n pip \\\\\\n python3 \\\\\\n software-properties-common \\\\\\n && rm -rf /var/lib/apt/lists/*" \
58+
"command": "apt-get update -qq \\\\\\n && apt-get install -y -q --no-install-recommends \\\\\\n ca-certificates \\\\\\n curl \\\\\\n gcc \\\\\\n git \\\\\\n gnupg2 \\\\\\n pip \\\\\\n python3 \\\\\\n software-properties-common \\\\\\n && rm -rf /var/lib/apt/lists/*" \
5759
} \
5860
}, \
5961
{ \

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Dockerfile:
44
docker run --rm repronim/neurodocker:0.9.5 generate docker \
55
--pkg-manager apt \
66
--base-image ubuntu:22.04 \
7-
--install gnupg2 curl gcc ca-certificates software-properties-common python3 pip \
7+
--install gnupg2 curl gcc ca-certificates software-properties-common python3 pip git \
88
--run "apt-key adv --fetch-keys https://apt.sr-research.com/SRResearch_key && add-apt-repository 'deb [arch=amd64] https://apt.sr-research.com SRResearch main'" \
99
--install eyelink-display-software \
1010
--run "mkdir /eye2bids" \

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ pip install .
4545

4646
- edf file by EyeLink Eye Tracker
4747

48-
To try it, you can install our test data from OSF by running the following command:
49-
50-
```bash
51-
python tools/download_test_data.py
52-
```
53-
5448
- manual_metadata.yml file (find template and an example in conversion_json folder)
5549

5650
### Run code
@@ -77,4 +71,11 @@ Make sure you install eye2bids in editable mode (see above) and install the deve
7771
pip install --editable .[dev]
7872
```
7973

74+
To run the tests, you need to install the [test data from OSF](https://osf.io/jdv7n/)
75+
by running the following command:
76+
77+
```bash
78+
python tools/download_test_data.py
79+
```
80+
8081
## Related projects

eye2bids/_parser.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import argparse
2+
3+
4+
def global_parser():
5+
"""Parse command line arguments.
6+
7+
Returns
8+
-------
9+
parser: An ArgumentParser object.
10+
11+
"""
12+
parser = argparse.ArgumentParser()
13+
parser.add_argument("--input_file", type=str)
14+
parser.add_argument("--metadata_file", type=str)
15+
parser.add_argument("--output_dir", type=str)
16+
return parser

0 commit comments

Comments
 (0)