-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathconfig.py
More file actions
43 lines (34 loc) · 1.32 KB
/
config.py
File metadata and controls
43 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Configuration for CNPJ data pipeline."""
import os
from dataclasses import dataclass
from dotenv import load_dotenv
load_dotenv()
@dataclass
class Config:
"""Pipeline configuration with sensible defaults."""
database_url: str
batch_size: int = 500000
temp_dir: str = "./temp"
download_workers: int = 4
retry_attempts: int = 3
retry_delay: int = 5
connect_timeout: int = 30
read_timeout: int = 300
keep_files: bool = False
base_url: str = "https://arquivos.receitafederal.gov.br/public.php/webdav"
share_token: str = "YggdBLfdninEJX9"
@classmethod
def from_env(cls) -> "Config":
"""Create config from environment variables."""
return cls(
database_url=os.getenv("DATABASE_URL", ""),
batch_size=int(os.getenv("BATCH_SIZE", "500000")),
temp_dir=os.getenv("TEMP_DIR", "./temp"),
download_workers=int(os.getenv("DOWNLOAD_WORKERS", "4")),
retry_attempts=int(os.getenv("RETRY_ATTEMPTS", "3")),
retry_delay=int(os.getenv("RETRY_DELAY", "5")),
connect_timeout=int(os.getenv("CONNECT_TIMEOUT", "30")),
read_timeout=int(os.getenv("READ_TIMEOUT", "300")),
keep_files=os.getenv("KEEP_DOWNLOADED_FILES", "false").lower() == "true",
)
config = Config.from_env()