Skip to content

Commit

Permalink
Remove interface.run_conversion without nwbfile_path (#951)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com>
Co-authored-by: Ben Dichter <ben.dichter@gmail.com>
  • Loading branch information
3 people authored Jul 11, 2024
1 parent eee7ca3 commit c9aeed9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 3 additions & 10 deletions src/neuroconv/basedatainterface.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_ecephys/test_ecephys_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion tests/test_ophys/test_ophys_interfaces.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import tempfile
import unittest
from pathlib import Path

from pynwb.testing.mock.file import mock_NWBFile

Expand All @@ -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()
Expand Down

0 comments on commit c9aeed9

Please sign in to comment.