|
16 | 16 | import json |
17 | 17 | import os |
18 | 18 | import uuid |
19 | | -from typing import Any, BinaryIO, Literal, Optional, TextIO |
| 19 | +from typing import Any, BinaryIO, Literal, TextIO |
20 | 20 |
|
21 | 21 | import requests |
22 | 22 | import tos |
|
44 | 44 |
|
45 | 45 |
|
46 | 46 | class VolcengineTOSConfig(BaseModel): |
47 | | - endpoint: Optional[str] = Field( |
48 | | - default=getenv("DATABASE_TOS_ENDPOINT", "tos-cn-beijing.volces.com"), |
| 47 | + endpoint: str = Field( |
| 48 | + default_factory=lambda: getenv( |
| 49 | + "DATABASE_TOS_ENDPOINT", "tos-cn-beijing.volces.com" |
| 50 | + ), |
49 | 51 | description="VikingDB TOS endpoint", |
50 | 52 | ) |
51 | | - region: Optional[str] = Field( |
52 | | - default=getenv("DATABASE_TOS_REGION", "cn-beijing"), |
| 53 | + region: str = Field( |
| 54 | + default_factory=lambda: getenv("DATABASE_TOS_REGION", "cn-beijing"), |
53 | 55 | description="VikingDB TOS region", |
54 | 56 | ) |
55 | | - bucket: Optional[str] = Field( |
56 | | - default=getenv("DATABASE_TOS_BUCKET"), |
| 57 | + bucket: str = Field( |
| 58 | + default_factory=lambda: getenv("DATABASE_TOS_BUCKET"), |
57 | 59 | description="VikingDB TOS bucket", |
58 | 60 | ) |
59 | | - base_key: Optional[str] = Field( |
| 61 | + base_key: str = Field( |
60 | 62 | default="veadk", |
61 | 63 | description="VikingDB TOS base key", |
62 | 64 | ) |
63 | 65 |
|
64 | 66 |
|
65 | 67 | class VikingDatabaseConfig(BaseModel): |
66 | | - volcengine_ak: Optional[str] = Field( |
67 | | - default=getenv("VOLCENGINE_ACCESS_KEY"), |
| 68 | + volcengine_ak: str = Field( |
| 69 | + default_factory=lambda: getenv("VOLCENGINE_ACCESS_KEY"), |
68 | 70 | description="VikingDB access key", |
69 | 71 | ) |
70 | | - volcengine_sk: Optional[str] = Field( |
71 | | - default=getenv("VOLCENGINE_SECRET_KEY"), |
| 72 | + volcengine_sk: str = Field( |
| 73 | + default_factory=lambda: getenv("VOLCENGINE_SECRET_KEY"), |
72 | 74 | description="VikingDB secret key", |
73 | 75 | ) |
74 | | - project: Optional[str] = Field( |
75 | | - default=getenv("DATABASE_VIKING_PROJECT"), |
| 76 | + project: str = Field( |
| 77 | + default_factory=lambda: getenv("DATABASE_VIKING_PROJECT"), |
76 | 78 | description="VikingDB project name", |
77 | 79 | ) |
78 | | - region: Optional[str] = Field( |
79 | | - default=getenv("DATABASE_VIKING_REGION"), |
| 80 | + region: str = Field( |
| 81 | + default_factory=lambda: getenv("DATABASE_VIKING_REGION"), |
80 | 82 | description="VikingDB region", |
81 | 83 | ) |
82 | | - tos: Optional[VolcengineTOSConfig] = Field( |
| 84 | + tos: VolcengineTOSConfig = Field( |
83 | 85 | default_factory=VolcengineTOSConfig, |
84 | 86 | description="VikingDB TOS configuration", |
85 | 87 | ) |
|
0 commit comments