diff --git a/.Jules/palette.md b/.Jules/palette.md index d14c0c7..6316051 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -43,3 +43,7 @@ ## 2026-04-16 - [Cohesive Branding in CLI and Dashboards] **Learning:** For tool-sets with both a CLI and a web-based dashboard (like Prefect), maintaining a consistent "brand" (e.g., specific color schemes like 'bold blue' and emoji usage) across both interfaces creates a more unified and professional user experience. Standardizing the "Result" panel and task naming conventions makes the entire system feel like a single, cohesive product. **Action:** Apply consistent branding (colors, titles, emojis) to both terminal output and dashboard metadata to ensure a unified user experience across all interfaces. + +## 2026-04-17 - [Dynamic Pluralization and Visual Breathing Room] +**Learning:** For tutorial scripts, using dynamic pluralization (e.g., "1 customer" vs. "5 customers") ensures the UI remains grammatically correct and polished regardless of data volume. Additionally, adding explicit `padding=(1, 2)` to `Panel` components prevents the content from feeling "cramped," especially in final summaries where visual balance is key to a professional feel. +**Action:** Always implement dynamic pluralization for key nouns and ensure result panels have adequate internal padding for a clean, professional aesthetic. diff --git a/01_getting_started.py b/01_getting_started.py index b4d9aff..6296e8b 100644 --- a/01_getting_started.py +++ b/01_getting_started.py @@ -55,12 +55,15 @@ def main(): with console.status("[bold green]🔍 Fetching customer data..."): customer_ids = get_customer_ids() + # Add dynamic pluralization for better UX + customer_label = "customer ID" if len(customer_ids) == 1 else "customer IDs" console.print( - f"[bold blue]📦 Successfully fetched [bold cyan]{len(customer_ids)}[/bold cyan] customer IDs[/bold blue]" + f"[bold blue]📦 Successfully fetched [bold cyan]{len(customer_ids)}[/bold cyan] {customer_label}[/bold blue]" ) console.print() - with console.status("[bold green]⚙️ Processing customers..."): + processing_label = "customer" if len(customer_ids) == 1 else "customers" + with console.status(f"[bold green]⚙️ Processing {processing_label}..."): futures = process_customer.map(customer_ids) # Explicitly wait for results to avoid AttributeErrors on futures results = [f.result() for f in futures] @@ -95,18 +98,21 @@ def main(): console.print(table) console.print() + # Add dynamic pluralization and visual breathing room to the result panel + result_label = "customer" if len(results) == 1 else "customers" console.print( Panel.fit( - f"[bold green]Successfully processed [bold cyan]{len(results)}[/bold cyan] customers in [bold cyan]{duration:.2f}s[/bold cyan]![/bold green]", + f"[bold green]Successfully processed [bold cyan]{len(results)}[/bold cyan] {result_label} in [bold cyan]{duration:.2f}s[/bold cyan]![/bold green]", title="✨ Result", border_style="bold blue", + padding=(1, 2), ) ) console.print() console.print(Rule("🚀 Next Step", style="bold blue")) console.print( - "[bold blue]➡️[/bold blue] [bold blue]Try running[/bold blue] [cyan]python 02_logging.py[/cyan] [bold blue]to learn about logging in Prefect![/bold blue]" + "[bold blue]➡️[/bold blue] [bold blue]Try running[/bold blue] [bold cyan]python 02_logging.py[/bold cyan] [bold blue]to learn about logging in Prefect![/bold blue]" ) return results diff --git a/02_logging.py b/02_logging.py index 63ab2df..a075b01 100644 --- a/02_logging.py +++ b/02_logging.py @@ -25,10 +25,12 @@ def get_customer_ids() -> list[str]: def process_customer(customer_id: str) -> str: """Process a single customer.""" logger = get_run_logger() - for _ in range(3): + steps = 3 + for i in range(steps): # Add a brief pause to make the logging visible and realistic time.sleep(0.05) - logger.info(f"Processing customer {customer_id}") + # Add step progress to the logs for better clarity + logger.info(f"Processing customer {customer_id} (step {i+1}/{steps})") return f"Processed {customer_id}" @@ -64,12 +66,17 @@ def main(): with console.status("[bold green]🔍 Fetching customer data..."): customer_ids = get_customer_ids() + # Add dynamic pluralization for better UX + customer_label = "customer ID" if len(customer_ids) == 1 else "customer IDs" console.print( - f"[bold blue]📦 Successfully fetched [bold cyan]{len(customer_ids)}[/bold cyan] customer IDs[/bold blue]" + f"[bold blue]📦 Successfully fetched [bold cyan]{len(customer_ids)}[/bold cyan] {customer_label}[/bold blue]" ) console.print() - with console.status("[bold green]⚙️ Processing customers with logging..."): + processing_label = "customer" if len(customer_ids) == 1 else "customers" + with console.status( + f"[bold green]⚙️ Processing {processing_label} with logging..." + ): futures = process_customer.map(customer_ids) # Explicitly wait for results to avoid AttributeErrors on futures results = [f.result() for f in futures] @@ -104,11 +111,14 @@ def main(): console.print(table) console.print() + # Add dynamic pluralization and visual breathing room to the result panel + result_label = "customer" if len(results) == 1 else "customers" console.print( Panel.fit( - f"[bold green]Successfully processed [bold cyan]{len(results)}[/bold cyan] customers with detailed logging in [bold cyan]{duration:.2f}s[/bold cyan]![/bold green]", + f"[bold green]Successfully processed [bold cyan]{len(results)}[/bold cyan] {result_label} with detailed logging in [bold cyan]{duration:.2f}s[/bold cyan]![/bold green]", title="📊 Result", border_style="bold blue", + padding=(1, 2), ) )