Skip to content

Commit

Permalink
Implement scope control over check submodule (#486)
Browse files Browse the repository at this point in the history
* implement scope control over check submodule

* remove hallucinated names and fix test imports

* adjust imports for deprecated submodules

---------

Co-authored-by: CodyCBakerPhD <[email protected]>
  • Loading branch information
CodyCBakerPhD and CodyCBakerPhD authored Aug 19, 2024
1 parent d6a13ca commit bf93524
Show file tree
Hide file tree
Showing 28 changed files with 313 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/nwbinspector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
InspectorOutputJSONEncoder,
)
from ._organization import organize_messages
from .checks import *
from .checks import * # These need to be imported to trigger registration with 'available_checks', but are not exposed

default_check_registry = {check.__name__: check for check in available_checks}

Expand Down
161 changes: 149 additions & 12 deletions src/nwbinspector/checks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,149 @@
from .ecephys import *
from .general import *
from .image_series import *
from .images import *
from .nwb_containers import *
from .nwbfile_metadata import *
from .ogen import *
from .ophys import *
from .tables import *
from .time_series import *
from .icephys import *
from .behavior import *
from ._ecephys import (
check_negative_spike_times,
check_electrical_series_dims,
check_electrical_series_reference_electrodes_table,
check_spike_times_not_in_unobserved_interval,
)
from ._general import (
check_description,
check_name_slashes,
)
from ._image_series import (
check_image_series_data_size,
check_image_series_external_file_relative,
check_image_series_external_file_valid,
)
from ._images import (
check_order_of_images_unique,
check_order_of_images_len,
check_index_series_points_to_image,
)
from ._nwb_containers import (
check_empty_string_for_optional_attribute,
check_small_dataset_compression,
check_large_dataset_compression,
)
from ._nwbfile_metadata import (
check_keywords,
check_institution,
check_subject_age,
check_subject_sex,
check_subject_exists,
check_doi_publications,
check_experimenter_form,
check_experimenter_exists,
check_experiment_description,
check_subject_id_exists,
check_subject_species_exists,
check_subject_species_form,
check_subject_proper_age_range,
check_session_start_time_future_date,
check_processing_module_name,
check_session_start_time_old_date,
)
from ._ogen import (
check_optogenetic_stimulus_site_has_optogenetic_series,
)
from ._ophys import (
check_excitation_lambda_in_nm,
check_plane_segmentation_image_mask_shape_against_ref_images,
check_roi_response_series_dims,
check_emission_lambda_in_nm,
check_roi_response_series_link_to_plane_segmentation,
)
from ._tables import (
check_single_row,
check_ids_unique,
check_empty_table,
check_col_not_nan,
check_column_binary_capability,
check_dynamic_table_region_data_validity,
check_time_interval_time_columns,
check_time_intervals_stop_after_start,
check_table_values_for_dict,
check_table_time_columns_are_not_negative,
)
from ._time_series import (
check_resolution,
check_missing_unit,
check_regular_timestamps,
check_timestamps_ascending,
check_data_orientation,
check_timestamps_without_nans,
check_timestamps_match_first_dimension,
check_timestamp_of_the_first_sample_is_not_negative,
check_rate_is_not_zero,
)
from ._icephys import (
check_intracellular_electrode_cell_id_exists,
)
from ._behavior import (
check_compass_direction_unit,
check_spatial_series_radians_magnitude,
check_spatial_series_dims,
check_spatial_series_degrees_magnitude,
)

__all__ = [
"check_negative_spike_times",
"check_electrical_series_dims",
"check_electrical_series_reference_electrodes_table",
"check_spike_times_not_in_unobserved_interval",
"check_description",
"check_name_slashes",
"check_image_series_data_size",
"check_image_series_external_file_relative",
"check_image_series_external_file_valid",
"check_order_of_images_unique",
"check_order_of_images_len",
"check_index_series_points_to_image",
"check_empty_string_for_optional_attribute",
"check_small_dataset_compression",
"check_large_dataset_compression",
"check_keywords",
"check_institution",
"check_subject_age",
"check_subject_sex",
"check_subject_exists",
"check_doi_publications",
"check_experimenter_form",
"check_experimenter_exists",
"check_experiment_description",
"check_subject_id_exists",
"check_subject_species_exists",
"check_subject_species_form",
"check_subject_proper_age_range",
"check_session_start_time_future_date",
"check_processing_module_name",
"check_session_start_time_old_date",
"check_optogenetic_stimulus_site_has_optogenetic_series",
"check_excitation_lambda_in_nm",
"check_plane_segmentation_image_mask_shape_against_ref_images",
"check_roi_response_series_dims",
"check_emission_lambda_in_nm",
"check_roi_response_series_link_to_plane_segmentation",
"check_single_row",
"check_ids_unique",
"check_empty_table",
"check_col_not_nan",
"check_column_binary_capability",
"check_dynamic_table_region_data_validity",
"check_time_interval_time_columns",
"check_time_intervals_stop_after_start",
"check_table_values_for_dict",
"check_table_time_columns_are_not_negative",
"check_resolution",
"check_missing_unit",
"check_regular_timestamps",
"check_timestamps_ascending",
"check_data_orientation",
"check_timestamps_without_nans",
"check_timestamps_match_first_dimension",
"check_timestamp_of_the_first_sample_is_not_negative",
"check_rate_is_not_zero",
"check_intracellular_electrode_cell_id_exists",
"check_compass_direction_unit",
"check_spatial_series_radians_magnitude",
"check_spatial_series_dims",
"check_spatial_series_degrees_magnitude",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/behavior/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._behavior import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/ecephys/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._ecephys import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/general/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._general import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/icephys/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._icephys import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/image_series/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._image_series import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/images/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._images import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/nwb_containers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._nwb_containers import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/nwbfile_metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._nwbfile_metadata import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/ogen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._ogen import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/ophys/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._ophys import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/tables/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._tables import *
13 changes: 13 additions & 0 deletions src/nwbinspector/checks/time_series/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import warnings

message = (
"All submodules below the level 'nwbinspector.checks' have been deprecated. "
"Please retrieve the specific check function(s) you wish to use from the `available_checks` registry "
"at the top-level or import directly from 'nwbinspector.checks'."
)

warnings.warn(message=message, category=DeprecationWarning, stacklevel=2)

# Still keep imports functional with warning for soft deprecation cycle
# TODO: remove after 9/15/2024
from .._time_series import *
10 changes: 6 additions & 4 deletions tests/test_check_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

from nwbinspector import (
Importance,
check_small_dataset_compression,
check_regular_timestamps,
check_data_orientation,
check_timestamps_match_first_dimension,
available_checks,
default_check_registry,
validate_config,
configure_checks,
load_config,
)
from nwbinspector.checks import (
check_small_dataset_compression,
check_regular_timestamps,
check_data_orientation,
check_timestamps_match_first_dimension,
)
from nwbinspector._configuration import _copy_function


Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_nwbfile_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
check_processing_module_name,
check_session_start_time_old_date,
check_session_start_time_future_date,
PROCESSING_MODULE_CONFIG,
)
from nwbinspector.testing import make_minimal_nwbfile
from nwbinspector.checks._nwbfile_metadata import PROCESSING_MODULE_CONFIG


minimal_nwbfile = make_minimal_nwbfile()
Expand Down

0 comments on commit bf93524

Please sign in to comment.