Cards and Notebooks
Introduction
Every card in DataCards has a corresponding Notebook that provides its data. Our notebooks are based on Jupyter notebooks - the industry standard for data science, scripting, and modeling - with additional features specific to DataCards. Currently, we support Python kernels for these notebooks.
Inside each notebook, you have access to a Python object called datacards
. This object, known as the DataCards SDK, lets you interact with various DataCards features, such as publishing cards. Let’s explore how this works.
Output card
DataCards distinguishes between Output cards, which display data, and Input cards, which enable a user to enter and modify data. Let’s create an output card and view it’s corresponding notebook.
As before, click an empty cell in the deck to open the card store. This time, select the “Number” card (an output card).

Click on the header of the card (“Number”) to open the notebook that generated this card.

You will see a minimal example of a notebook, with one Python code cell. This cell demonstrates how to create a card using the datacards
object and its method .publish.card()
Change the value
argument to a different number and click the “Play” button in the top-right of the cell. The card will be published with your change. Click the “Close” button in the top right of the notebook and you will see the change reflected on the deck.
Input card
Now let’s add an input card. Open the card store again and an “Integer Slider”

Open the integer slider card’s notebook. You will see that it published a Variable using the datacards
object:
datacards.publish.variable("my_input_123", 42)
All input cards publish a variable, so that their value can be used in other parts of the project.
Note also that input cards take a variable_key
, which associates the card with the variable:
datacards.publish.card(
type='intSlider',
...
variable_key='my_input_123'
)
Connecting notebooks
Let’s connect the slider to the number card, so that moving the slider changes the number displayed. This demonstrates how DataCards can connect notebooks to build interactive processes.
Exit the slider card notebook and open the number card notebook. Currently, the value
argument is set to a static number (e.g. 42
). We’ll modify it to consume the variable published by the slider instead. Take care to ensure that the variable name matches exactly!
datacards.publish.card(
type='number',
- value=42,
+ value=datacards.consume.variable.my_input_123()
label='Number',
description='Description',
unit='Unit',
logic_view_size=(2,1)
)
Now click the “Run all” button in the notebook to publish the card .
Congratulations, you just connected two notebooks! Whenever the input is changed, the consuming notebook will be executed, updating the value of the number card it publishes.