config

pydantic model Config[source]
Config:
  • extra: str = ignore

  • env_prefix: str = noob_

  • nested_model_default_partial_update: bool = True

  • env_file: str = .env

  • env_file_encoding: str = utf-8

  • env_nested_delimiter: str = __

  • yaml_file: str = noob_config.yaml

  • pyproject_toml_table_header: tuple = (‘tool’, ‘noob’, ‘config’)

Fields:
Validators:
field config_dirs: list[Path] [Optional]

Directory where config yaml files are stored

Validated by:
field logs: LogConfig = LogConfig(level='INFO', level_file=None, level_stdout=None, dir=False, file_n=5, file_size=4194304, width=None)
field tmp_dir: Path = PosixPath('/tmp/runtime-1005/noob')
Validated by:
field user_dir: Path = PosixPath('/home/docs/.local/share/noob')
Validated by:
validator create_dir  »  user_dir, tmp_dir, config_dirs[source]
classmethod settings_customise_sources(settings_cls: type[BaseSettings], init_settings: PydanticBaseSettingsSource, env_settings: PydanticBaseSettingsSource, dotenv_settings: PydanticBaseSettingsSource, file_secret_settings: PydanticBaseSettingsSource) tuple[PydanticBaseSettingsSource, ...][source]

Read config settings from, in order of priority from high to low, where high priorities override lower priorities:

  • in the arguments passed to the class constructor (not user configurable)

  • in environment variables like export NOOB_LOGS__DIR=~/

  • in a .env file in the working directory

  • in a noob_config.yaml file in the working directory

  • in the tool.noob.config table in a pyproject.toml file in the working directory

  • the default values in the Config model

pydantic model LogConfig[source]

Configuration for logging

Config:
  • validate_default: bool = True

Fields:
Validators:
field dir: Path | Literal[False] = PosixPath('/home/docs/.local/state/noob/log')

Directory where logs are stored.

Validated by:
field file_n: int = 5

Number of log files to rotate through

field file_size: int = 4194304

Maximum size of log files (bytes)

field level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'] = 'INFO'

Severity of log messages to process.

Validated by:
field level_file: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'] | None = None

Severity for file-based logging. If unset, use level

Validated by:
field level_stdout: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'] | None = None

Severity for stream-based logging. If unset, use level

Validated by:
field width: int | None = None

Explicitly set width of rich stdout logs, leave as None for auto detection.

validator create_dir  »  dir[source]
validator no_file_on_rtd  »  dir[source]

On readthedocs, don’t log to file

validator uppercase_levels  »  level, level_file, level_stdout[source]

Ensure log level strings are uppercased

add_config_source(path: Path) None[source]

Add a directory as a source of tube configs when searching by tube id

get_extra_sources() list[Path][source]

Get the extra sources added by add_config_source()

(avoid importing the private module-level collection anywhere else, as it makes mutation weird and unpredictable)

get_entrypoint_sources() list[Path][source]

Get additional config sources added by entrypoint functions.

Packages that ship noob tubes can make those tubes available by adding an entrypoint function with a signature () -> list[Path] to their pyproject.toml like:

[project.entry-points.”noob.add_sources”] tubes = “my_package.something:add_sources”

References

https://setuptools.pypa.io/en/latest/userguide/entry_point.html