synapsis
Synapse integration utilities with asyncio support.
Provides helper methods for common Synapse operations and seamless asyncio integration for all methods.
Installation
pip install synapsis
Usage
Configure authentication and the synapseclient:
from synapsis import Synapsis
# No configuration is necessary if using environment variables or the default synapse config file.
# For user/pass, set:
# SYNAPSE_USERNAME=
# SYNAPSE_PASSWORD=
# For auth token, set:
# SYNAPSE_AUTH_TOKEN=
# For Synapse Config file, have a valid config file in:
# ~/.synapseConfig
# Or, have the environment variable set:
# SYNAPSE_CONFIG_FILE=
# Configure for user/pass:
Synapsis.configure(email='', password='')
# Configure for auth token:
Synapsis.configure(auth_token='')
# Configure for non-default Synapse Config file:
Synapsis.configure(synapse_args={'configPath': '~/.synapseConfigAdmin'})
# Configure the Synapse client:
Synapsis.configure(synapse_args={'cache_root_dir': '/tmp/synapse', 'silent': False})
# Force the synapseclient to be multi-threaded:
Synapsis.configure(synapse_args={'multi_threaded': True})
Inject authentication params into argparse.
import argparse
from synapsis import cli as synapsis_cli
def main():
parser = argparse.ArgumentParser(...)
synapsis_cli.inject(parser)
args = parser.parse_args
synapsis_cli.configure(args)
# or with logging in.
synapsis_cli.configure(args, login=True)
This will inject the following args.
options:
-u USERNAME, --username USERNAME
Synapse username.
-p PASSWORD, --password PASSWORD
Synapse password.
--auth-token AUTH_TOKEN
Synapse auth token.
--synapse-config SYNAPSE_CONFIG
Path to Synapse configuration file.
Login to Synapse
from synapsis import Synapsis
Synapsis.login()
Method Chaining and Piping
Synchronous: Synapsis.Chain.<your-method-chain>.Result()
Asynchronous: await Synapsis.Chain.<your-method-chain>
Examples:
from synapsis import Synapsis
# Chaining
filehandle = Synapsis.Chain.get('syn123').get('_file_handle', None).Result()
# or
filehandle = await Synapsis.Chain.get('syn123').get('_file_handle', None)
# Piping
filehandle = Synapsis.Chain.get('syn123').Pipe.Utils.get_filehandle().Result()
# or
filehandle = await Synapsis.Chain.get('syn123').Pipe.Utils.get_filehandle()
Calling a Synapsis, Synapsis.Utils, synapseclient, or synapseutils method
A method called directly on Synapsis will resolve in the following order.
SynapsisSynapsis.Synapse
Utils and SynapseUtils need to be called directly.
Synapsis.UtilsSynapsis.SynapseUtils
NOTE: For Synapsis.SynapseUtils (synapseutils) you do not have to call the method with the syn arg, it will be set
to the current Synapsis.Synapse instance automatically.
Calling an Asynchronous Method
Start by calling Synapsis.Chain then the rest of the method chain.
from synapsis import Synapsis
async def my_async_method():
# Any resolvable method on `Synapsis` can be called asynchronously.
await Synapsis.Chain.configure(...)
await Synapsis.Chain.login()
entity = await Synapsis.Chain.Synapse.get(...)
# or
entity = await Synapsis.Chain.get(...)
copy = await Synapsis.Chain.SynapseUtils.copy(...)
entity = await Synapsis.Chain.Utils.find_entity(...)
Calling a Synchronous Method
Call the method directly on Synapsis.
from synapsis import Synapsis
def my_sync_method():
Synapsis.configure(...)
Synapsis.login()
entity = Synapsis.Synapse.get(...)
# or
entity = Synapsis.get(...)
copy = Synapsis.SynapseUtils.copy(...)
entity = Synapsis.Utils.find_entity(...)
Development Setup
git clone https://github.com/ki-tools/synapsis-py.git
cd synapsis-py
pipenv --python 3.10
pipenv shell
make pip_install
Run tests:
- Rename
.env.templateto.envand set the variables in the file. - Run
make testortox
Metadata
Release files for synapsis 0.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| synapsis-0.0.9.tar.gz | 20.8 kB | Without provenance | Details for synapsis-0.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| synapsis-0.0.9-py3-none-any.whl | Python 3 | none | any | Details for synapsis-0.0.9-py3-none-any.whl |
Total release size: 49.3 kB
Release files / synapsis-0.0.9.tar.gz
| Download URL | synapsis-0.0.9.tar.gz |
|---|---|
| Size | 20.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff5a7a7657283535ddd9723ffbc0834464a7eec7c683979de2034bcb69486de2
|
|
BLAKE2b-256 checksum How to use checksums |
5d751568548f5dd3f2e23d397800e1eb8ee5ed481d3eb558ec0afe12dd762f9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / synapsis-0.0.9-py3-none-any.whl
| Download URL | synapsis-0.0.9-py3-none-any.whl |
|---|---|
| Size | 28.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb7559fac005dd8d47fc52b06ba12030a9aa42ae826f608eee944dbdb53d1bf5
|
|
BLAKE2b-256 checksum How to use checksums |
79698442d9f8737eaca946bfc3b25c176f5e091503b5cb3d7b25d192b6a7220f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for synapsis 0.0.9
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.