Python Client in Jupyter¶
This guide uses the Python client in a Jupyter notebook to load a table into a pandas DataFrame and keep a DataFrame up to date from live updates.
Prerequisites¶
- A Jupyter kernel running Python 3.14.
- A client certificate the server accepts, with
client.crt.pem,client.key.pem, and the server's3forge.pubin the notebook's directory. See Connecting and Securing a Client.
1. Install and connect¶
This stage installs the package and opens the connections the later stages use.
-
Install the package from a notebook cell:
-
Connect in a new cell. The listener collects updates into the
rowsdictionary: -
Check that the cell shows
{'1': array([1], dtype=int32)}. An empty{}means the server refused the certificate.
2. Load a table into a DataFrame¶
This stage creates a small table and reads it into pandas.
-
Create a table and query it with the query builder:
-
Check that the cell shows a DataFrame with 2 rows.
3. Keep a DataFrame of live updates¶
This stage subscribes to the table and shows the merged updates as a DataFrame.
-
Subscribe, change a row, and show the collected rows:
-
Check that the DataFrame shows
IBMat999.0, indexed by row id.
Updates arrive on the client's callback thread, not in the cell, so the listener stores them and a later cell shows them. subscribe returns before every row has arrived; the pause gives them time. Run the last line again at any time to see the current state.
4. Clean up¶
This stage removes the table and closes the connections.
-
Drop the table and disconnect:
-
Check that the cell runs without output.
The bundled demos¶
The package also installs 2 demo packages, demo and failover_demo, each with the modules ami_client_demo, crypto_ticker, crypto_ticker_nb, and multiplex_crypto_ticker. They need panel, which the package does not install: without it, importing a demo fails with ModuleNotFoundError: No module named 'panel'. Install it with %pip install panel.
The demos are Panel apps, for a notebook or panel serve. As shipped, they do not run against a default install:
- They cannot use a client certificate:
create_default_multiplex_stacktakesuse_sslbut no certificate settings, so with or without TLS the connections are refused and nothing is published. - They expect 2 instances: by default, Relay ports
3289and4289, and Center ports3271and4271. crypto_tickerfails with current Panel: with Panel 1.10.0,panel servereportsTabulator.__init__() got an unexpected keyword argument 'style'.ami_client_demohas no notebook: its helpers are written forami_client_demo.ipynb, which the package does not include.
Result¶
The notebook holds a DataFrame loaded from Quotes, and a second DataFrame that stays current with live updates.