File size: 1,109 Bytes
72eadef | 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 | """Runtime configuration."""
from __future__ import annotations
import os
from dataclasses import dataclass
from pathlib import Path
DEFAULT_HF_REPO = "ZipLime/corporate-actions"
# Everything here is derived from one sibling dataset. No new source is
# fetched: the dividends were already parsed out of XBRL, and the splits are
# recovered from the restatement history that dataset keeps precisely because
# it never overwrites what a filing said.
SOURCE_REPO = "ZipLime/company-fundamentals"
SIBLING_DIR = "Company_fundamentals"
@dataclass(frozen=True, slots=True)
class Settings:
data_dir: Path = Path("data")
hf_repo: str = DEFAULT_HF_REPO
siblings_dir: Path | None = None
@classmethod
def from_env(cls, **overrides) -> Settings:
siblings = os.environ.get("CORPORATE_ACTIONS_SIBLINGS")
return cls(
data_dir=Path(overrides.get("data_dir") or os.environ.get("DATA_DIR", "data")),
hf_repo=overrides.get("hf_repo") or os.environ.get("HF_DATASET_REPO", DEFAULT_HF_REPO),
siblings_dir=Path(siblings) if siblings else None,
)
|