Smart Python Read
In this guide, we'll build a Smart Python Read Component that leverages Ascend's Smart partitioning feature to efficiently ingest partitioned datasets by discovering and processing partitions in parallel.
Prerequisites
- Ascend Flow
Create a new Component
From your Workspace Super Graph view, follow these steps to create your Component:
- Form
- Files panel
- Double-click the Flow where you want to create your Component
- Right-click anywhere in the Flow Graph
- Hover over Create Component, then over Read in the expanded menu, and click From Scratch

- Complete the form with these details:
- Select your Flow
- Enter a descriptive Component Name like
read_sales - Select Python as your file type

- Open the files panel in the top left corner
- Navigate to and select your desired Flow
- Right-click on the components directory and choose New file

- Name your file with a descriptive name like
read_sales.pyand press enter
Create your Smart Python Read Component
Structure your Smart Python Read Component following this pattern, based on our Otto's Expeditions Project:
- Import necessary packages: Include Ascend resources (
reader), context handlers (ComponentExecutionContext), data processing libraries (Polarsandpyarrowin this examples), filesystem libraries (gcsfsin this examples), and logging utilities (log) - Define a partition listing function with the
@reader.list()decorator: Discover and yield partitions to process - Define a partition read function with the
@reader.read()decorator: Read each partition identified by the listing function - Return structured data: Ensure the read function returns an Arrow table for efficient downstream processing
The @reader.list() and @reader.read() decorators integrate into Ascend's Smart partitioning framework, enabling parallel ingestion across data partitions.
Example
Check out our reference guide for additional examples and advanced options.
🎉 Congratulations! You've successfully created a Smart Python Read Component in Ascend.