Skip to content

Configuration

taxotagger

ProjectConfig

Bases: BaseModel

Configuration for the project.

Attributes:

  • mycoai_home (str) –

    The working directory for the project. Downloads and cache files are stored here. Defaults to ~/.cache/mycoai.

    You can also set the MYCOAI_HOME environment variable to override this, e.g. on Linux or macOS: export MYCOAI_HOME="~/mycoai".

  • device (str) –

    The device to run the model on. Defaults to "cpu".

    Available options are:

    • "cpu": when no GPU is available,
    • "cuda": when NVIDIA GPUs are available, use "cuda:0" to use the first GPU
    • "mps": when Mac GPUs are available
    • and any other valid PyTorch device

    For more information, see the PyTorch documentation.

  • force_reload (bool) –

    Whether to force reload the model. Defaults to False.

  • log_level (Literal['NONSET', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']) –

    The log level. Use the logging module's log level constants. Defaults to "INFO".

  • log_file (str) –

    The file to write the log to. If the file is an empty string (by default), the log will not be written to a file. If the file does not exist, it will be created. The log will be written to the file in append mode.

  • log_to_console (bool) –

    Whether to log to the console. Defaults to True.

Examples:

Get the default configuration

>>> config = ProjectConfig()
>>> print(config)

Set the working directory to "~/mycoai"

>>> config = ProjectConfig(mycoai_home="~/mycoai")
>>> print(config.mycoai_home)

mycoai_home class-attribute instance-attribute

mycoai_home: str = Field(
    default_factory=lambda: expanduser(
        getenv(ENV_MYCOAI_HOME, DEFAULT_CACHE_DIR)
    ),
    min_length=1,
)

device class-attribute instance-attribute

device: str = Field(default='cpu', min_length=1)

force_reload class-attribute instance-attribute

force_reload: bool = Field(default=False, strict=True)

log_level class-attribute instance-attribute

log_level: Literal[
    "NONSET",
    "DEBUG",
    "INFO",
    "WARNING",
    "ERROR",
    "CRITICAL",
] = Field(default="INFO")

log_file class-attribute instance-attribute

log_file: str = Field(default='')

log_to_console class-attribute instance-attribute

log_to_console: bool = Field(default=True, strict=True)