Coverage for src/nendo/config.py: 100%

30 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-20 15:55 +0100

1"""Settings used to configure nendo.""" 

2from enum import Enum 

3from functools import lru_cache 

4from typing import List 

5 

6from pydantic import Field 

7from pydantic_settings import BaseSettings 

8 

9 

10class Environment(Enum): 

11 """Enum used to denote the environment in which nendo is running.""" 

12 

13 LOCAL = "local" 

14 TEST = "test" 

15 REMOTE = "remote" 

16 

17 

18class NendoConfig(BaseSettings): 

19 """The basic nendo configuration object. 

20 

21 Uses pydantic's settings management features. Refer to the 

22 [documentation page on configuration management](../usage/config.md) for 

23 a full list of configuration options. 

24 """ 

25 

26 environment: Environment = Field(default=Environment.LOCAL) 

27 log_level: str = Field(default="WARNING") 

28 log_file_path: str = Field(default="") 

29 plugins: List[str] = Field(default_factory=list) 

30 library_plugin: str = Field(default="default") 

31 library_path: str = Field(default="nendo_library") 

32 user_name: str = Field(default="nendo") 

33 user_id: str = Field(default="ffffffff-1111-2222-3333-1234567890ab") 

34 auto_resample: bool = Field(default=False) 

35 default_sr: int = Field(default=44100) 

36 copy_to_library: bool = Field(default=True) 

37 auto_convert: bool = Field(default=True) 

38 skip_duplicate: bool = Field(default=True) 

39 max_threads: int = Field(default=2) 

40 batch_size: int = Field(default=10) 

41 stream_mode: bool = Field(default=False) 

42 stream_chunk_size: int = Field(default=1) 

43 

44 

45@lru_cache() 

46def get_settings() -> NendoConfig: 

47 """Return the Nendo configuration, cached.""" 

48 return NendoConfig()