examples: FireExample ORM class + round-trip test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
b5bfe8b73c
commit
8f2a80f563
2 changed files with 81 additions and 0 deletions
|
|
@ -322,6 +322,44 @@ class RetirementGoal(Base):
|
|||
server_default=func.now())
|
||||
|
||||
|
||||
class FireExample(Base):
|
||||
"""One Reddit-sourced FIRE example.
|
||||
|
||||
`reddit_id` UNIQUE makes re-ingest idempotent. Fields are nullable
|
||||
when the LLM couldn't extract them confidently — never inferred.
|
||||
Currency normalisation (portfolio_gbp / annual_exp_gbp) happens at
|
||||
extraction time using `fire_planner/fx.py`; `raw_currency` is kept
|
||||
for traceability.
|
||||
"""
|
||||
__tablename__ = "fire_example"
|
||||
__table_args__ = {"schema": SCHEMA_NAME} # noqa: RUF012
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
reddit_id: Mapped[str] = mapped_column(String(16), unique=True, nullable=False)
|
||||
source_sub: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
post_url: Mapped[str] = mapped_column(String, nullable=False)
|
||||
post_date: Mapped[date] = mapped_column(Date, nullable=False, index=True)
|
||||
post_title: Mapped[str] = mapped_column(String, nullable=False)
|
||||
country: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
||||
city: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
||||
portfolio_gbp: Mapped[Decimal | None] = mapped_column(Numeric(14, 2), nullable=True)
|
||||
annual_exp_gbp: Mapped[Decimal | None] = mapped_column(Numeric(12, 2), nullable=True)
|
||||
age: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
family_size: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
fi_status: Mapped[str | None] = mapped_column(String(24), nullable=True, index=True)
|
||||
is_retired: Mapped[bool | None] = mapped_column(Boolean, nullable=True)
|
||||
raw_currency: Mapped[str | None] = mapped_column(String(3), nullable=True)
|
||||
raw_excerpt: Mapped[str | None] = mapped_column(String, nullable=True)
|
||||
llm_model: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
llm_confidence: Mapped[Decimal | None] = mapped_column(Numeric(3, 2), nullable=True)
|
||||
extracted_at: Mapped[datetime] = mapped_column(TIMESTAMP(timezone=True),
|
||||
nullable=False,
|
||||
server_default=func.now())
|
||||
ingested_at: Mapped[datetime] = mapped_column(TIMESTAMP(timezone=True),
|
||||
nullable=False,
|
||||
server_default=func.now())
|
||||
|
||||
|
||||
def create_engine_from_env() -> AsyncEngine:
|
||||
url = os.environ["DB_CONNECTION_STRING"]
|
||||
return create_async_engine(url, pool_pre_ping=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue