Peliqan pip module
A Python module to connect to a Peliqan environment from a Python script running anywhere outside of the Peliqan environment. This module is a wrapper for the public Peliqan REST APIs.Install
Upgrade to latest version
Usage
Peliqan class arguments
The**Peliqan** class takes two arguments:
- jwt (required): This is the JWT token used to authenticate requests from the client to the server. In Peliqan, see Admin > Security settings > API token.
- backend_url (optional): This is the
instance_urlthat points to a specific Peliqan environment. If no value is provided, the client will look for thePELIQAN_URLenvironment variable. If it is not set, then the value defaults to https://app.eu.peliqan.io/.
Environment variables (optional)
- PELIQAN_URL: If this variable is set, it is not needed to set the
backend_urlparameter while instantiating the client.
Useful Links
See here to learn more about building data apps.Streamlit apps
If you want to run interactive Streamlit apps locally, install Streamlit first:Bundler
Data apps in Peliqan are single file Python scripts. You can use the Peliqan bundler to combine a multi-file Python script (e.g. a multi-file Streamlit app) into a single file that can be deployed to Peliqan.Note that the single file script must be tested. In some cases, changes to the source code are required to make the code compatible with the bundler.
python bundler.py test-project/main.py
Creating data apps that can run both locally and inside of Peliqan
Inside Peliqan, the Peliqan module is automatically imported aspq and Streamlit is automatically imported as st. The constant RUN_CONTEXT is always set, e.g. with value “interactive” when the data app runs in interactive mode and “scheduled” or “background” otherwise.
Click here for more info on run modes (RUN_CONTEXT).
Example Data App that can run both on Peliqan and outside of Peliqan (e.g. locally on your computer):
- Background mode:
python script.py - Interactive mode (Streamlit):
streamlit run script.py.
Share state between a local Data App and a Data App on Peliqan
Example code to share state with an app on Peliqan:Note: when running a Data App outside of Peliqan, by default
pq.get_state() and pq.set_state(state)will read and write the state locally in a temporary file. The above code however, shares the state with a Data App running on Peliqan. Make sure that PELIQAN_INTERFACE_ID is set as a local environment variable, with the id of the Data App on Peliqan.