Synapse integration utilities with asyncio support.
Project description
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
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 synapsis-0.0.9.tar.gz.
File metadata
- Download URL: synapsis-0.0.9.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff5a7a7657283535ddd9723ffbc0834464a7eec7c683979de2034bcb69486de2
|
|
| MD5 |
1983e44741e438f39085b18b2247d71e
|
|
| BLAKE2b-256 |
5d751568548f5dd3f2e23d397800e1eb8ee5ed481d3eb558ec0afe12dd762f9b
|
File details
Details for the file synapsis-0.0.9-py3-none-any.whl.
File metadata
- Download URL: synapsis-0.0.9-py3-none-any.whl
- Upload date:
- Size: 28.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb7559fac005dd8d47fc52b06ba12030a9aa42ae826f608eee944dbdb53d1bf5
|
|
| MD5 |
1fbbdca1a28a3353bc108516e8904ed2
|
|
| BLAKE2b-256 |
79698442d9f8737eaca946bfc3b25c176f5e091503b5cb3d7b25d192b6a7220f
|