diff --git a/01_getting_started.py b/01_getting_started.py index 3d5fcb7..2f57417 100644 --- a/01_getting_started.py +++ b/01_getting_started.py @@ -2,6 +2,7 @@ import random from rich.console import Console from rich.panel import Panel +from rich.rule import Rule console = Console() @@ -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. @@ -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 diff --git a/02_logging.py b/02_logging.py index f5c436b..5a0753b 100644 --- a/02_logging.py +++ b/02_logging.py @@ -3,6 +3,7 @@ import random from rich.console import Console from rich.panel import Panel +from rich.rule import Rule console = Console() @@ -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 @@ -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( @@ -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