92 lines
3.4 KiB
Python
92 lines
3.4 KiB
Python
"""
|
||
Main entry point for the Personal AI Fluency Plan project.
|
||
|
||
The script demonstrates how to use the :class:`plan.Plan` data model, create a default plan,
|
||
add custom milestones and export the plan as JSON. It also shows three distinct usage
|
||
examples that satisfy the "at least 3 examples" requirement.
|
||
|
||
Running ``python main.py`` will print the results of each example to stdout.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import json
|
||
from datetime import date, timedelta
|
||
|
||
# Import the plan module we created earlier
|
||
from plan import Plan, WeekPlan, Milestone
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Example 1: Create a default 9‑week plan and print it
|
||
# ---------------------------------------------------------------------------
|
||
|
||
def example_default_plan() -> None:
|
||
"""Instantiate a :class:`~plan.Plan` with the built‑in default weeks.
|
||
|
||
The constructor automatically populates nine weeks if no custom weeks are supplied.
|
||
"""
|
||
plan = Plan(start_date=date.today())
|
||
print("\n=== Example 1: Default 9‑week plan ===")
|
||
print(plan)
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Example 2: Add a custom week with two milestones and display the updated plan
|
||
# ---------------------------------------------------------------------------
|
||
|
||
def example_custom_week() -> None:
|
||
"""Create a plan, add a user‑defined week and show the result.
|
||
|
||
The new week starts one month after the default start date. Two milestones are added
|
||
to illustrate how the :class:`~plan.Milestone` objects can be constructed.
|
||
"""
|
||
base_plan = Plan(start_date=date.today())
|
||
custom_start = date.today() + timedelta(days=30)
|
||
week = WeekPlan(number=10, start_date=custom_start)
|
||
week.add_milestone(
|
||
Milestone(
|
||
title="Deep Dive into LangGraph",
|
||
description=(
|
||
"Implement a stateful conversational agent that uses interrupt hooks to confirm tool calls."
|
||
),
|
||
due_date=custom_start + timedelta(days=6),
|
||
)
|
||
)
|
||
week.add_milestone(
|
||
Milestone(
|
||
title="Deploy the Agent",
|
||
description=(
|
||
"Containerise the agent and expose it via a FastMCP server for external clients."
|
||
),
|
||
due_date=custom_start + timedelta(days=13),
|
||
)
|
||
)
|
||
base_plan.add_week(week)
|
||
|
||
print("\n=== Example 2: Plan with custom week added ===")
|
||
print(base_plan)
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Example 3: Export the plan to a JSON string and pretty‑print it
|
||
# ---------------------------------------------------------------------------
|
||
|
||
def example_export_json() -> None:
|
||
"""Export a :class:`~plan.Plan` instance to JSON.
|
||
|
||
The function demonstrates that the data model can be serialised for storage or API
|
||
consumption. It uses ``json.dumps`` with indentation for readability.
|
||
"""
|
||
plan = Plan(start_date=date.today())
|
||
json_str = json.dumps(plan.to_dict(), indent=2, ensure_ascii=False)
|
||
print("\n=== Example 3: Exported JSON ===")
|
||
print(json_str)
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Main entry point – run all examples when executed as a script
|
||
# ---------------------------------------------------------------------------
|
||
if __name__ == "__main__":
|
||
example_default_plan()
|
||
example_custom_week()
|
||
example_export_json()
|
||
|
||
# End of main.py
|