PyGraphistry can be configured for tasks such as eliminating analyst boilerplate, customizing security handling, and supporting advanced server configurations.
Configuration is for two basic APIs: the upload API for how PyGraphistry sends data to a Graphistry server, and the client API for how a URL is loaded into a user's browser.
For server configuration, see main configuration docs. For REST API settings for uploading and viewing visualizations, see main developer documentation.
PyGraphistry configuration settings resolve through the following cascade, with the top items overriding the further ones:
Priority | Name | Primary Use |
---|---|---|
5 | graph.settings(url_params={...}) |
Analyst or developer fine-tuning an individual visualization's style via |
4 | graphistry.register(...) |
Analyst or developer |
3 | Environment variables | Developer or sysadmin |
2 | graphistry.config |
Sysadmin |
1 | Default |
Graphistry's built-in Jupyter server comes with a predefined graphistry.config
.
Setting | Default | Type | Description |
---|---|---|---|
api |
1 | 1 JSON 2 protobuf 3 (recommended: JWT+Arrow) |
Upload format and wire protocol |
certificate_validation |
True |
boolean | Unsafe: Disable to allow ignore TLS failures such as for known-faulty CAs |
client_protocol_hostname |
None |
FQDN, including protocol, for overriding protocol and hostname for what URL is used in browsers from displaying visualizations |
|
hostname |
"hub.graphistry.com" |
string | Domain (and optional path) for where to upload data and load visualizations |
protocol |
"https" |
"https" or "http" |
Deprecated 1.0 API option (api=1, api=2)
| Setting | Default | Type | Description
| api_key
| None
| string | deprecated |
| dataset_prefix
| "PyGraphistry/"
| string | deprecated Prefix on upload location |
Override and add query parameters to the loaded visualization iframe by adding key/value strings to url_params
. This does not control the protocol, domain, nor path, so is primarily for styling and debugging purposes.
my_graph.settings(url_params={
'play': '0',
'my_correlation_id': 'session-123'
}).plot()
Note: Setup of the environment lets developers and analysts skip manually configuring register()
, which may be preferrable
Global module settings can be defined via register()
:
register(api=3, username='...', password='...', server=None, protocol=None, api=None, certificate_validation=None, ...)
See PyGraphistry docs for individual connectors such as .bolt(...)
and .tigergraph(...)
.
import graphistry
graphistry.register(api=3, username='...', password='...', protocol='http', server='my.server.com')
g = graphistry.bolt({'server': 'bolt://...', 'auth': ('my_user', 'my_pwd')})
g.cypher("MATCH (a)-[b]->(c) RETURN a,b,c LIMIT 10").plot()
g.cypher("MATCH (a)-[b]->(c) RETURN a,b,c LIMIT 100000").plot()
...
Graphistry Setting | Environment Variable | Description |
---|---|---|
api_version |
GRAPHISTRY_API_VERSION |
|
certificate_validation |
GRAPHISTRY_CERTIFICATE_VALIDATION |
|
client_protocol_hostname |
GRAPHISTRY_CLIENT_PROTOCOL_HOSTNAME |
|
hostname |
GRAPHISTRY_HOSTNAME |
|
protocol |
GRAPHISTRY_PROTOCOL |
|
PYGRAPHISTRY_CONFIG |
Absolute path of graphistry.config |
Graphistry Setting | Environment Variable | Description |
---|---|---|
api_key |
GRAPHISTRY_API_KEY |
|
dataset_prefix |
GRAPHISTRY_DATASET_PREFIX |
There are multiple common ways to set environment variables:
- OS user login, e.g.,
.bashrc
file - In an invocation script,
MY_FLD=MY_VAL python myscript.py
- The
environment:
section of Graphistry's~/docker-compose.yml
fornotebook
or the~/.env
file. WARNING: Editing.env
is preferred over editing.yml
in order to simplify upgrading - In Python via
os.environ['MY_FLD'] = 'MY_VAL'
Specify a json
file using key/values from the Settings table.
PyGraphistry automatically checks for graphistry.config
as follows:
config_paths = [
os.path.join('/etc/graphistry', '.pygraphistry'),
os.path.join(os.path.expanduser('~'), '.pygraphistry'),
os.environ.get('PYGRAPHISTRY_CONFIG', '')
]
If you are using Graphistry's built-in Jupyter server, it autoconfigures PYGRAPHISTRY_CONFIG
and graphistry.config
. Modify docker-compose.yml
's notebook
section's volume mounts for new behavior. You can check the container's default config by running ! cat /home/graphistry/pygraphistry.config
from a notebook.
import graphistry
graphistry.register(api=3, username='..', password='...')
Create Python-readable /etc/graphistry/.pygraphistry
:
{
"api_key": "SHARED_USERS_KEY",
"protocol": "https",
"hostname":"my.server.com"
}
For Jupyter notebooks, you may want to create per-user login .pygraphistry
files. Please contact staff for further options and requests.
In scenarios like Graphistry running on a notebook server, you may prefer to send uploads to a local host (http://localhost
, http://nginx
, ...), and tell browser client viewers to use a separate, public host and subpath (http://graphistry.site.ngo/graphistry
):
import os
import graphistry
### Internal URL: PyGraphistry app -> Graphistry Server
GRAPHISTRY_HOSTNAME_PROTOCOL='https'
os.environ['GRAPHISTRY_HOSTNAME'] = "localhost"
### External URL: Webpage iframe URL -> Graphistry Server
os.environ['GRAPHISTRY_CLIENT_PROTOCOL_HOSTNAME'] = "https://graph.site.ngo/graphistry"
graphistry.register(
key='MY_API_KEY',
protocol=GRAPHISTRY_HOSTNAME_PROTOCOL
)