From 47066306a42dca594a6b32c987ff96802a9fe921 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 5 Apr 2026 05:23:14 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Improve=20CLI=20feedb?= =?UTF-8?q?ack=20and=20visual=20hierarchy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add execution duration to final result panels using time.perf_counter() - Switch to random.sample for unique customer ID generation in demos - Enhance rich.Rule components with descriptive titles for better navigation - Clean up guidance messages for improved readability Co-authored-by: ruh-al-tarikh <203426218+ruh-al-tarikh@users.noreply.github.com> --- 01_getting_started.py | 13 +++++++++---- 02_logging.py | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/01_getting_started.py b/01_getting_started.py index 8f31d36..392e45d 100644 --- a/01_getting_started.py +++ b/01_getting_started.py @@ -14,7 +14,8 @@ def get_customer_ids() -> list[str]: """Fetch customer IDs from a database or API.""" # Use sorted and zero-padded IDs for better terminal alignment - ids = [f"customer-{n:02d}" for n in random.choices(range(100), k=5)] + # Use random.sample to ensure unique customer IDs + ids = [f"customer-{n:02d}" for n in random.sample(range(100), k=5)] return sorted(ids) @@ -34,6 +35,8 @@ def main(): 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. """ + start_time = time.perf_counter() + # Display the flow's purpose for a guided onboarding experience if main.__doc__: console.print( @@ -79,17 +82,19 @@ def main(): console.print(table) console.print() + duration = time.perf_counter() - start_time + console.print( Panel.fit( - f"[bold green]✨ Successfully processed {len(results)} customers![/bold green]", + f"[bold green]✨ Successfully processed {len(results)} customers in {duration:.2f}s![/bold green]", title="Result", border_style="green", ) ) - console.print(Rule(style="blue")) + console.print(Rule("Next Step", style="blue")) console.print( - "[bold blue]➡️ Next Step:[/bold blue] Try running [cyan]python 02_logging.py[/cyan] to learn about logging in Prefect!" + "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 3d14d66..03a957e 100644 --- a/02_logging.py +++ b/02_logging.py @@ -15,7 +15,8 @@ def get_customer_ids() -> list[str]: """Fetch customer IDs from a database or API.""" # Use sorted and zero-padded IDs for better terminal alignment - ids = [f"customer-{n:02d}" for n in random.choices(range(100), k=5)] + # Use random.sample to ensure unique customer IDs + ids = [f"customer-{n:02d}" for n in random.sample(range(100), k=5)] return sorted(ids) @@ -43,6 +44,8 @@ def main(): - Use the Prefect logger for structured logging in tasks. - Map tasks across a list of inputs. """ + start_time = time.perf_counter() + # Display the flow's purpose for a guided onboarding experience if main.__doc__: console.print( @@ -88,17 +91,19 @@ def main(): console.print(table) console.print() + duration = time.perf_counter() - start_time + console.print( Panel.fit( - f"[bold green]✨ Successfully processed {len(results)} customers with detailed logging![/bold green]", + f"[bold green]✨ Successfully processed {len(results)} customers with detailed logging in {duration:.2f}s![/bold green]", title="Result", border_style="green", ) ) - console.print(Rule(style="blue")) + console.print(Rule("Conclusion", style="blue")) console.print( - "[bold blue]🎉 You've completed the Quickstart! Check out the [cyan]README.md[/cyan] for more features.[/bold blue]" + "🎉 You've completed the Quickstart! Check out the [cyan]README.md[/cyan] for more features." ) return results