Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Testing

The tests in the `tests` folder use pytest and can be run locally as:

```
SKIP_LIMS=true TEST_INHOUSE=false pytest
```

This does not assume that you have access to AllenInstitute internal resources like LIMS or network shares.

## Strategy for adopting newer NWB schema versions

The upstream source of NWB files for ipfx is [MIES](https://github.com/AllenInstitute/MIES) and
[IPNWB](https://github.com/AllenInstitute/IPNWB). We are at the moment using fixed versions of nwb-schema for
IPNWB and pynwb for ipfx. This is done in order to reduce maintenance and friction between the two.

Steps for upgrading:

- Choose a pynwb/nwb-schema version you want to adopt
- Raise pynwb version in `requirements.txt`
- Check if all tests still pass. In the past this always required patching the latest
pynwb version, bringing that patch upstream and waiting for a new release.
- Fix pynwb deprecations where appropriate
- Upgrade the nwb-schema version used in IPNWB as documented there
- Re-export the files `Vip-IRES-Cre;Ai14(IVSCC)-226110.03.01.pxp` and
`Vip-IRES-Cre;Ai14(IVSCC)-236654.04.02.pxp` using the IPNWB/MIES version with the new nwb-schema to NWBv2
- Add the files to `tests/data` and extend `testdata` in `tests/test_run_feature_vector.py` with them
- Check if the tests still pass
- Propose a PR
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pandas
pg8000
pillow
pyabf
pynwb
pynwb==3.1.2
pyYAML
ruamel.yaml<0.18.0
scipy
Expand Down
Git LFS file not shown
Git LFS file not shown
23 changes: 16 additions & 7 deletions tests/test_run_feature_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@

nwb2_file1 = os.path.join(current_directory, "data", "Vip-IRES-Cre;Ai14(IVSCC)-226110.03.01.nwb")
nwb2_file2 = os.path.join(current_directory, "data", "Vip-IRES-Cre;Ai14(IVSCC)-236654.04.02.nwb")
test_nwb2_files = dict({500844783: nwb2_file1, 509604672: nwb2_file2})
nwb2_nwb_schema_2_9_0_file1 = os.path.join(current_directory, "data", "Vip-IRES-Cre;Ai14(IVSCC)-226110.03.01_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb")
nwb2_nwb_schema_2_9_0_file2 = os.path.join(current_directory, "data", "Vip-IRES-Cre;Ai14(IVSCC)-236654.04.02_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb")

def test_feature_vector_extraction(tmpdir_factory):
testdata = [dict({500844783: nwb2_file1,
509604672: nwb2_file2}),
dict({500844783: nwb2_nwb_schema_2_9_0_file1,
509604672: nwb2_nwb_schema_2_9_0_file2})
]

@pytest.mark.parametrize("ids_and_files", testdata, ids = ["default", "schema-2.9.0"])
def test_feature_vector_extraction(ids_and_files, tmpdir_factory):

temp_output_dir = str(tmpdir_factory.mktemp("feature_vector"))
test_output_dir = TEST_OUTPUT_DIR
Expand All @@ -37,7 +45,7 @@ def test_feature_vector_extraction(tmpdir_factory):
"subthresh_depol_norm",
]

run_feature_vector_extraction(ids=[500844783, 509604672],
run_feature_vector_extraction(ids=ids_and_files.keys(),
output_dir=temp_output_dir,
data_source="filesystem",
output_code="TEMP",
Expand All @@ -47,7 +55,7 @@ def test_feature_vector_extraction(tmpdir_factory):
include_failed_cells=True,
run_parallel=False,
ap_window_length=0.003,
file_list=test_nwb2_files
file_list=ids_and_files
)

for feature in features:
Expand All @@ -57,19 +65,20 @@ def test_feature_vector_extraction(tmpdir_factory):
assert np.allclose(test_data, temp_data)


def test_feature_collection(tmpdir_factory):
@pytest.mark.parametrize("ids_and_files", testdata, ids = ["default", "schema-2.9.0"])
def test_feature_collection(ids_and_files, tmpdir_factory):

temp_output_dir = str(tmpdir_factory.mktemp("feature_vector"))
test_output_dir = TEST_OUTPUT_DIR

temp_output_file = os.path.join(temp_output_dir, "features_T301.csv")
test_output_file = os.path.join(test_output_dir, "features_T301.csv")

run_feature_collection(ids=[500844783, 509604672],
run_feature_collection(ids=ids_and_files.keys(),
output_file=temp_output_file,
data_source="filesystem",
run_parallel=False,
file_list=test_nwb2_files)
file_list=ids_and_files)

test_table = pd.read_csv(test_output_file, sep=",").to_dict()
temp_table = pd.read_csv(temp_output_file, sep=",").to_dict()
Expand Down