From 11f6dd39aa121020b00d191536dfbcde4764fd89 Mon Sep 17 00:00:00 2001 From: alessandratrapani Date: Wed, 20 Nov 2024 18:45:01 +0100 Subject: [PATCH] ruff fixes --- .github/workflows/test-install.yml | 1 - .gitignore | 2 +- README.md | 18 +++++++++--------- pyproject.toml | 1 - .../embargo_2025/convert_all_sessions.py | 19 ++++++++++--------- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml index 0e97f8a..0faddf9 100644 --- a/.github/workflows/test-install.yml +++ b/.github/workflows/test-install.yml @@ -29,4 +29,3 @@ jobs: run: pip install -e . - name: Test module load run: python -c "import hnasko_lab_to_nwb" - diff --git a/.gitignore b/.gitignore index 6198485..7347b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -146,4 +146,4 @@ dmypy.json .DS_Store # NWB files -**.nwb \ No newline at end of file +**.nwb diff --git a/README.md b/README.md index 3841bd8..bc83eac 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ pip install hnasko-lab-to-nwb We recommend that you install the package inside a [virtual environment](https://docs.python.org/3/tutorial/venv. html). A simple way of doing this is to use a [conda environment](https://docs.conda. -io/projects/conda/en/latest/user-guide/concepts/environments.html) from the `conda` package manager ([installation -instructions](https://docs.conda.io/en/latest/miniconda.html)). Detailed instructions on how to use conda +io/projects/conda/en/latest/user-guide/concepts/environments.html) from the `conda` package manager ([installation +instructions](https://docs.conda.io/en/latest/miniconda.html)). Detailed instructions on how to use conda environments can be found in their [documentation](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html). ### Running a specific conversion @@ -30,10 +30,10 @@ python convert_session.py ``` ## Installation from GitHub -Another option is to install the package directly from GitHub. This option has the advantage that the source code -can be modified if you need to amend some of the code we originally provided to adapt to future experimental -differences. To install the conversion from GitHub you will need to use `git` ([installation instructions] (https://github.com/git-guides/install-git)). -We also recommend the installation of `conda` ([installation instructions](https://docs.conda.io/en/latest/miniconda.html)) as it contains all the required +Another option is to install the package directly from GitHub. This option has the advantage that the source code +can be modified if you need to amend some of the code we originally provided to adapt to future experimental +differences. To install the conversion from GitHub you will need to use `git` ([installation instructions] (https://github.com/git-guides/install-git)). +We also recommend the installation of `conda` ([installation instructions](https://docs.conda.io/en/latest/miniconda.html)) as it contains all the required machinery in a single and simple install. From a terminal (note that conda should install one in your system) you can do the following: @@ -47,7 +47,7 @@ conda activate hnasko-lab-to-nwb-env This creates a [conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html) which isolates the conversion code from your system libraries. We recommend that you run all your conversion related tasks and analysis from the created environment in order to minimize issues related to package dependencies. -Alternatively, if you want to avoid conda altogether (for example if you use another virtual environment tool) you +Alternatively, if you want to avoid conda altogether (for example if you use another virtual environment tool) you can install the repository with the following commands using only pip: ``` @@ -94,11 +94,11 @@ Each conversion is organized in a directory of its own in the `src` directory: └── __init__.py -For example, for the conversion `embargo_2025` you can find a directory located in `src/hnasko-lab-to-nwb/embargo_2025`. +For example, for the conversion `embargo_2025` you can find a directory located in `src/hnasko-lab-to-nwb/embargo_2025`. Inside each conversion directory you can find the following files: -* `convert_sesion.py`: this script defines the function to convert one full session of the conversion. +* `convert_sesion.py`: this script defines the function to convert one full session of the conversion. * `metadata.yml`: metadata in yaml format for this specific conversion. * `behaviorinterface.py`: the behavior interface. Usually ad-hoc for each conversion. * `nwbconverter.py`: the place where the `NWBConverter` class is defined. diff --git a/pyproject.toml b/pyproject.toml index 6e29e33..f6fa89d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,4 +83,3 @@ fixable = ["ALL"] [tool.ruff.lint.isort] relative-imports-order = "closest-to-furthest" known-first-party = ["neuroconv"] - diff --git a/src/hnasko_lab_to_nwb/embargo_2025/convert_all_sessions.py b/src/hnasko_lab_to_nwb/embargo_2025/convert_all_sessions.py index 084d52f..efb7936 100644 --- a/src/hnasko_lab_to_nwb/embargo_2025/convert_all_sessions.py +++ b/src/hnasko_lab_to_nwb/embargo_2025/convert_all_sessions.py @@ -1,9 +1,10 @@ """Primary script to run to convert all sessions in a dataset using session_to_nwb.""" -from pathlib import Path -from typing import Union +import traceback from concurrent.futures import ProcessPoolExecutor, as_completed +from pathlib import Path from pprint import pformat -import traceback +from typing import Union + from tqdm import tqdm from .embargo_2025_convert_session import session_to_nwb @@ -39,7 +40,7 @@ def dataset_to_nwb( for session_to_nwb_kwargs in session_to_nwb_kwargs_per_session: session_to_nwb_kwargs["output_dir_path"] = output_dir_path session_to_nwb_kwargs["verbose"] = verbose - exception_file_path = data_dir_path / f"ERROR_.txt" # Add error file path here + exception_file_path = data_dir_path / f"ERROR_.txt" # Add error file path here futures.append( executor.submit( safe_session_to_nwb, @@ -86,11 +87,11 @@ def get_session_to_nwb_kwargs_per_session( list[dict[str, Any]] A list of dictionaries containing the kwargs for session_to_nwb for each session. """ - ##### - # # Implement this function to return the kwargs for session_to_nwb for each session - # This can be a specific list with hard-coded sessions, a path expansion or any conversion specific logic that you might need - ##### - raise NotImplementedError + ##### + # # Implement this function to return the kwargs for session_to_nwb for each session + # This can be a specific list with hard-coded sessions, a path expansion or any conversion specific logic that you might need + ##### + raise NotImplementedError if __name__ == "__main__":