config

pydantic model Config[source]

Show JSON schema
{
   "title": "Config",
   "type": "object",
   "properties": {
      "logs": {
         "$ref": "#/$defs/LogConfig",
         "default": {
            "level": "INFO",
            "level_file": null,
            "level_stdout": null,
            "dir": false,
            "file_n": 5,
            "file_size": 4194304,
            "width": null
         }
      },
      "user_dir": {
         "default": "/home/docs/.local/share/noob",
         "format": "path",
         "title": "User Dir",
         "type": "string"
      },
      "tmp_dir": {
         "default": "/run/user/1005/noob",
         "format": "path",
         "title": "Tmp Dir",
         "type": "string"
      },
      "config_dir": {
         "default": "/home/docs/.local/share/noob/config",
         "description": "Directory where config yaml files are stored",
         "format": "path",
         "title": "Config Dir",
         "type": "string"
      }
   },
   "$defs": {
      "LogConfig": {
         "description": "Configuration for logging",
         "properties": {
            "level": {
               "default": "INFO",
               "enum": [
                  "DEBUG",
                  "INFO",
                  "WARNING",
                  "ERROR"
               ],
               "title": "Level",
               "type": "string"
            },
            "level_file": {
               "anyOf": [
                  {
                     "enum": [
                        "DEBUG",
                        "INFO",
                        "WARNING",
                        "ERROR"
                     ],
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Level File"
            },
            "level_stdout": {
               "anyOf": [
                  {
                     "enum": [
                        "DEBUG",
                        "INFO",
                        "WARNING",
                        "ERROR"
                     ],
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Level Stdout"
            },
            "dir": {
               "anyOf": [
                  {
                     "format": "path",
                     "type": "string"
                  },
                  {
                     "const": false,
                     "type": "boolean"
                  }
               ],
               "default": "/home/docs/.local/state/noob/log",
               "title": "Dir"
            },
            "file_n": {
               "default": 5,
               "title": "File N",
               "type": "integer"
            },
            "file_size": {
               "default": 4194304,
               "title": "File Size",
               "type": "integer"
            },
            "width": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Width"
            }
         },
         "title": "LogConfig",
         "type": "object"
      }
   }
}

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_dir: Path = PosixPath('/home/docs/.local/share/noob/config')

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('/run/user/1005/noob')
Validated by:
field user_dir: Path = PosixPath('/home/docs/.local/share/noob')
Validated by:
validator create_dir  »  tmp_dir, config_dir, user_dir[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

Show JSON schema
{
   "title": "LogConfig",
   "description": "Configuration for logging",
   "type": "object",
   "properties": {
      "level": {
         "default": "INFO",
         "enum": [
            "DEBUG",
            "INFO",
            "WARNING",
            "ERROR"
         ],
         "title": "Level",
         "type": "string"
      },
      "level_file": {
         "anyOf": [
            {
               "enum": [
                  "DEBUG",
                  "INFO",
                  "WARNING",
                  "ERROR"
               ],
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Level File"
      },
      "level_stdout": {
         "anyOf": [
            {
               "enum": [
                  "DEBUG",
                  "INFO",
                  "WARNING",
                  "ERROR"
               ],
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Level Stdout"
      },
      "dir": {
         "anyOf": [
            {
               "format": "path",
               "type": "string"
            },
            {
               "const": false,
               "type": "boolean"
            }
         ],
         "default": "/home/docs/.local/state/noob/log",
         "title": "Dir"
      },
      "file_n": {
         "default": 5,
         "title": "File N",
         "type": "integer"
      },
      "file_size": {
         "default": 4194304,
         "title": "File Size",
         "type": "integer"
      },
      "width": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Width"
      }
   }
}

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_stdout, level_file, level[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