Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
404873d
Remove interpreter from base project config
austin2118ace Dec 4, 2025
7b31ee6
Add test dir to project structure
austin2118ace Dec 4, 2025
ae335f7
Add George, small reorganization
austin2118ace Dec 4, 2025
bbebf1e
Remove these unused dependencies for the moment
austin2118ace Dec 8, 2025
2dad11c
update uv.lock to reflect dependency changes
austin2118ace Dec 8, 2025
2ce6458
Default_Setup: add calibration and logs directories; no longer create…
austin2118ace Dec 8, 2025
27d8d92
Copy default files to top level directory instead of a specific bpod …
austin2118ace Dec 8, 2025
0c44b5c
Ruff check and format
austin2118ace Dec 10, 2025
5559074
Add "bpod" CLI command to launch __main__.main() (for now)
austin2118ace Dec 10, 2025
6783b11
__main__: remove unused arguments for create default folder structure
austin2118ace Dec 10, 2025
6edf70f
deafult_setup: Create two functions to save the path to the Bpod dire…
austin2118ace Dec 10, 2025
20f8559
default_setup: remove unneeded else
austin2118ace Dec 10, 2025
3b580f1
default_setup: ruff format; update docstrings
austin2118ace Dec 10, 2025
99646c9
default_setup: return None if the bpod_path.txt file does not exist
austin2118ace Dec 10, 2025
bc8afe1
default_setup: wrapper to return the default Bpod directory or the us…
austin2118ace Dec 10, 2025
df11c74
default_setup: Start implementing logic for system initialization
austin2118ace Dec 10, 2025
00f61af
cli_io: Module to handle IO via CLI
austin2118ace Dec 11, 2025
381099f
__main__: Recreate default folder structure based on user input
austin2118ace Dec 11, 2025
66ae924
config.utils: function to verify standard directories exist in a Bpod…
austin2118ace Dec 11, 2025
15d3a0c
cli_io: somehow used a function that doesn't exist
austin2118ace Dec 11, 2025
64c0bd9
__main__: verify the Bpod directory and adjust logic to use it
austin2118ace Dec 11, 2025
6fd182d
__main__: rename bpod_directory -> bpod_directory_path for clarity
austin2118ace Dec 11, 2025
a747748
cli_io: prompt user for path with some error checking
austin2118ace Dec 17, 2025
2d137f0
Add platformdirs as a dependency
austin2118ace Dec 17, 2025
3a292bd
Default setup: create_default_directories now takes an explicit path
austin2118ace Dec 17, 2025
07a4f70
default_setup: remove pointer file functions; new function to check w…
austin2118ace Dec 17, 2025
dc91038
default_setup: update get_bpod_directory
austin2118ace Dec 17, 2025
579b70e
__main__: Remove old todo;call get_bpod_directory()
austin2118ace Dec 17, 2025
13576d0
default_setup: Function to return the Bpod dir from the system config
austin2118ace Dec 25, 2025
985dbbc
default_setup: function to check if the system is initialized based on
austin2118ace Dec 25, 2025
7343ad8
default_setup: Update get_bpod_directory function
austin2118ace Dec 25, 2025
0a15395
__main__: update logging messages; check for initialization
austin2118ace Dec 25, 2025
7dc50ed
defaults: Finally made a defaults module
austin2118ace Dec 25, 2025
1b75ebd
defaults: add comments; update system path to be site_path instead of
austin2118ace Dec 25, 2025
f8bca59
__main__: reference defaults module for Bpod path; make Bpod directory
austin2118ace Dec 25, 2025
e3806dc
default_setup: remove some extraneous code and checks that are duplic…
austin2118ace Dec 29, 2025
d064a9e
defaults: use user_config_path and rename file to config.json
austin2118ace Jan 2, 2026
bf70d53
__main__: import defaults; some refactoring
austin2118ace Jan 2, 2026
402c73d
__main__: comments to organize each step in the loading sequence
austin2118ace Jan 2, 2026
2d2ad44
default_setup: allow errors to bubble up
austin2118ace Jan 22, 2026
48223e4
__main__: cleanup startup process
austin2118ace Jan 22, 2026
486181d
default_setup: convert to explicit import; remove unused imports
austin2118ace Jan 22, 2026
ceaa0af
test_default_setup: fix default setup test
austin2118ace Jan 22, 2026
2f62d43
system_settings: another explicit import
austin2118ace Jan 22, 2026
4c34b12
Config: refactor update_modification_time to be a member of the super…
austin2118ace Feb 4, 2026
a153c69
Config.utils: function to save the system paths; save_system_configur…
austin2118ace Feb 4, 2026
1b2e22e
Add testcase for passing metadata object and ignoring the username field
austin2118ace Feb 4, 2026
edcbab7
Refactor: rename default_setup -> startup
austin2118ace Feb 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/bpod-rig.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions bpod_rig/IO/cli_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import logging
from pathlib import Path

import click

logger = logging.getLogger(__name__)

def yes_no_prompt(prompt: str) -> bool:
response = ''

while response not in ['y', 'n', 'Y', 'N']:
response = click.prompt(prompt, prompt_suffix=' [y/N] ')

if response in ['y', 'Y']:
return True
else:
return False

def prompt_for_path(prompt: str) -> Path:
validated = False
path = []

while not validated:
unverified_path = click.prompt(prompt)
response = yes_no_prompt(f"Is {unverified_path} the correct path?")
if response:
try:
path = Path(unverified_path)
validated = True
except Exception as e:
logger.error("Invalid path: %s", exc_info=e)
click.echo("Invalid path entered, please try again.", err=True)

return path

136 changes: 0 additions & 136 deletions bpod_rig/IO/default_setup.py

This file was deleted.

154 changes: 154 additions & 0 deletions bpod_rig/IO/startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
"""Module to create the default Bpod user directory and associated subdirs."""

import logging
import shutil
from pathlib import Path

from bpod_rig.examples import calibration, settings
from bpod_rig.config import utils
from bpod_rig.defaults import (
DEFAULT_SUBDIRS, SYSTEM_CONFIG_DIR, SYSTEM_CONFIG_FILE,
)

logger = logging.getLogger(__name__)


def create_default_directories(bpod_directory_path: Path = None) -> Path:
"""Create the default Bpod folder structure.

The Bpod directory will be created inside the given path with the following
top-level subdirectories:

Bpod/
Config/
Calibration/
Protocols/
Data/
Logs/

This function only creates the directory structure — it does NOT populate
default calibration or settings files. To copy default files, call
`copy_default_files()` separately.

Parameters
----------
bpod_directory_path : pathlib.Path
The path to initialize the Bpod folder location

Returns
-------
pathlib.Path
The path to the created Bpod directory.
"""
is_new_install = False

if not bpod_directory_path.exists():
logger.debug("Creating default Bpod user directory in %s", bpod_directory_path)
bpod_directory_path.mkdir(parents=True, exist_ok=True)
is_new_install = True
else:
logger.debug("Bpod user directory found: %s", bpod_directory_path)

# Create top-level subdirectories
for subdir in DEFAULT_SUBDIRS:
new_path = bpod_directory_path.joinpath(subdir)
if not new_path.exists():
logger.debug(
"Creating default subdirectory [%s] in %s", subdir, bpod_directory_path
)
new_path.mkdir(parents=True, exist_ok=True)

if is_new_install:
logger.info("Bpod user directory initialized to %s", bpod_directory_path)

return bpod_directory_path


def copy_default_files(bpod_folder_path: Path, override: bool = False):
"""Function to copy default files into their respective folders.

Copies the default calibration and configuration files from the examples module
to their respective directories.

Parameters
----------
bpod_folder_path : pathlib.Path
Path to the Bpod directory
override : bool, optional
Overwrite any existing files

Returns
-------
None

"""
# Locate target Calibration and Settings directories for this machine
calibration_dir = bpod_folder_path.joinpath("Calibration")
settings_dir = bpod_folder_path.joinpath("Config")

calibration_example_dir = Path(calibration.__path__[0])
settings_example_dir = Path(settings.__path__[0])
default_calibration_files = calibration_example_dir.glob("*.json")
default_settings_files = settings_example_dir.glob("*.json")

calibration_dir_contents = list(calibration_dir.iterdir())
settings_dir_contents = list(settings_dir.iterdir())

if len(calibration_dir_contents) == 0 or override:
for cal_file in default_calibration_files:
try:
logger.debug("Copying %s to %s...", cal_file, calibration_dir)
shutil.copy2(cal_file, calibration_dir)
except Exception as e: # NOQA PERF203
logger.error("Error copying %s!", cal_file)
raise e

if len(settings_dir_contents) == 0 or override:
for setting_file in default_settings_files:
try:
logger.debug("Copying %s to %s...", setting_file, settings_dir)
shutil.copy2(setting_file, settings_dir)
except Exception as e: # NOQA PERF203
logger.error("Error copying %s!", setting_file)
raise e


def get_bpod_dir_from_system() -> Path | None:
"""Attempts to get the Bpod directory path from the system configuration file

Checks to see if the system configuration directory exists, if so, check to see
if there is a system configuration file. If there is attempt to read the Bpod
directory path from the configuration file.

Returns
-------
pathlib.Path
Path to the Bpod directory read from the system configuration file
"""

# Attempt to load and read path from system configuration file
system_settings = utils.load_system_configuration(SYSTEM_CONFIG_FILE)
return system_settings.paths.base_dir


def check_system_is_initialized() -> bool:
"""Checks whether Bpod has been initialized on this system before

If the system configuration directory does not exist, the system has not been initialized
If the system configuration directory exists, but the system_config.json file
does not exist, the system likely has only been partially initialized and needs to
be reinitialized.

Returns
------
bool
True if system is initialized, False otherwise
"""

if SYSTEM_CONFIG_DIR.exists():
logger.debug("System configuration directory found: %s", SYSTEM_CONFIG_DIR)
if SYSTEM_CONFIG_FILE.exists():
logger.debug("System configuration file found: %s", SYSTEM_CONFIG_FILE)
return True
return False

Loading