diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b837f700..509797542 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 . [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) diff --git a/src/neuroconv/basedatainterface.py b/src/neuroconv/basedatainterface.py index 73cb114ee..c279d8900 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: str, nwbfile: Optional[NWBFile] = None, metadata: Optional[dict] = None, overwrite: bool = False, @@ -133,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 @@ -152,12 +150,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 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 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()