config

Module-global configuration models

pydantic settings mio.models.config.Config

Runtime configuration for mio.

See https://docs.pydantic.dev/latest/concepts/pydantic_settings/

Set values either in an .env file or using environment variables prefixed with MIO_*. Values in nested models are separated with __ , eg. MIO_LOGS__LEVEL

See .env.example in repository root

Paths are set relative to user_dir by default, unless explicitly specified.

Show JSON schema
{
   "title": "Config",
   "description": "Runtime configuration for mio.\n\nSee https://docs.pydantic.dev/latest/concepts/pydantic_settings/\n\nSet values either in an ``.env`` file or using environment variables\nprefixed with ``MIO_*``. Values in nested models are separated with ``__`` ,\neg. ``MIO_LOGS__LEVEL``\n\nSee ``.env.example`` in repository root\n\nPaths are set relative to ``user_dir`` by default, unless explicitly specified.",
   "type": "object",
   "properties": {
      "user_dir": {
         "default": "/home/docs/.config/mio",
         "description": "Base directory to store user configuration and other temporary files, other paths are relative to this by default",
         "format": "path",
         "title": "User Dir",
         "type": "string"
      },
      "config_dir": {
         "default": "config",
         "description": "Location to store user configs",
         "format": "path",
         "title": "Config Dir",
         "type": "string"
      },
      "log_dir": {
         "default": "logs",
         "description": "Location to store logs",
         "format": "path",
         "title": "Log Dir",
         "type": "string"
      },
      "logs": {
         "$ref": "#/$defs/LogConfig",
         "default": {
            "level": "INFO",
            "level_file": null,
            "level_stdout": null,
            "file_n": 5,
            "file_size": 4194304
         },
         "description": "Additional settings for logs"
      }
   },
   "$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"
            },
            "file_n": {
               "default": 5,
               "title": "File N",
               "type": "integer"
            },
            "file_size": {
               "default": 4194304,
               "title": "File Size",
               "type": "integer"
            }
         },
         "title": "LogConfig",
         "type": "object"
      }
   }
}

Config:
  • extra: str = ignore

  • env_prefix: str = mio_

  • nested_model_default_partial_update: bool = True

  • env_file: str = .env

  • env_nested_delimiter: str = __

  • yaml_file: str = mio_config.yaml

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

Fields:
Validators:
field config_dir: Path = PosixPath('config')

Location to store user configs

Validated by:
field log_dir: Path = PosixPath('logs')

Location to store logs

Validated by:
field logs: LogConfig = LogConfig(level='INFO', level_file=None, level_stdout=None, file_n=5, file_size=4194304)

Additional settings for logs

Validated by:
field user_dir: Path = PosixPath('/home/docs/.config/mio')

Base directory to store user configuration and other temporary files, other paths are relative to this by default

Validated by:
validator folder_exists  »  user_dir

Ensure user_dir exists, make it otherwise

validator paths_relative_to_basedir  »  all fields

If relative paths are given, make them absolute relative to user_dir

pydantic model mio.models.config.LogConfig

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"
      },
      "file_n": {
         "default": 5,
         "title": "File N",
         "type": "integer"
      },
      "file_size": {
         "default": 4194304,
         "title": "File Size",
         "type": "integer"
      }
   }
}

Fields:
Validators:
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:
validator uppercase_levels  »  level_stdout, level, level_file

Ensure log level strings are uppercased

mio.models.config.set_user_dir(path: Path) None

Set the location of the user dir in the global config file