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
6 changes: 4 additions & 2 deletions 01_getting_started.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import random
from rich.console import Console
from rich.panel import Panel
from rich.rule import Rule

console = Console()

Expand All @@ -19,7 +20,7 @@ def process_customer(customer_id: str) -> str:


@flow(log_prints=True)
def main() -> list[str]:
def main():
"""
### 🚀 Getting Started with Prefect
This flow demonstrates how to map a task over a list of inputs.
Expand All @@ -40,8 +41,9 @@ def main() -> list[str]:
)
)

console.print(Rule(style="blue"))
console.print(
"\n[bold blue]➡️ Next Step:[/bold blue] Try running [cyan]python 02_logging.py[/cyan] to learn about logging in Prefect!"
"[bold blue]➡️ Next Step:[/bold blue] Try running [cyan]python 02_logging.py[/cyan] to learn about logging in Prefect!"
)

return results
Expand Down
13 changes: 9 additions & 4 deletions 02_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
from rich.console import Console
from rich.panel import Panel
from rich.rule import Rule

console = Console()

Expand All @@ -17,13 +18,13 @@ def get_customer_ids() -> list[str]:
def process_customer(customer_id: str) -> str:
# Process a single customer
logger = get_run_logger()
for _ in range(50):
for _ in range(3):
logger.info(f"Processing customer {customer_id}")
return f"Processed {customer_id}"


@flow(log_prints=True)
def main() -> list[str]:
def main():
"""
### 📊 Logging with Prefect

Expand All @@ -37,7 +38,10 @@ def main() -> list[str]:
"""
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 with logging..."):
results = process_customer.map(customer_ids)

console.print(
Panel.fit(
Expand All @@ -47,8 +51,9 @@ def main() -> list[str]:
)
)

console.print(Rule(style="blue"))
console.print(
"\n[bold blue]🎉 You've completed the Quickstart! Check out the [cyan]README.md[/cyan] for more features.[/bold blue]"
"[bold blue]🎉 You've completed the Quickstart! Check out the [cyan]README.md[/cyan] for more features.[/bold blue]"
)

return results
Expand Down
Loading