This project has been archived by its maintainers, and is no longer receiving any updates.
Glia: NEURON package manager
Glia is an asset manager for NEURON. It collects mod files from different pip packages and compiles them into a central library that is automatically loaded into NEURON. This removes the need for compiling folder after folder with cluttered, duplicated mod files and allows you to focus on using these mechanisms across multiple models.
Packaging your mod files as a Glia package allows you to distribute them as dependencies of your Python models and delegates the installation, distribution, versioning and archiving of your assets to Python's packet manager pip.
To create Glia packages, check out the CLI tool Astrocyte. Astrocyte also allows you to organize your personal mod collection!
Usage
Glia can be installed from pip:
pip install nrn-glia
Glia will check whether packages have been added, changed or removed and will recompile and load the library if necessary. This means that except for importing Glia there's not much you need to do!
from neuron import h
import glia as g
section = h.Section(name="soma")
# Load your favourite Kv1 mechanism.
g.insert(section, "Kv1")
# Note: to load the library at import time you can import glia.library instead
import glia.library
Glia avoids conflicts between authors and even variants of the same mechanism and allows you to select sensible default preferences on many levels: globally, per script, per context or per function call.
Asset management
Glia allows for multiple assets to refer to the same mechanism by giving them a unique name per package. The standard naming convention is as follows:
glia__<package-name>__<asset-name>__<variant-name>
Double underscores in packages, assets or variant names are not allowed.
This naming convention allows for multiple people to provide an
implementation of the same asset, and by using variants even one package
can provide multiple variations on the same mechanism. The default
variant is 0
If you install multiple packages that provide the same asset, or if you would like to specify another variant you will need to tell Glia which one you require. You can do so by setting your asset preferences.
Asset preferences
There are 4 different scopes for providing asset preferences:
- Global scope: Selects a default mechanism asset everywhere.
- Script scope: Selects a default mechanism asset for the remainder of the Python script.
- Context scope: Select a preferred package or variant for all
glia.insertcalls within the context block. - Single use: Selects a mechanism asset for a single
glia.insertcall
Single use
Whenever you call glia.insert you can append your preferences for that
insert:
g.insert('Kv1', pkg='not_my_models', variant='high_activity')
Context scope
Any glia.insert or glia.resolve call within the with statement will
preferably use the given package or variant:
from patch import p
s = p.Section()
with g.context(pkg='not_my_models'):
g.insert(s, 'Kv1')
g.insert(s, 'Kv1', variant='high_activity')
You can also specify a dictionary with multiple asset-specific preferences:
from patch import p
s = p.Section()
with g.context(assets={
'Kv1': {'package': 'not_my_models', 'variant': 'high_activity'},
'HCN1': {'variant': 'revised'}
}):
g.insert(s, 'Kv1')
g.insert(s, 'HCN1')
# Not affected by the context:
g.insert(s, 'Kir2.3')
And you can even combine, preferring a certain package unless the dictionary specifies otherwise:
from patch import p
s = p.Section()
with g.context(assets={
'Kv1': {'package': 'not_my_models', 'variant': 'high_activity'},
'HCN1': {'variant': 'revised'}
}, package='some_pkg_name'):
g.insert(s, 'Kv1')
g.insert(s, 'HCN1')
Finally for those of you that have really crazy preferences you can even nest contexts, where the innermost preferences take priority.
Script scope
Use glia.select to select a preferred mechanism asset, similar to the
single use syntax, for the remainder of the lifetime of the glia module:
section_global_Kv1 = h.Section()
section_local_Kv1 = h.Section()
g.insert(section_global_Kv1, 'Kv1') # Will use your global Kv1 mechanism
g.select('Kv1', pkg='not_my_models', variant='high_activity')
g.insert(section_local_Kv1, 'Kv1') # Will use the above selected Kv1 mechanism
Global scope
Applying global scope uses the Glia command-line tool and will configure glia to always select a mechanism asset as default.
Go to your favorite command-line and enter:
glia select Kv1 --pkg=some_pkg_name --variant=non_default
This will set your preference in any script you use.
Metadata
Release files for nrn-glia 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nrn_glia-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / nrn_glia-0.5.1-py3-none-any.whl
| Download URL | nrn_glia-0.5.1-py3-none-any.whl |
|---|---|
| Size | 32.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b4782b6166bcfe9aced77a060a06f4b6f688804a45c58751a42d9fb2294f3b4
|
|
BLAKE2b-256 checksum How to use checksums |
c791a76a3cae9635f6bb1e2cc4d5199e4e4553f83c83479b12a193270c0ab497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for nrn-glia 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.