config

Module-global configuration models

pydantic settings miniscope_io.models.config.Config

Runtime configuration for miniscope-io.

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

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

See .env.example in repository root

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

Show JSON schema
{
   "title": "Config",
   "description": "Runtime configuration for miniscope-io.\n\nSee https://docs.pydantic.dev/latest/concepts/pydantic_settings/\n\nSet values either in an ``.env`` file or using environment variables\nprefixed with ``MINISCOPE_IO_*``. Values in nested models are separated with ``__`` ,\neg. ``MINISCOPE_IO_LOGS__LEVEL``\n\nSee ``.env.example`` in repository root\n\nPaths are set relative to ``base_dir`` by default, unless explicitly specified.",
   "type": "object",
   "properties": {
      "base_dir": {
         "default": "/home/docs/.config/miniscope_io",
         "description": "Base directory to store configuration and other temporary files, other paths are relative to this by default",
         "format": "path",
         "title": "Base Dir",
         "type": "string"
      },
      "log_dir": {
         "default": "logs",
         "description": "Location to store logs",
         "format": "path",
         "title": "Log Dir",
         "type": "string"
      },
      "logs": {
         "allOf": [
            {
               "$ref": "#/$defs/LogConfig"
            }
         ],
         "default": {
            "level": "INFO",
            "level_file": "INFO",
            "level_stdout": "INFO",
            "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 = miniscope_io_

  • env_file: str = .env

  • env_nested_delimiter: str = __

Fields:
Validators:
field base_dir: Path = PosixPath('/home/docs/.config/miniscope_io')

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

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

Location to store logs

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

Additional settings for logs

Validated by:
validator folder_exists  »  base_dir

Ensure base_dir exists, make it otherwise

validator paths_relative_to_basedir  »  all fields

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

pydantic model miniscope_io.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

Validated by:
field file_size: int = 4194304

Maximum size of log files (bytes)

Validated by:
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 inherit_base_level  »  all fields

If loglevels for specific output streams are unset, set from base level

validator uppercase_levels  »  level_file, level, level_stdout

Ensure log level strings are uppercased