hooks
The second required parameter for all run functions is hooks:
# modules/hello_world.py
import prism.task
import prism.target
class HelloWorld(prism.task.PrismTask):
def run(self, tasks, hooks):
test_str = "Hello, world!"
return test_strThis parameter is an instance of the PrismHooks class, a high-level interface that lets you quickly and easily talk to external connections without having to write low-level code or use special libraries.
The following hooks are available to Prism users:
hooks.sql(): execute SQL code using specific adaptershooks.spark(): execute PySpark codehooks.dbt_ref(): convert materialized dbt models into Pandas DataFrameshooks.get_connection(): retrieve the connection instance (for SQL adapters)hooks.get_cursor(): retrieve a cursor instance (for SQL adapters)
If you want to access these hooks outside of a task, you can use the load_hooks() function. Check out the API documentation for more information.
Last updated