Python client utilities for interacting with the Clio platform
Project description
clio-py: Python client for clio-store
Install
$ pip3 install git+https://github.com/schlegelp/clio-py@main
Token
To access Clio programmatically you need an API token. Currently, Clio tokens expire after a week. You have three options to get and set your token (in increasing order of convenience):
Option 1
Get your token from the Clio website (go to settings in the top right and copy the "ClioStore Token") and provide it whenever you instantiate a client:
>>> import clio
>>> client = clio.Client(dataset='VNC', token="eyJhb.....")
Option 2
Get your token from the Clio website and save it to disk. clio-py will
automatically use it when available and inform you when the token has expired
and you need to get a new one:
>>> import clio
>>> clio.set_token("eyJhb.....") # this is a one-off until token expires!
>>> client = clio.Client(dataset='VNC')
Option 3
Install gcloud and link it with your Google account (must be the same you use for Clio).
From now on, clio-py will use gcloud to auto-refresh your Clio token
whenever it expires.
>>> import clio
>>> client = clio.Client(dataset='VNC')
Usage
Setup
>>> import clio
>>> # You can get a list of available datasets by just invoking the client
>>> clio.Client()
...
RuntimeError: Please specify a dataset from the following list: ['CNS', 'MANC', 'VNC', 'hemibrain', 'manc:v1.0', 'medulla7column']
>>> # Initialize client with a specific dataset
>>> client = clio.Client(dataset='VNC')
Pulling annotations
>>> # Fetch annotations for given ID(s)
>>> clio.fetch_annotations([154109])
hemilineage long_tract description user soma_side ... to_review bodyid entry_nerve soma_neuromere position
0 7B 7B in T3 LHS xxxxxxxxxx@gmail.com LHS ... 154109 None T3 [17429, 21568, 21811]
>>> # Fetch annotations by a given field
>>> clio.fetch_annotations(hemilineage='07B')
avg_location birthtime bodyid ... transmission old_bodyids tosoma_position
0 18910, 35515, 55240 primary 10010 ... NaN NaN NaN
1 26128, 38807, 55528 primary 10018 ... NaN NaN NaN
2 15749, 33362, 38398 primary 10087 ... NaN NaN NaN
3 26128, 38807, 55528 primary 10090 ... NaN NaN NaN
4 NaN early secondary 10148 ... NaN NaN NaN
...
>>> # Fetch all annotations
>>> clio.fetch_annotations()
avg_location birthtime bodyid ... subclassabbr tosoma_position source
0 20293, 15901, 10843 secondary 26896 ... NaN NaN NaN
1 NaN NaN 139486 ... NaN NaN NaN
2 27443, 20049, 23897 secondary 158190 ... NaN NaN NaN
3 16884, 19674, 35784 secondary 165660 ... NaN NaN NaN
4 13227, 35591, 30152 secondary 20366 ... NaN NaN NaN
...
Please see help(clio.fetch_annotations) for further details and examples.
Pushing annotations
:warning: Clio has little in the way of guard rails when it comes to writing annotations to the database. It's easy to accidentally overwrite existing annotations. Do not use this functionality unless you know exactly what you are doing! Please check in with a a senior person/postdoc before writing to any field.
>>> # Use a {bodyid: {field: value}} dictionary to update fields
>>> clio.set_annotations({154109: {"soma_side": "LHS"}})
>>> # Alternatively, use a dataframe dictionary to update fields
>>> import pandas as pd
>>> new_ann = pd.DataFrame([[154109, "LHS", "ascending neuron"]],
... columns=["bodyid", "soma_side", "class"])
>>> new_ann.head()
bodyid soma_side class
0 154109 LHS ascending neuron
>>> clio.set_annotations(new_ann)
Please see help(clio.set_annotations) for details.
References
List of API endpoints for Clio.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clio_py-0.1.0.tar.gz.
File metadata
- Download URL: clio_py-0.1.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
523b1547104bf100a1fd232fb5b7938d5a2957a3cd9306982319bf32a14995ed
|
|
| MD5 |
c45bcd729e540993b9d6c6c349cc6754
|
|
| BLAKE2b-256 |
5df85acf3e5981ae200b3ec36babf66b57d9e48b6caaf8da884ad54fd8c21f12
|
Provenance
The following attestation bundles were made for clio_py-0.1.0.tar.gz:
Publisher:
publish.yml on schlegelp/clio-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clio_py-0.1.0.tar.gz -
Subject digest:
523b1547104bf100a1fd232fb5b7938d5a2957a3cd9306982319bf32a14995ed - Sigstore transparency entry: 2184935638
- Sigstore integration time:
-
Permalink:
schlegelp/clio-py@956f1b455ae9e0f72fc146d8fecf754a7b771e18 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/schlegelp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@956f1b455ae9e0f72fc146d8fecf754a7b771e18 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clio_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: clio_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82defef00912da1638f2de4f846652795368e49cc48f61ab5e67c8505f41c636
|
|
| MD5 |
6d4693228076e5fa3b8dabadcab80edb
|
|
| BLAKE2b-256 |
585d75b4ecb5bd83a0af462972a3eb100f10fb4b8a84b0f054e347ffbc21203a
|
Provenance
The following attestation bundles were made for clio_py-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on schlegelp/clio-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clio_py-0.1.0-py3-none-any.whl -
Subject digest:
82defef00912da1638f2de4f846652795368e49cc48f61ab5e67c8505f41c636 - Sigstore transparency entry: 2184935732
- Sigstore integration time:
-
Permalink:
schlegelp/clio-py@956f1b455ae9e0f72fc146d8fecf754a7b771e18 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/schlegelp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@956f1b455ae9e0f72fc146d8fecf754a7b771e18 -
Trigger Event:
push
-
Statement type: