From c5faf34114bb80cd2a52a6fba26402284f295fa0 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 26 Mar 2026 05:14:40 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20UX=20enhancements=20f?= =?UTF-8?q?or=20CLI=20and=20Prefect=20UI=20in=2001=5Fgetting=5Fstarted.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Integrated 'rich' for colorful and interactive CLI output (status spinner, success panel). - Added a descriptive Markdown docstring to the '@flow' for better documentation in the Prefect UI. - Enabled 'log_prints=True' to ensure all output is captured in Prefect logs. - Removed the broken 'quickstart-demo' entry point in 'pyproject.toml' to restore the original naming convention. - Added a journal entry for project-specific learnings. Co-authored-by: ruh-al-tarikh <203426218+ruh-al-tarikh@users.noreply.github.com> --- .Jules/palette.md | 3 +++ 01_getting_started.py | 27 +++++++++++++++++++++++++-- 02_logging.py | 2 ++ pyproject.toml | 2 -- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 .Jules/palette.md diff --git a/.Jules/palette.md b/.Jules/palette.md new file mode 100644 index 0000000..3a36227 --- /dev/null +++ b/.Jules/palette.md @@ -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. diff --git a/01_getting_started.py b/01_getting_started.py index 049b084..b3692ff 100644 --- a/01_getting_started.py +++ b/01_getting_started.py @@ -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 diff --git a/02_logging.py b/02_logging.py index 752a596..92837c6 100644 --- a/02_logging.py +++ b/02_logging.py @@ -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 @@ -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() diff --git a/pyproject.toml b/pyproject.toml index 7b15b2a..e012eac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,5 +9,3 @@ dependencies = [ "prefect-cloud", ] -[project.scripts] -quickstart-demo = "getting_started:main"