diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..e4c697bc --- /dev/null +++ b/TESTING.md @@ -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 diff --git a/requirements.txt b/requirements.txt index b34f70ef..a6e90e15 100755 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ pandas pg8000 pillow pyabf -pynwb +pynwb==3.1.2 pyYAML ruamel.yaml<0.18.0 scipy diff --git a/tests/data/Vip-IRES-Cre;Ai14(IVSCC)-226110.03.01_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb b/tests/data/Vip-IRES-Cre;Ai14(IVSCC)-226110.03.01_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb new file mode 100644 index 00000000..6bf541aa --- /dev/null +++ b/tests/data/Vip-IRES-Cre;Ai14(IVSCC)-226110.03.01_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c0c13850e8c1e6787fcc758e628eee3068d883fd15484b5a6653af9887881ab +size 21392507 diff --git a/tests/data/Vip-IRES-Cre;Ai14(IVSCC)-236654.04.02_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb b/tests/data/Vip-IRES-Cre;Ai14(IVSCC)-236654.04.02_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb new file mode 100644 index 00000000..32d7b00d --- /dev/null +++ b/tests/data/Vip-IRES-Cre;Ai14(IVSCC)-236654.04.02_ITC18USB_Dev_0-nwb-schema-2.9.0.nwb @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa465ac15157bfc6e2ec506e868d8d40f5d2d1161385bc7216f578401d2dacb5 +size 32211379 diff --git a/tests/test_run_feature_vector.py b/tests/test_run_feature_vector.py index 2a3efafe..39174880 100644 --- a/tests/test_run_feature_vector.py +++ b/tests/test_run_feature_vector.py @@ -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 @@ -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", @@ -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: @@ -57,7 +65,8 @@ 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 @@ -65,11 +74,11 @@ def test_feature_collection(tmpdir_factory): 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()