bamboost._config
This module manages configuration options for bamboost. It supports loading configuration
from a global file (~/.config/bamboost/config.toml) and a project configuration in the
standard (pyproject.toml).
The configuration is structured using dataclasses, allowing hierarchical and type-validated configuration handling.
Key Features:
- Detects the root directory of the project based on common anchor files.
- Reads configuration from global and project-specific TOML files.
- Provides structured access to configuration values via dataclasses.
- Supports nested dictionary updates for merging configuration sources.
- Includes an index system for managing paths and database settings.
Attributes
- __all__=
['config'] - CONFIG_DIR=
Path('~/.config/bamboost').expanduser() - CONFIG_FILE=
CONFIG_DIR.joinpath(DEFAULT_CONFIG_FILE_NAME) - _LOCAL_DIR=
'~/.local/share/bamboost' - LOCAL_DIR=
Path(_LOCAL_DIR).expanduser() - CACHE_DIR=
Path('~/.cache/bamboost-next').expanduser() - DEFAULT_EXCLUDE_DIRS:
set[str]={'.git', '.hg', '.svn', '.bzr', '.cvs', '.venv', 'venv', 'env', '.tox', '.nox', 'node_modules', '.yarn', '.pnp', 'build', 'dist', '.eggs', '.idea', '.vscode', '.vs', '__pycache__', '.mypy_cache', '.pytest_cache', '.ruff_cache', '.cache', '.cargo', '.gocache', '.next', '.nuxt', '.terser-cache', '.parcel-cache', '.vercel', '.serverless', '.aws-sam', '.terraform', 'vendor'} The main configuration instance containing paths, options, and index settings.
Functions
() -> Optional[Path]Find the root directory.
(filepath) -> dict[str, Any]Reads the configuration file and fills the configuration options.
Arguments:
- filepath:
pathlib.Path
(project_dir) -> dict[str, Any]Get the project configuration from bamboost.toml or pyproject.toml.
Arguments:
- project_dir:
pathlib.Path
(d, u) -> MutableMappingArguments:
- d:
collections.abc.MutableMapping - u:
collections.abc.MutableMapping
Classes
_Base
(self) -> NoneAttributes:
- _field_aliases=
{}
(self, name) -> AnyArguments:
- name:
str
(self, key, value) -> NoneSet the configuration options by key, separated by dots.
Arguments:
- key:
str - value:
typing.Any
(self, key) -> AnyAccess the configuration options by key, separated by dots.
Arguments:
- key:
str
(self) -> str(cls, config, **kwargs) -> SelfCreate an instance of the dataclass from a dictionary of configuration values.
This method performs the following steps:
- Identifies valid field names and aliases.
- Logs any unknown configuration keys.
- Filters the input dictionary to include only valid keys and aliases.
- Validates the types of the configuration values.
- Creates an instance of the class with the filtered and validated configuration.
- Logs any missing fields that are using default values.
Arguments:
- cls
- config:
dictA dictionary containing configuration key-value pairs.
- kwargs=
{}
Returns
typing_extensions.SelfAn instance of the class initialized with the provided configuration.Note
- Invalid type values are removed from the configuration.
- Aliases are resolved to their corresponding field names.
(self) -> Generator[str, None, None]_Paths
(self, localDir=LOCAL_DIR, cacheDir=CACHE_DIR) -> NonePaths used by bamboost.
This dataclass contains the paths used by bamboost.
Attributes:
The directory where the local data is stored.
The directory where the cache is stored.
Bases
(self, name, value) -> NoneArguments:
- name:
str - value:
typing.Any
_Options
(self, mpi=importlib.util.find_spec('mpi4py') is not None, sortTableKey='created_at', sortTableOrder='desc', log_file_lock_severity='WARNING', log_root_only=False, logLevel='WARNING', clipboardCommand=None) -> NoneCore options for bamboost.
This dataclass contains the core options for bamboost.
Arguments:
- mpi:
bool=importlib.importlib.util.importlib.util.find_spec('mpi4py') is not None - sortTableKey:
str='created_at' - sortTableOrder:
str='desc' - log_file_lock_severity:
typing.Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']='WARNING' - log_root_only:
bool=False - logLevel:
typing.Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']='WARNING' - clipboardCommand:
str | None=None
Attributes:
- mpi:
bool=field(default=(importlib.util.find_spec('mpi4py') is not None))If True, the mpi4py package is available and used.
- sortTableKey:
str=field(default='created_at')The default key to sort the table by.
- sortTableOrder:
str=field(default='desc')The default order to sort the table by.
- log_file_lock_severity:
typing.Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']=field(default='WARNING')The severity level for the log file lock.
- log_root_only:
bool=FalseIf True, only the root logger is used.
- logLevel:
typing.Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']=field(default='WARNING')The log level for the logger.
- clipboardCommand:
str | None=NoneThe command to use for copying to the clipboard. If None, an error is raised if clipboard functionality is used but no command is set.
_IndexOptions
(self, searchPaths=(lambda: PathSet([Path('~').expanduser()]))(), excludeDirs=(lambda: DEFAULT_EXCLUDE_DIRS)(), extendDefaultExcludeDirs=None, syncTables=True, convertArrays=True, databaseFileName=DEFAULT_DATABASE_FILE_NAME, isolated=False, projectDir=None, strictLinks=True, strictLinksWhenSyncing=False) -> NoneIndex options for bamboost.
This dataclass contains the index options for bamboost.
Arguments:
- searchPaths:
typing.Iterable[typing.Union[str, pathlib.Path]]=(lambda: PathSet([Path('~').expanduser()]))() - excludeDirs:
typing.Iterable[str]=(lambda: DEFAULT_EXCLUDE_DIRS)() - extendDefaultExcludeDirs:
typing.Iterable[str] | None=None - syncTables:
bool=True - convertArrays:
bool=True - databaseFileName:
str=bamboost.constants.DEFAULT_DATABASE_FILE_NAME - isolated:
bool=False - projectDir:
typing.Optional[pathlib.Path]=None - strictLinks:
bool=True - strictLinksWhenSyncing:
bool=False
Attributes:
- _field_aliases=
{'paths': 'searchPaths'} - searchPaths:
typing.Iterable[typing.Union[str, pathlib.Path]]=field(default_factory=(lambda: PathSet([Path('~').expanduser()])))A list of paths to index.
- excludeDirs:
typing.Iterable[str]=field(default_factory=(lambda: DEFAULT_EXCLUDE_DIRS))The list of directory names to exclude from the search.
- extendDefaultExcludeDirs:
typing.Iterable[str] | None=NoneUse this to extend the default exclude directories.
- syncTables:
bool=field(default=True)If True, the sqlite tables are synchronized immediatly after some queries.
- convertArrays:
bool=TrueIf True, arrays are converted to np.arrays.
- databaseFileName:
str=field(default=DEFAULT_DATABASE_FILE_NAME)The name of the database file.
- databaseFile:
pathlib.Path=field(init=False)The path to the database file.
- isolated:
bool=FalseIf true, this project manages it's own database. The searchPaths are reduced to the project root only.
- projectDir:
typing.Optional[pathlib.Path]=NoneThe project directory, if found.
- strictLinks:
bool=TrueIf True, an error is raised when trying to set a link and the target is invalid.
- strictLinksWhenSyncing:
bool=FalseIf True, strictLinks is also applied when syncing the database. This can lead to errors if files have been moved or deleted since the last sync, but can help to catch issues early.
Bases
(self) -> None_Config
(self, project_dir=None) -> NoneConfiguration class for bamboost.
This class manages the configuration options and index settings for bamboost. It loads the configuration from a file and provides access to the options and index attributes.
Arguments:
Attributes:
Paths used by bamboost.
Configuration options for bamboost.
Index settings for bamboost.
- _remainder=
bamboost._config.config
Bases
(self) -> str
Bamboost