Python Task
Task Components in Ascend let you execute arbitrary Python code as a Component. Unlike Transforms, Python Tasks aren't directly tied to the Data Plane, giving you more flexibility.
Structure your Task Component
The @task
decorator defines dependencies and execution context for your Python Task. This decorator specifies input data and any Components that your Task depends on.
Example
Here's a Python Task Component example:
This example computes metrics using Ibis expressions and logs the results:
-
Task decorator: The
@task
decorator establishes dependencies. In this case, it depends on thetop_guides
Component which provides the input data. -
Aggregation: The code computes metrics with Ibis expressions, calculating average customer ratings and total expeditions led by aggregating data from the
top_guides
table. -
Materialization: Results are converted to a PyArrow table with individual metrics extracted for logging.
-
Logging: The computed metrics are logged to provide insights into average customer ratings and total expeditions.
Next steps
- Learn more about Tasks in our concept guide
- Explore Task options in our reference guide