In Assette Data Blocks, the response
keyword is a predefined object used to define the outputs of a Data Block. These outputs are then consumed by report components such as tables, charts, or text fields in Assette deliverables. Proper use of the response
object is essential for ensuring that the processed data is returned correctly and in a usable structure.
This article explores how response
works, how to use it, and provides a detailed walkthrough based on a comprehensive Data Block example.
What Is response
? #
The response
object is a dictionary-like container automatically available in every Assette Data Block. Authors use it to assign one or more named outputs that will be referenced by the report or downstream components.
Each entry in the response
object must have:
- A key: a string that identifies the name of the output.
- A value: the actual data to be rendered—typically a list of dictionaries, a string, a number, or a pandas DataFrame.
This design makes response
the final handoff point between the Data Block and the presentation layer.
Syntax for response
#
response["<key>"] = <value>
Parameters: #
<key>
: A string that defines the name of the output. This name must match the element name expected in the report, chart, table, or downstream Data Block.<value>
: The data you want to return. This can be:- A
list
of dictionaries (the most common structure) - A
pandas.DataFrame
(automatically converted to a list of dictionaries) - A string, number, or boolean (for text or scalar outputs)
- A JSON-serializable structure
- A
Best Practices #
- Always assign your final processed result to
response
under a clearly named key (e.g.,"data"
,"results"
, or context-specific names). - Sanitize your data structure to avoid nulls, missing keys, or unexpected types.
- The Data Block should only have a single output
Troubleshooting #
- Failing to assign to
response
: Ifresponse
is never populated, the Data Block will execute but produce no visible results. - Using invalid data types: Make sure to return serializable structures (lists, dictionaries, DataFrames). Complex objects or classes will cause errors.
- Overwriting keys unintentionally: Avoid assigning to the same key multiple times unless intentionally updating the value.