This is a question regarding developing process rather than the outcome.
I am familiar with the jupyter notebook / google colab environment and develop a habit of fragmenting code execution so I can review the output constantly.
However, I am quite confused on how to do that when developing with dash, especially with callback function. Here’s an example:
Blockquote
@callback(
Output(“a_dcc_download”, “data”),
Input(“a_button”, “n_clicks”),
State(“a_datatable”, ‘data’),
State(“a_datatable”, ‘columns’),
)
When I use callback similar to above code, is it possible for me to know what exactly the variable are storing and their corresponding data type? Since I am new to dash and not so familiar with the component property yet, I would like to preview these variable to know what I am inputting, like is it a dict or list?
I have tried ways below:
I try to assign global variable and store the input, but it is not successful
Blockquote
def function(n_clicks, data, column):
global x
x = data
Outcome in colab / jupyter notebook:
Another way I have tried is to print output, but when I execute the code, it only output the local link for my site, without executing the print method
Lastly I have tried to create a temporary div and output the variable as string to preview it.
Blockquote
html.Div(id=“temp_div”)
@callback(
Output(“temp_div”, “data”),
Input(“a_button”, “n_clicks”),
State(“a_datatable”, ‘data’),
State(“a_datatable”, ‘columns’),
)
def function(n_clicks, data, column):
x = str(data)
return x
This time I succeed and get a string of the variable printed in my site. But it is slow since I need to copy and paste it back to colab / jupyter notebook, store them in a variable and continue my development, especially when the vairable is a very long dictionary / dataframe
My question:
Is there an easier way to let me assign / preview input or output variable in callback when using Colab / Jupyter Notebook?
In the best scenario, I want to store them as a independent or temporary variable which I can use in another code block in Colab / Jupyter Notebook.
Sorry that the question is a bit long, thanks for reading.