Getting started
This project uses uv (https://docs.astral.sh/uv/) for dependency management, which provides fast and reliable Python package installation. uv will automatically handle Python version management and create virtual environments. The workflow is as follows:
Quick Installation
-
Install
uv(if not already installed):On Linux and macOS use
curl -LsSf https://astral.sh/uv/install.sh | shFor Windows instructions see the documentation
-
Clone the repository:
git clone https://github.com/DurstewitzLab/hier-MTF.git
cd hier-MTF -
Install dependencies and create virtual environment:
uv syncThis will:
- Create a virtual environment (
.venv) - Install all dependencies from
pyproject.toml - Use the exact versions specified in
uv.lockfor reproducibility
- Create a virtual environment (
-
(Optional) Install pre-commit hooks:
Pre-commit hooks help maintain code quality by automatically formatting code and checking for common issues before commits. To install pre-commit hooks, run the following in a terminal with the environment activated:
pre-commit installNote that this correct code formatting is mandatory for contributions to be accepted.
Running the code
The workflow for running the code is centered around the ubermain.py file (or variant thereof). This file serves as both the entry point and the configuration file for your experiments.
-
Configure the Experiment: Open
ubermain.pyand modify theconfigdictionary to suit your data and model requirements. This dictionary controls data loading, model architecture (encoder, decoder, latent step), training parameters, and evaluation settings. -
Run the Training: After installation, you can run the code by:
# Activate the environment
$ source .venv/bin/activate
# Run the configured experiment
(hier-mtf) $ python ubermain.pyOr use
uvdirectly:$ uv run python ubermain.py
Fixing TensorBoard path length issues on Windows
When running TensorBoard on Windows, you may encounter errors related to path length limitations. These errors typically occur during the automatic generation of temporary files and logging directories. Windows has a default path length limit of 260 characters, which TensorBoard's auto-generated paths can exceed. Solution
To resolve this issue, you need to enable long path support in Windows Registry:
Open Registry Editor: Press Win + R Type regedit and press Enter
Navigate to:
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
Find the LongPathsEnabled entry Double-click on LongPathsEnabled Set the value to 1 Click OK
Restart your system for changes to take effect
Note: This modification requires administrative privileges. If you don't have access to modify the registry, please contact your system administrator.
After applying this change, TensorBoard should work without path length-related errors.