generated from coulomb/repo-seed
Implement canonical pricing core and close WP-0003
This commit is contained in:
12
projects/coulomb-pricing/observatory/_repo_root.py
Normal file
12
projects/coulomb-pricing/observatory/_repo_root.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[3]
|
||||
|
||||
|
||||
def ensure_repo_root_on_syspath() -> None:
|
||||
root = str(REPO_ROOT)
|
||||
if root not in sys.path:
|
||||
sys.path.insert(0, root)
|
||||
@@ -4,6 +4,10 @@ import json
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
|
||||
from ._repo_root import ensure_repo_root_on_syspath
|
||||
ensure_repo_root_on_syspath()
|
||||
|
||||
from adaptive_pricing_core.pricing_models import load_pricing_models as load_canonical_pricing_models
|
||||
from .ledger import build_monthly_ledger
|
||||
from .models import (
|
||||
Budget,
|
||||
@@ -50,20 +54,7 @@ def load_budget(data_dir: Path | None = None) -> Budget:
|
||||
|
||||
|
||||
def load_pricing_models(data_dir: Path | None = None) -> list[PricingModel]:
|
||||
raw = _read_json((data_dir or default_data_dir()) / "pricing-models.json")
|
||||
return [
|
||||
PricingModel(
|
||||
id=item["id"],
|
||||
name=item["name"],
|
||||
model_type=item["model_type"],
|
||||
lifecycle_phase=item["lifecycle_phase"],
|
||||
currency=item["currency"],
|
||||
access_fee_amount=_money(item["access_fee_amount"]),
|
||||
access_fee_cadence=item["access_fee_cadence"],
|
||||
status=item["status"],
|
||||
)
|
||||
for item in raw["models"]
|
||||
]
|
||||
return load_canonical_pricing_models((data_dir or default_data_dir()) / "pricing-models.json")
|
||||
|
||||
|
||||
def load_fx_rates(data_dir: Path | None = None) -> dict[str, Decimal]:
|
||||
@@ -150,4 +141,4 @@ def load_monthly_ledger(data_dir: Path | None = None) -> list[MonthlyPlatformCos
|
||||
|
||||
|
||||
def latest_period(monthly_costs: list[MonthlyPlatformCost]) -> str:
|
||||
return max(item.period for item in monthly_costs)
|
||||
return max(item.period for item in monthly_costs)
|
||||
|
||||
@@ -4,9 +4,20 @@ from dataclasses import dataclass
|
||||
from decimal import Decimal
|
||||
from typing import Literal
|
||||
|
||||
from ._repo_root import ensure_repo_root_on_syspath
|
||||
|
||||
ensure_repo_root_on_syspath()
|
||||
|
||||
from adaptive_pricing_core.pricing_models import ( # noqa: E402
|
||||
ChargeComponent,
|
||||
Commitment,
|
||||
PricingModel,
|
||||
PricingModelStatus,
|
||||
TunableParameter,
|
||||
)
|
||||
|
||||
ExpenseClass = Literal["infrastructure", "payment_processing"]
|
||||
MemberStatus = Literal["active", "churned", "paused"]
|
||||
PricingModelStatus = Literal["active", "candidate", "retired"]
|
||||
LiquidityStatus = Literal["burning", "neutral", "generating"]
|
||||
|
||||
|
||||
@@ -20,18 +31,6 @@ class Product:
|
||||
active_pricing_model_id: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PricingModel:
|
||||
id: str
|
||||
name: str
|
||||
model_type: str
|
||||
lifecycle_phase: str
|
||||
currency: str
|
||||
access_fee_amount: Decimal
|
||||
access_fee_cadence: str
|
||||
status: PricingModelStatus
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ExpenseRecord:
|
||||
id: str
|
||||
@@ -118,4 +117,4 @@ class LiquiditySummary:
|
||||
cumulative_net_liquidity: Decimal
|
||||
remaining_budget: Decimal
|
||||
liquidity_status: LiquidityStatus
|
||||
months_tracked: int
|
||||
months_tracked: int
|
||||
|
||||
Reference in New Issue
Block a user