by: Kevin Broløs
(Feyn version 1.4 or newer)
The keys to the self-driving car
In order to use your QLattice, you need two key components.
You can get both of these pieces of information from the dashboard.
QLattice URL consists of two parts - our
QLattice URL, and a
It will look something like this:
On your dashboard, it can be found under
[QLattice_Name] > Details :: QLattice url.
User Access Token
User Access Token is your authentication credential for accessing the QLattice (so keep it safe). It can be found on the same dashboard page as above, under
[QLattice_Name] > Details :: User Access Token and will look something like this:
Some of you might recognize this as a JWT.
Using your credentials
In short, you can provide your credentials in three different ways:
- As parameters in the connect call.
- From a configuration file.
- From environment variables.
In the connect call
This is the simplest way. You just pass them in as the arguments
api_token to the QLattice constructor.
qlattice = QLattice(url = "https://qlattice.abzu.ai/qlattice-a1b2c3d4", api_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
Alternatively, you can store them in a local configuration file like this:
[QuesadillaLattice] url = https://qlattice.abzu.ai/qlattice-a1b2c3d4 api_token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c [QuibbleLattice] url = ... api_token = ...
The configuration file should be placed in your home folder (or in the
.config subfolder), and be called
feyn.ini if you are on Windows, otherwise
With the configuration file in place, you can connect to the QLattice by specifying which configuration section to use. Or none at all, and the first configuration section will be used.
qlattice = QLattice() # Will use the QuesadillaLattice section. qlattice = QLattice(config="QuibbleLattice") # Loads the QuibbleLattice configurations.
We recommend you use this approach, as it allows you to share code with others, without accidentially disclosing your access token.
The last way is to set two environment variables
This is often convinient for automated processes, such as continuous integration servers.
FEYN_QLATTICE_URL = https://qlattice.abzu.ai/qlattice-a1b2c3d4 FEYN_QLATTICE_API_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
With the environment variables set, you can initialize a QLattice without specifying authentication parameters.
qlattice = QLattice() # No parameters necessary when environments set