Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2025-05-15 - [Naming Conventions vs. Packaging Requirements]
**Learning:** In projects using numbered prefixes for demo scripts (e.g., `01_script.py`), these files cannot be used directly as console script entry points in `pyproject.toml` because they are not valid Python module names. Attempting to "fix" this by renaming the files may break established naming conventions and user expectations.
**Action:** Prefer maintaining existing naming conventions over forcing script entry points. If a demo script needs to be an entry point, create a separate wrapper module with a valid name rather than renaming the numbered file.
27 changes: 25 additions & 2 deletions 01_getting_started.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
from prefect import flow, task
import random
from rich.console import Console
from rich.panel import Panel

console = Console()


@task
def get_customer_ids() -> list[str]:
# Fetch customer IDs from a database or API
return [f"customer{n}" for n in random.choices(range(100), k=50)]


@task
def process_customer(customer_id: str) -> str:
# Process a single customer
return f"Processed {customer_id}"

@flow

@flow(log_prints=True)
def main() -> list[str]:
"""
### 🚀 Getting Started with Prefect
This flow demonstrates how to map a task over a list of inputs.
It fetches a list of customer IDs and processes each one individually.
"""
customer_ids = get_customer_ids()
# Map the process_customer task across all customer IDs
results = process_customer.map(customer_ids)
console.print(f"[bold blue]📦 Fetched {len(customer_ids)} customer IDs[/bold blue]")

with console.status("[bold green]Processing customers..."):
results = process_customer.map(customer_ids)

console.print(
Panel.fit(
f"[bold green]✅ Successfully processed {len(results)} customers![/bold green]",
title="Success",
border_style="green",
)
)
return results


Expand Down
2 changes: 2 additions & 0 deletions 02_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def get_customer_ids() -> list[str]:
# Fetch customer IDs from a database or API
return [f"customer{n}" for n in random.choices(range(100), k=50)]


@task
def process_customer(customer_id: str) -> str:
# Process a single customer
Expand All @@ -16,6 +17,7 @@ def process_customer(customer_id: str) -> str:
logger.info(f"Processing customer {customer_id}")
return f"Processed {customer_id}"


@flow
def main() -> list[str]:
customer_ids = get_customer_ids()
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ dependencies = [
"prefect-cloud",
]

[project.scripts]
quickstart-demo = "getting_started:main"
Loading