Input blocks
Adding input blocks
Input blocks are a great way to add different user inputs to be used as variables within your code and SQL blocks.
You can easily add an input block to your notebook by clicking the block adder between blocks. Alternatively, you can add input blocks by clicking the Input button at the bottom of your notebook or using the command palette.
Once you've added an input block, you can adjust various settings like variable name and display name. Explore more options for the given input type.
Using input variables in notebook
You can use the inputs as variables within your code. For example, you can use the date input variable in the code block to filter DataFrame data.
You can also pass on input variables as parameters in your SQL blocks.
Using input variables in app
Even though all inputs work great both in the notebook and in the app some are particularly powerful in the app.
File input
The file input block allows users to easily upload files to your app for further processing.
After uploading the file, the input variable will contain the path to the file. All files are stored in the file_input_uploads folder within your projects and the maximum file size is 5GB. It's also possible to specify allowed file extensions and MIME types.
Button
The button can be used as a custom run (execution) button, which is very handy when building forms, for example. More behaviors are coming soon.
Dynamic input variables
In some cases, you may want to dynamically generate the list of available values in select inputs instead of using pre-defined values. You can do so by clicking on input settings and select the 'From variable' option at the Values section. In the dropdown you will need to pick one of your existing variables (supported python types that can be used are: list
, ndarray
, DataFrame
, and Series
).
Once you select the variable, the values in the list will be then made available as user inputs in the select input dropdown.
Limits for using dynamic input variables:
- Only variables with 1,000 elements or fewer are supported.
- Total characters of all elements cannot exceed 10,000.