From 7334bf89bd1babbb1e98354e78f2fdd8ce868908 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 10 Jul 2024 20:33:55 -0600 Subject: [PATCH 1/5] remove interface.run_conversion without nwbfile_path --- src/neuroconv/basedatainterface.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/neuroconv/basedatainterface.py b/src/neuroconv/basedatainterface.py index 73cb114ee..1521af7c5 100644 --- a/src/neuroconv/basedatainterface.py +++ b/src/neuroconv/basedatainterface.py @@ -1,7 +1,6 @@ import importlib import json import uuid -import warnings from abc import ABC, abstractmethod from pathlib import Path from typing import Literal, Optional, Tuple, Union @@ -116,7 +115,7 @@ def add_to_nwbfile(self, nwbfile: NWBFile, **conversion_options) -> None: def run_conversion( self, - nwbfile_path: Optional[str] = None, + nwbfile_path: Union[str, Path], nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, overwrite: bool = False, @@ -152,12 +151,7 @@ def run_conversion( BackendConfiguration object, and pass that instead. Otherwise, all datasets will use default configuration settings. """ - if nwbfile_path is None: - warnings.warn( # TODO: remove on or after 6/21/2024 - "Using DataInterface.run_conversion without specifying nwbfile_path is deprecated. To create an " - "NWBFile object in memory, use DataInterface.create_nwbfile. To append to an existing NWBFile object," - " use DataInterface.add_to_nwbfile." - ) + backend = _resolve_backend(backend, backend_configuration) no_nwbfile_provided = nwbfile is None # Otherwise, variable reference may mutate later on inside the context From 221aecb854eb38db4726b37b63047d8faf64ca54 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 10 Jul 2024 20:35:47 -0600 Subject: [PATCH 2/5] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04e10f6a7..96dd35e8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ * The usage of `compression` and `compression_opts` directly through the `FicTracDataInterface` is now deprecated - users should refer to the new `configure_backend` method for a general approach for setting compression. [PR #941](https://github.com/catalystneuro/neuroconv/pull/941) * The usage of `compression` directly through the `neuroconv.tools.neo` submodule is now deprecated - users should refer to the new `configure_backend` method for a general approach for setting compression. [PR #943](https://github.com/catalystneuro/neuroconv/pull/943) * The usage of `compression_options` directly through the `neuroconv.tools.ophys` submodule is now deprecated - users should refer to the new `configure_backend` method for a general approach for setting compression. [PR #940](https://github.com/catalystneuro/neuroconv/pull/940) +* Removed the option of running `interface.run_conversion` without `nwbfile_path argument`git . [PR #951](https://github.com/catalystneuro/neuroconv/pull/951) + + ### Features * Added docker image and tests for an automated Rclone configuration (with file stream passed via an environment variable). [PR #902](https://github.com/catalystneuro/neuroconv/pull/902) From fdb6ca1c067cf14b4681533223a6de42cbeb69c2 Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Wed, 10 Jul 2024 20:50:41 -0600 Subject: [PATCH 3/5] restrictive typing, modification docstring, correct docstring --- CHANGELOG.md | 2 +- src/neuroconv/basedatainterface.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96dd35e8d..ffcb5f284 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ * The usage of `compression` and `compression_opts` directly through the `FicTracDataInterface` is now deprecated - users should refer to the new `configure_backend` method for a general approach for setting compression. [PR #941](https://github.com/catalystneuro/neuroconv/pull/941) * The usage of `compression` directly through the `neuroconv.tools.neo` submodule is now deprecated - users should refer to the new `configure_backend` method for a general approach for setting compression. [PR #943](https://github.com/catalystneuro/neuroconv/pull/943) * The usage of `compression_options` directly through the `neuroconv.tools.ophys` submodule is now deprecated - users should refer to the new `configure_backend` method for a general approach for setting compression. [PR #940](https://github.com/catalystneuro/neuroconv/pull/940) -* Removed the option of running `interface.run_conversion` without `nwbfile_path argument`git . [PR #951](https://github.com/catalystneuro/neuroconv/pull/951) +* Removed the option of running `interface.run_conversion` without `nwbfile_path` argument . [PR #951](https://github.com/catalystneuro/neuroconv/pull/951) diff --git a/src/neuroconv/basedatainterface.py b/src/neuroconv/basedatainterface.py index 1521af7c5..c279d8900 100644 --- a/src/neuroconv/basedatainterface.py +++ b/src/neuroconv/basedatainterface.py @@ -115,7 +115,7 @@ def add_to_nwbfile(self, nwbfile: NWBFile, **conversion_options) -> None: def run_conversion( self, - nwbfile_path: Union[str, Path], + nwbfile_path: str, nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, overwrite: bool = False, @@ -132,8 +132,7 @@ def run_conversion( Parameters ---------- nwbfile_path : FilePathType - Path for where to write or load (if overwrite=False) the NWBFile. - If specified, the context will always write to this location. + Path for where the data will be written or appended. nwbfile : NWBFile, optional An in-memory NWBFile object to write to the location. metadata : dict, optional From 8e0bc8f8fcda1bf525f5f495ef57e618918b489d Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Thu, 11 Jul 2024 11:37:14 -0400 Subject: [PATCH 4/5] update tests to use create_nwbfile instead of run_conversion --- tests/test_ecephys/test_ecephys_interfaces.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_ecephys/test_ecephys_interfaces.py b/tests/test_ecephys/test_ecephys_interfaces.py index b8293f2ee..6372b3535 100644 --- a/tests/test_ecephys/test_ecephys_interfaces.py +++ b/tests/test_ecephys/test_ecephys_interfaces.py @@ -34,12 +34,12 @@ def setUpClass(cls): def test_stub_single_segment(self): interface = self.single_segment_recording_interface metadata = interface.get_metadata() - interface.run_conversion(stub_test=True, metadata=metadata) + interface.create_nwbfile(stub_test=True, metadata=metadata) def test_stub_multi_segment(self): interface = self.multi_segment_recording_interface metadata = interface.get_metadata() - interface.run_conversion(stub_test=True, metadata=metadata) + interface.create_nwbfile(stub_test=True, metadata=metadata) def test_no_slash_in_name(self): interface = self.single_segment_recording_interface From 076ffb520b413c632ec1a473d73e0863b05e7e2e Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 11 Jul 2024 13:30:20 -0600 Subject: [PATCH 5/5] fix ophys error --- tests/test_ophys/test_ophys_interfaces.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_ophys/test_ophys_interfaces.py b/tests/test_ophys/test_ophys_interfaces.py index 7c6685f72..1a774f713 100644 --- a/tests/test_ophys/test_ophys_interfaces.py +++ b/tests/test_ophys/test_ophys_interfaces.py @@ -1,4 +1,6 @@ +import tempfile import unittest +from pathlib import Path from pynwb.testing.mock.file import mock_NWBFile @@ -10,7 +12,10 @@ def setUp(self): self.mock_imaging_interface = MockImagingInterface() def test_run_conversion(self): - self.mock_imaging_interface.run_conversion() + + with tempfile.TemporaryDirectory() as tmpdir: + nwbfile_path = Path(tmpdir) / "test.nwb" + self.mock_imaging_interface.run_conversion(nwbfile_path=nwbfile_path) def test_add_to_nwbfile(self): nwbfile = mock_NWBFile()