diff --git a/datashuttle/__init__.py b/datashuttle/__init__.py index 501cb2036..557521387 100644 --- a/datashuttle/__init__.py +++ b/datashuttle/__init__.py @@ -1,7 +1,7 @@ from importlib.metadata import PackageNotFoundError, version from datashuttle.datashuttle_class import DataShuttle -from datashuttle.datashuttle_functions import quick_validate_project +from datashuttle.datashuttle_functions import validate_project_from_path try: diff --git a/datashuttle/datashuttle_functions.py b/datashuttle/datashuttle_functions.py index 5f24b9301..5547d4fe4 100644 --- a/datashuttle/datashuttle_functions.py +++ b/datashuttle/datashuttle_functions.py @@ -22,7 +22,7 @@ ) -def quick_validate_project( +def validate_project_from_path( project_path: str | Path, top_level_folder: Optional[TopLevelFolder] = "rawdata", display_mode: DisplayMode = "warn", diff --git a/datashuttle/tui/app.py b/datashuttle/tui/app.py index ca51488a1..c87e1ed56 100644 --- a/datashuttle/tui/app.py +++ b/datashuttle/tui/app.py @@ -58,7 +58,7 @@ def compose(self) -> ComposeResult: ), Button("Make New Project", id="mainwindow_new_project_button"), Button( - "Validate Project at Path", + "Validate Project From Path", id="mainwindow_validate_from_project_path", ), Button("Settings", id="mainwindow_settings_button"), diff --git a/datashuttle/tui/shared/validate_content.py b/datashuttle/tui/shared/validate_content.py index 38f04d34c..4a4f2652c 100644 --- a/datashuttle/tui/shared/validate_content.py +++ b/datashuttle/tui/shared/validate_content.py @@ -20,7 +20,7 @@ Select, ) -from datashuttle.datashuttle_functions import quick_validate_project +from datashuttle.datashuttle_functions import validate_project_from_path from datashuttle.tui.custom_widgets import ClickableInput from datashuttle.tui.screens import modal_dialogs, validate_at_path from datashuttle.tui.tooltips import get_tooltip @@ -29,7 +29,7 @@ class ValidateContent(Container): """A container containing widgets for project validation. - This is shared between the Validate Project from Path + This is shared between the Validate Project From Path and validation tab on the project manager. It takes a similar approach to ConfigsContent. @@ -192,7 +192,7 @@ def on_button_pressed(self, event: Button.Pressed) -> None: ) return - output = quick_validate_project( + output = validate_project_from_path( path_, top_level_folder=top_level_folder, strict_mode=strict_mode, diff --git a/docs/source/pages/api_index.rst b/docs/source/pages/api_index.rst index 76216e6b3..c56db1ab3 100644 --- a/docs/source/pages/api_index.rst +++ b/docs/source/pages/api_index.rst @@ -7,4 +7,4 @@ API Reference .. autoclass:: DataShuttle -.. autofunction:: quick_validate_project +.. autofunction:: validate_project_from_path diff --git a/docs/source/pages/get_started/quick-validate-project.md b/docs/source/pages/get_started/quick-validate-project.md index 02082da55..d829ccc14 100644 --- a/docs/source/pages/get_started/quick-validate-project.md +++ b/docs/source/pages/get_started/quick-validate-project.md @@ -1,5 +1,5 @@ :orphan: -(quick-validate-projects)= +(validate-project-from-path)= # Validate a project from a filepath @@ -14,7 +14,7 @@ to any problematic folders. :sync: gui To quickly validate a project, start the terminal user interface with -``datashuttle launch`` and click ``Validate Project at Path``. +``datashuttle launch`` and click ``Validate Project From Path``. The screen below will show. To validate an existing project, enter the full filepath to the project folder in the top input box @@ -54,12 +54,12 @@ raise a validation issue. :sync: python To validate a project using the Python API, pass the path -to the project to validate to ``quick_validate_project``: +to the project to validate to ``validate_project_from_path``: ```python -from datashuttle import quick_validate_project +from datashuttle import validate_project_from_path -quick_validate_project( +validate_project_from_path( project_path="/mydrive/path/to/project/project_name", display_mode="error", ) @@ -69,7 +69,7 @@ quick_validate_project( In this case, `display_mode=error` will result in an error on the first encountered validation issue. Otherwise, `"warn"` will show a python warning for all detected issues, while `"print"` will print directly to the console. -See the [](datashuttle.quick_validate_project) API documentation +See the [](validate_project_from_path()) API documentation for full details of parameters, including the important argument ``strict_mode`` that controls how validation is performed. diff --git a/docs/source/pages/user_guides/validate.md b/docs/source/pages/user_guides/validate.md index d593b59bc..092c948ad 100644 --- a/docs/source/pages/user_guides/validate.md +++ b/docs/source/pages/user_guides/validate.md @@ -6,7 +6,7 @@ [NeuroBlueprint specification](https://neuroblueprint.neuroinformatics.dev/latest/specification.html). This will find and display a list of all formatting errors in the project. -To quickly validate an existing project with only the project path, see [quick-validate-projects](quick-validate-projects). +To quickly validate an existing project with only the project path, see how to [validate a project from a path](validate-project-from-path). Below we will cover how to validate a datashuttle-managed project (which will additionally [log](how-to-read-the-logs) the validation results). diff --git a/tests/tests_integration/test_validation.py b/tests/tests_integration/test_validation.py index 0c40bc2f4..ab6850cf0 100644 --- a/tests/tests_integration/test_validation.py +++ b/tests/tests_integration/test_validation.py @@ -4,7 +4,7 @@ import pytest -from datashuttle import quick_validate_project +from datashuttle import validate_project_from_path from datashuttle.utils import formatting, validation from datashuttle.utils.custom_exceptions import NeuroBlueprintError @@ -794,7 +794,7 @@ def test_quick_validation(self, mocker, project): os.makedirs(project.cfg["local_path"] / "derivatives" / "sub-02") with pytest.warns(UserWarning) as w: - quick_validate_project( + validate_project_from_path( project.get_local_path(), display_mode="warn", top_level_folder=None, @@ -812,7 +812,7 @@ def test_quick_validation(self, mocker, project): datashuttle.datashuttle_functions.validation, "validate_project" ) - quick_validate_project( + validate_project_from_path( project.get_local_path(), display_mode="print", top_level_folder="derivatives", @@ -829,7 +829,7 @@ def test_quick_validation_top_level_folder(self, project): bad project path input. """ with pytest.raises(FileNotFoundError) as e: - quick_validate_project( + validate_project_from_path( project.get_local_path() / "does not exist", display_mode="error", ) diff --git a/tests/tests_tui/test_tui_validate.py b/tests/tests_tui/test_tui_validate.py index f9e0931c5..53102ebdf 100644 --- a/tests/tests_tui/test_tui_validate.py +++ b/tests/tests_tui/test_tui_validate.py @@ -160,7 +160,7 @@ async def test_validate_on_project_manager_kwargs( @pytest.mark.asyncio async def test_validate_at_path_kwargs(self, setup_project_paths, mocker): - """Test kwargs are properly passed through from the TUI to `quick_validate_project` + """Test kwargs are properly passed through from the TUI to `validate_project_from_path` with mocker. Note that the 'Select' button / directorytree is not tested here, as the screen is tested elsewhere and it's non-critical feature here. """ @@ -179,7 +179,7 @@ async def test_validate_at_path_kwargs(self, setup_project_paths, mocker): # Spy the function and click 'validate' button spy_validate = mocker.spy( datashuttle.tui.shared.validate_content, - "quick_validate_project", + "validate_project_from_path", ) warnings.filterwarnings("ignore")