synapseclient 3.2.0__tar.gz → 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- synapseclient-4.0.0/PKG-INFO +387 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/README.md +6 -8
- {synapseclient-3.2.0 → synapseclient-4.0.0}/setup.cfg +10 -5
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/.synapseConfig +2 -2
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/__init__.py +2 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/__main__.py +134 -126
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/activity.py +39 -54
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/annotations.py +165 -81
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/client.py +1571 -966
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/cache.py +60 -41
- synapseclient-4.0.0/synapseclient/core/credentials/__init__.py +2 -0
- synapseclient-4.0.0/synapseclient/core/credentials/cred_data.py +102 -0
- synapseclient-4.0.0/synapseclient/core/credentials/credential_provider.py +279 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/exceptions.py +0 -14
- synapseclient-4.0.0/synapseclient/core/models/permission.py +190 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/multithread_download/download_threads.py +65 -52
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/remote_file_storage_wrappers.py +119 -55
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/retry.py +34 -21
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/sts_transfer.py +18 -11
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/upload/multipart_upload.py +105 -63
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/upload/upload_functions.py +35 -20
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/utils.py +310 -130
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/version_check.py +26 -28
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/entity.py +194 -225
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/evaluation.py +89 -83
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/synapsePythonClient +2 -2
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/table.py +499 -646
- synapseclient-4.0.0/synapseclient/team.py +108 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/wiki.py +33 -47
- synapseclient-4.0.0/synapseclient.egg-info/PKG-INFO +387 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient.egg-info/SOURCES.txt +1 -1
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient.egg-info/entry_points.txt +0 -1
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient.egg-info/requires.txt +9 -7
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseutils/__init__.py +2 -14
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseutils/copy_functions.py +224 -217
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseutils/describe_functions.py +45 -36
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseutils/migrate_functions.py +74 -67
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseutils/monitor.py +31 -28
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseutils/sync.py +429 -195
- synapseclient-4.0.0/synapseutils/walk_functions.py +114 -0
- synapseclient-3.2.0/PKG-INFO +0 -357
- synapseclient-3.2.0/synapseclient/core/credentials/__init__.py +0 -4
- synapseclient-3.2.0/synapseclient/core/credentials/cached_sessions.py +0 -34
- synapseclient-3.2.0/synapseclient/core/credentials/cred_data.py +0 -197
- synapseclient-3.2.0/synapseclient/core/credentials/credential_provider.py +0 -295
- synapseclient-3.2.0/synapseclient/team.py +0 -101
- synapseclient-3.2.0/synapseclient.egg-info/PKG-INFO +0 -357
- synapseclient-3.2.0/synapseutils/walk_functions.py +0 -82
- {synapseclient-3.2.0 → synapseclient-4.0.0}/MANIFEST.in +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/pyproject.toml +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/setup.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/__init__.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/config.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/constants/__init__.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/constants/concrete_types.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/constants/config_file_constants.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/constants/limits.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/cumulative_transfer_progress.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/dozer.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/lock.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/logging_setup.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/models/__init__.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/models/custom_json.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/models/dict_object.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/multithread_download/__init__.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/pool_provider.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/core/upload/__init__.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/services/__init__.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient/services/json_schema.py +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient.egg-info/dependency_links.txt +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient.egg-info/not-zip-safe +0 -0
- {synapseclient-3.2.0 → synapseclient-4.0.0}/synapseclient.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: synapseclient
|
|
3
|
+
Version: 4.0.0
|
|
4
|
+
Summary: A client for Synapse, a collaborative, open-source research platform that allows teams to share data, track analyses, and collaborate.
|
|
5
|
+
Home-page: https://www.synapse.org
|
|
6
|
+
Author: The Synapse Engineering Team
|
|
7
|
+
Author-email: platform@sagebase.org
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Project-URL: Source, https://github.com/Sage-Bionetworks/synapsePythonClient
|
|
10
|
+
Project-URL: Tracker, https://github.com/Sage-Bionetworks/synapsePythonClient/issues
|
|
11
|
+
Project-URL: Documentation, https://python-docs.synapse.org
|
|
12
|
+
Project-URL: Changelog, https://python-docs.synapse.org/build/html/index.html#release-notes
|
|
13
|
+
Platform: any
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Operating System :: MacOS
|
|
21
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
22
|
+
Classifier: Operating System :: Unix
|
|
23
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
24
|
+
Classifier: Intended Audience :: Developers
|
|
25
|
+
Classifier: Intended Audience :: Science/Research
|
|
26
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
30
|
+
Requires-Python: >=3.8
|
|
31
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
32
|
+
Requires-Dist: requests<3.0,>=2.22.0
|
|
33
|
+
Requires-Dist: urllib3<2,>=1.26.18
|
|
34
|
+
Requires-Dist: deprecated<2.0,>=1.2.4
|
|
35
|
+
Requires-Dist: opentelemetry-api~=1.21.0
|
|
36
|
+
Requires-Dist: opentelemetry-sdk~=1.21.0
|
|
37
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http~=1.21.0
|
|
38
|
+
Provides-Extra: dev
|
|
39
|
+
Requires-Dist: pytest<7.0,>=6.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: pytest-mock<4.0,>=3.0; extra == "dev"
|
|
41
|
+
Requires-Dist: flake8<4.0,>=3.7.0; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-xdist[psutil]<3.0.0,>=2.2; extra == "dev"
|
|
43
|
+
Requires-Dist: pytest-rerunfailures~=12.0; extra == "dev"
|
|
44
|
+
Requires-Dist: func-timeout~=4.3; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-cov~=4.1.0; extra == "dev"
|
|
46
|
+
Requires-Dist: black; extra == "dev"
|
|
47
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
48
|
+
Provides-Extra: tests
|
|
49
|
+
Requires-Dist: pytest<7.0,>=6.0.0; extra == "tests"
|
|
50
|
+
Requires-Dist: pytest-mock<4.0,>=3.0; extra == "tests"
|
|
51
|
+
Requires-Dist: flake8<4.0,>=3.7.0; extra == "tests"
|
|
52
|
+
Requires-Dist: pytest-xdist[psutil]<3.0.0,>=2.2; extra == "tests"
|
|
53
|
+
Requires-Dist: pytest-rerunfailures~=12.0; extra == "tests"
|
|
54
|
+
Requires-Dist: func-timeout~=4.3; extra == "tests"
|
|
55
|
+
Requires-Dist: pytest-cov~=4.1.0; extra == "tests"
|
|
56
|
+
Provides-Extra: pandas
|
|
57
|
+
Requires-Dist: pandas<2.1,>=1.5; extra == "pandas"
|
|
58
|
+
Provides-Extra: pysftp
|
|
59
|
+
Requires-Dist: pysftp<0.3,>=0.2.8; extra == "pysftp"
|
|
60
|
+
Provides-Extra: boto3
|
|
61
|
+
Requires-Dist: boto3<2.0,>=1.7.0; extra == "boto3"
|
|
62
|
+
Provides-Extra: docs
|
|
63
|
+
Requires-Dist: mkdocs>=1.5.3; extra == "docs"
|
|
64
|
+
Requires-Dist: mkdocs-material>=9.4.14; extra == "docs"
|
|
65
|
+
Requires-Dist: mkdocstrings>=0.24.0; extra == "docs"
|
|
66
|
+
Requires-Dist: mkdocstrings-python>=1.7.5; extra == "docs"
|
|
67
|
+
Requires-Dist: termynal>=0.11.1; extra == "docs"
|
|
68
|
+
Requires-Dist: mkdocs-open-in-new-tab~=1.0.3; extra == "docs"
|
|
69
|
+
Requires-Dist: markdown-include~=0.8.1; extra == "docs"
|
|
70
|
+
|
|
71
|
+
Python Synapse Client
|
|
72
|
+
=====================
|
|
73
|
+
|
|
74
|
+
Branch | Build Status
|
|
75
|
+
--------|-------------
|
|
76
|
+
develop | [](https://github.com/Sage-Bionetworks/synapsePythonClient/actions?query=branch%3Adevelop)
|
|
77
|
+
master | [](https://github.com/Sage-Bionetworks/synapsePythonClient/actions?query=branch%3Amaster)
|
|
78
|
+
|
|
79
|
+
[](https://pypi.python.org/pypi/synapseclient/) [](https://pypi.python.org/pypi/synapseclient/)
|
|
80
|
+
|
|
81
|
+
A Python client for [Sage Bionetworks'](https://www.sagebase.org) [Synapse](https://www.synapse.org/), a collaborative, open-source research platform that allows teams to share data, track analyses, and collaborate. The Python client can be used as a library for development of software that communicates with Synapse or as a command-line utility.
|
|
82
|
+
|
|
83
|
+
There is also a [Synapse client for R](https://github.com/Sage-Bionetworks/synapser/).
|
|
84
|
+
|
|
85
|
+
Documentation
|
|
86
|
+
-------------
|
|
87
|
+
|
|
88
|
+
For more information about the Python client, see:
|
|
89
|
+
|
|
90
|
+
* [Python client API docs](https://python-docs.synapse.org)
|
|
91
|
+
|
|
92
|
+
For more information about interacting with Synapse, see:
|
|
93
|
+
|
|
94
|
+
* [Synapse API docs](https://rest-docs.synapse.org/rest/)
|
|
95
|
+
* [User cases](https://help.synapse.org/docs/Use-Cases.1985151645.html)
|
|
96
|
+
* [Getting Started Guide to Synapse](https://help.synapse.org/docs/Getting-Started.2055471150.html)
|
|
97
|
+
|
|
98
|
+
For release information, see:
|
|
99
|
+
|
|
100
|
+
* [Release notes](https://python-docs.synapse.org/news/)
|
|
101
|
+
|
|
102
|
+
<!-- Subscribe to release and other announcements [here](https://groups.google.com/a/sagebase.org/forum/#!forum/python-announce)
|
|
103
|
+
or by sending an email to [python-announce+subscribe@sagebase.org](mailto:python-announce+subscribe@sagebase.org) -->
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
Installation
|
|
107
|
+
------------
|
|
108
|
+
|
|
109
|
+
The Python Synapse client has been tested on 3.8, 3.9, 3.10 and 3.11 on Mac OS X, Ubuntu Linux and Windows.
|
|
110
|
+
|
|
111
|
+
**Starting from Synapse Python client version 3.0, Synapse Python client requires Python >= 3.8**
|
|
112
|
+
|
|
113
|
+
### Install using pip
|
|
114
|
+
|
|
115
|
+
The [Python Synapse Client is on PyPI](https://pypi.python.org/pypi/synapseclient) and can be installed with pip:
|
|
116
|
+
|
|
117
|
+
(sudo) pip install synapseclient[pandas,pysftp]
|
|
118
|
+
|
|
119
|
+
...or to upgrade an existing installation of the Synapse client:
|
|
120
|
+
|
|
121
|
+
(sudo) pip install --upgrade synapseclient
|
|
122
|
+
|
|
123
|
+
The dependencies on `pandas` and `pysftp` are optional. Synapse [Tables](https://python-docs.synapse.org/reference/tables/) integrate
|
|
124
|
+
with [Pandas](http://pandas.pydata.org/). The library `pysftp` is required for users of
|
|
125
|
+
[SFTP](https://python-docs.synapse.org/guides/data_storage/#sftp) file storage. Both libraries require native code
|
|
126
|
+
to be compiled or installed separately from prebuilt binaries.
|
|
127
|
+
|
|
128
|
+
### Install from source
|
|
129
|
+
|
|
130
|
+
Clone the [source code repository](https://github.com/Sage-Bionetworks/synapsePythonClient).
|
|
131
|
+
|
|
132
|
+
git clone git://github.com/Sage-Bionetworks/synapsePythonClient.git
|
|
133
|
+
cd synapsePythonClient
|
|
134
|
+
pip install .
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
Command line usage
|
|
138
|
+
------------------
|
|
139
|
+
|
|
140
|
+
The Synapse client can be used from the shell command prompt. Valid commands
|
|
141
|
+
include: query, get, cat, add, update, delete, and onweb. A few examples are
|
|
142
|
+
shown.
|
|
143
|
+
|
|
144
|
+
### downloading test data from Synapse
|
|
145
|
+
|
|
146
|
+
synapse -p auth_token get syn1528299
|
|
147
|
+
|
|
148
|
+
### getting help
|
|
149
|
+
|
|
150
|
+
synapse -h
|
|
151
|
+
|
|
152
|
+
Note that a [Synapse account](https://www.synapse.org/#RegisterAccount:0) is required.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
Usage as a library
|
|
156
|
+
------------------
|
|
157
|
+
|
|
158
|
+
The Synapse client can be used to write software that interacts with the Sage Bionetworks Synapse repository. More examples can be found in the Tutorial section found [here](https://python-docs.synapse.org/tutorials/home/)
|
|
159
|
+
|
|
160
|
+
### Examples
|
|
161
|
+
|
|
162
|
+
#### Log-in and create a Synapse object
|
|
163
|
+
```
|
|
164
|
+
import synapseclient
|
|
165
|
+
|
|
166
|
+
syn = synapseclient.Synapse()
|
|
167
|
+
|
|
168
|
+
## log in using auth token
|
|
169
|
+
syn.login(authToken='auth_token')
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Sync a local directory to synapse
|
|
173
|
+
This is the recommended way of synchronizing more than one file or directory to a synapse project through the use of `synapseutils`. Using this library allows us to handle scheduling everything required to sync an entire directory tree. Read more about the manifest file format in [`synapseutils.syncToSynapse`](https://python-docs.synapse.org/reference/synapse_utils/#synapseutils.sync.syncToSynapse)
|
|
174
|
+
```
|
|
175
|
+
import synapseclient
|
|
176
|
+
import synapseutils
|
|
177
|
+
import os
|
|
178
|
+
|
|
179
|
+
syn = synapseclient.Synapse()
|
|
180
|
+
|
|
181
|
+
## log in using auth token
|
|
182
|
+
syn.login(authToken='auth_token')
|
|
183
|
+
|
|
184
|
+
path = os.path.expanduser("~/synapse_project")
|
|
185
|
+
manifest_path = f"{path}/my_project_manifest.tsv"
|
|
186
|
+
project_id = "syn1234"
|
|
187
|
+
|
|
188
|
+
# Create the manifest file on disk
|
|
189
|
+
with open(manifest_path, "w", encoding="utf-8") as f:
|
|
190
|
+
pass
|
|
191
|
+
|
|
192
|
+
# Walk the specified directory tree and create a TSV manifest file
|
|
193
|
+
synapseutils.generate_sync_manifest(
|
|
194
|
+
syn,
|
|
195
|
+
directory_path=path,
|
|
196
|
+
parent_id=project_id,
|
|
197
|
+
manifest_path=manifest_path,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
# Using the generated manifest file, sync the files to Synapse
|
|
201
|
+
synapseutils.syncToSynapse(
|
|
202
|
+
syn,
|
|
203
|
+
manifestFile=manifest_path,
|
|
204
|
+
sendMessages=False,
|
|
205
|
+
)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
#### Store a Project to Synapse
|
|
209
|
+
```
|
|
210
|
+
import synapseclient
|
|
211
|
+
from synapseclient.entity import Project
|
|
212
|
+
|
|
213
|
+
syn = synapseclient.Synapse()
|
|
214
|
+
|
|
215
|
+
## log in using auth token
|
|
216
|
+
syn.login(authToken='auth_token')
|
|
217
|
+
|
|
218
|
+
project = Project('My uniquely named project')
|
|
219
|
+
project = syn.store(project)
|
|
220
|
+
|
|
221
|
+
print(project.id)
|
|
222
|
+
print(project)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### Store a Folder to Synapse (Does not upload files within the folder)
|
|
226
|
+
```
|
|
227
|
+
import synapseclient
|
|
228
|
+
|
|
229
|
+
syn = synapseclient.Synapse()
|
|
230
|
+
|
|
231
|
+
## log in using auth token
|
|
232
|
+
syn.login(authToken='auth_token')
|
|
233
|
+
|
|
234
|
+
folder = Folder(name='my_folder', parent="syn123")
|
|
235
|
+
folder = syn.store(folder)
|
|
236
|
+
|
|
237
|
+
print(folder.id)
|
|
238
|
+
print(folder)
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
#### Store a File to Synapse
|
|
243
|
+
```
|
|
244
|
+
import synapseclient
|
|
245
|
+
|
|
246
|
+
syn = synapseclient.Synapse()
|
|
247
|
+
|
|
248
|
+
## log in using auth token
|
|
249
|
+
syn.login(authToken='auth_token')
|
|
250
|
+
|
|
251
|
+
file = File(
|
|
252
|
+
path=filepath,
|
|
253
|
+
parent="syn123",
|
|
254
|
+
)
|
|
255
|
+
file = syn.store(file)
|
|
256
|
+
|
|
257
|
+
print(file.id)
|
|
258
|
+
print(file)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### Get a data matrix
|
|
262
|
+
```
|
|
263
|
+
import synapseclient
|
|
264
|
+
|
|
265
|
+
syn = synapseclient.Synapse()
|
|
266
|
+
|
|
267
|
+
## log in using auth token
|
|
268
|
+
syn.login(authToken='auth_token')
|
|
269
|
+
|
|
270
|
+
## retrieve a 100 by 4 matrix
|
|
271
|
+
matrix = syn.get('syn1901033')
|
|
272
|
+
|
|
273
|
+
## inspect its properties
|
|
274
|
+
print(matrix.name)
|
|
275
|
+
print(matrix.description)
|
|
276
|
+
print(matrix.path)
|
|
277
|
+
|
|
278
|
+
## load the data matrix into a dictionary with an entry for each column
|
|
279
|
+
with open(matrix.path, 'r') as f:
|
|
280
|
+
labels = f.readline().strip().split('\t')
|
|
281
|
+
data = {label: [] for label in labels}
|
|
282
|
+
for line in f:
|
|
283
|
+
values = [float(x) for x in line.strip().split('\t')]
|
|
284
|
+
for i in range(len(labels)):
|
|
285
|
+
data[labels[i]].append(values[i])
|
|
286
|
+
|
|
287
|
+
## load the data matrix into a numpy array
|
|
288
|
+
import numpy as np
|
|
289
|
+
np.loadtxt(fname=matrix.path, skiprows=1)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
Authentication
|
|
294
|
+
--------------
|
|
295
|
+
Authentication toward [Synapse](https://www.synapse.org/#RegisterAccount:0) can be accomplished with the clients using personal access tokens. Learn more about [Synapse personal access tokens](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens)
|
|
296
|
+
|
|
297
|
+
Learn about the [multiple ways one can login to Synapse](https://python-docs.synapse.org/tutorials/authentication/).
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
Synapse Utilities (synapseutils)
|
|
301
|
+
--------------------------------
|
|
302
|
+
|
|
303
|
+
The purpose of synapseutils is to create a space filled with convenience functions that includes traversing through large projects, copying entities, recursively downloading files and many more.
|
|
304
|
+
|
|
305
|
+
### Example
|
|
306
|
+
|
|
307
|
+
import synapseutils
|
|
308
|
+
import synapseclient
|
|
309
|
+
syn = synapseclient.login()
|
|
310
|
+
|
|
311
|
+
# copies all Synapse entities to a destination location
|
|
312
|
+
synapseutils.copy(syn, "syn1234", destinationId = "syn2345")
|
|
313
|
+
|
|
314
|
+
# copies the wiki from the entity to a destination entity. Only a project can have sub wiki pages.
|
|
315
|
+
synapseutils.copyWiki(syn, "syn1234", destinationId = "syn2345")
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
# Traverses through Synapse directories, behaves exactly like os.walk()
|
|
319
|
+
walkedPath = synapseutils.walk(syn, "syn1234")
|
|
320
|
+
|
|
321
|
+
for dirpath, dirname, filename in walkedPath:
|
|
322
|
+
print(dirpath)
|
|
323
|
+
print(dirname)
|
|
324
|
+
print(filename)
|
|
325
|
+
|
|
326
|
+
OpenTelemetry (OTEL)
|
|
327
|
+
--------------------------------
|
|
328
|
+
[OpenTelemetry](https://opentelemetry.io/) helps support the analysis of traces and spans which can provide insights into latency, errors, and other performance metrics. The synapseclient is ready to provide traces should you want them. The Synapse Python client supports OTLP Exports and can be configured via environment variables as defined [here](https://opentelemetry-python.readthedocs.io/en/stable/exporter/otlp/otlp.html).
|
|
329
|
+
|
|
330
|
+
Read more about OpenTelemetry in Python [here](https://opentelemetry.io/docs/instrumentation/python/)
|
|
331
|
+
|
|
332
|
+
### Quick-start
|
|
333
|
+
The following shows an example of setting up [jaegertracing](https://www.jaegertracing.io/docs/1.50/deployment/#all-in-one) via docker and executing a simple python script that implements the Synapse Python client.
|
|
334
|
+
|
|
335
|
+
#### Running the jaeger docker container
|
|
336
|
+
Start a docker container with the following options:
|
|
337
|
+
```
|
|
338
|
+
docker run --name jaeger \
|
|
339
|
+
-e COLLECTOR_OTLP_ENABLED=true \
|
|
340
|
+
-p 16686:16686 \
|
|
341
|
+
-p 4318:4318 \
|
|
342
|
+
jaegertracing/all-in-one:latest
|
|
343
|
+
```
|
|
344
|
+
Explanation of ports:
|
|
345
|
+
* `4318` HTTP
|
|
346
|
+
* `16686` Jaeger UI
|
|
347
|
+
|
|
348
|
+
Once the docker container is running you can access the Jaeger UI via: `http://localhost:16686`
|
|
349
|
+
|
|
350
|
+
#### Example
|
|
351
|
+
By default the OTEL exporter sends trace data to `http://localhost:4318/v1/traces`, however you may override this by setting the `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` environment variable.
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
import synapseclient
|
|
355
|
+
from opentelemetry import trace
|
|
356
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
357
|
+
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
|
358
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
|
|
359
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
360
|
+
|
|
361
|
+
trace.set_tracer_provider(
|
|
362
|
+
TracerProvider(
|
|
363
|
+
resource=Resource(attributes={SERVICE_NAME: "my_own_code_above_synapse_client"})
|
|
364
|
+
)
|
|
365
|
+
)
|
|
366
|
+
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
|
|
367
|
+
tracer = trace.get_tracer("my_tracer")
|
|
368
|
+
|
|
369
|
+
@tracer.start_as_current_span("my_span_name")
|
|
370
|
+
def main():
|
|
371
|
+
syn = synapseclient.Synapse()
|
|
372
|
+
syn.login()
|
|
373
|
+
my_entity = syn.get("syn52569429")
|
|
374
|
+
print(my_entity)
|
|
375
|
+
|
|
376
|
+
main()
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
License and Copyright
|
|
383
|
+
---------------------
|
|
384
|
+
|
|
385
|
+
© Copyright 2013-23 Sage Bionetworks
|
|
386
|
+
|
|
387
|
+
This software is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
|
@@ -27,7 +27,7 @@ For more information about interacting with Synapse, see:
|
|
|
27
27
|
|
|
28
28
|
For release information, see:
|
|
29
29
|
|
|
30
|
-
* [Release notes](https://python-docs.synapse.org/
|
|
30
|
+
* [Release notes](https://python-docs.synapse.org/news/)
|
|
31
31
|
|
|
32
32
|
<!-- Subscribe to release and other announcements [here](https://groups.google.com/a/sagebase.org/forum/#!forum/python-announce)
|
|
33
33
|
or by sending an email to [python-announce+subscribe@sagebase.org](mailto:python-announce+subscribe@sagebase.org) -->
|
|
@@ -50,9 +50,9 @@ The [Python Synapse Client is on PyPI](https://pypi.python.org/pypi/synapseclien
|
|
|
50
50
|
|
|
51
51
|
(sudo) pip install --upgrade synapseclient
|
|
52
52
|
|
|
53
|
-
The dependencies on `pandas` and `pysftp` are optional. Synapse [Tables](
|
|
53
|
+
The dependencies on `pandas` and `pysftp` are optional. Synapse [Tables](https://python-docs.synapse.org/reference/tables/) integrate
|
|
54
54
|
with [Pandas](http://pandas.pydata.org/). The library `pysftp` is required for users of
|
|
55
|
-
[SFTP](
|
|
55
|
+
[SFTP](https://python-docs.synapse.org/guides/data_storage/#sftp) file storage. Both libraries require native code
|
|
56
56
|
to be compiled or installed separately from prebuilt binaries.
|
|
57
57
|
|
|
58
58
|
### Install from source
|
|
@@ -85,7 +85,7 @@ Note that a [Synapse account](https://www.synapse.org/#RegisterAccount:0) is req
|
|
|
85
85
|
Usage as a library
|
|
86
86
|
------------------
|
|
87
87
|
|
|
88
|
-
The Synapse client can be used to write software that interacts with the Sage Bionetworks Synapse repository. More examples can be found in the Tutorial section found [here](https://python-docs.synapse.org/
|
|
88
|
+
The Synapse client can be used to write software that interacts with the Sage Bionetworks Synapse repository. More examples can be found in the Tutorial section found [here](https://python-docs.synapse.org/tutorials/home/)
|
|
89
89
|
|
|
90
90
|
### Examples
|
|
91
91
|
|
|
@@ -100,7 +100,7 @@ syn.login(authToken='auth_token')
|
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
#### Sync a local directory to synapse
|
|
103
|
-
This is the recommended way of synchronizing more than one file or directory to a synapse project through the use of `synapseutils`. Using this library allows us to handle scheduling everything required to sync an entire directory tree. Read more about the manifest file format in [`synapseutils.syncToSynapse`](https://python-docs.synapse.org/
|
|
103
|
+
This is the recommended way of synchronizing more than one file or directory to a synapse project through the use of `synapseutils`. Using this library allows us to handle scheduling everything required to sync an entire directory tree. Read more about the manifest file format in [`synapseutils.syncToSynapse`](https://python-docs.synapse.org/reference/synapse_utils/#synapseutils.sync.syncToSynapse)
|
|
104
104
|
```
|
|
105
105
|
import synapseclient
|
|
106
106
|
import synapseutils
|
|
@@ -224,9 +224,7 @@ Authentication
|
|
|
224
224
|
--------------
|
|
225
225
|
Authentication toward [Synapse](https://www.synapse.org/#RegisterAccount:0) can be accomplished with the clients using personal access tokens. Learn more about [Synapse personal access tokens](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens)
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
Learn about the multiple ways one can login to Synapse [here](https://python-docs.synapse.org/build/html/getting_started/credentials.html).
|
|
227
|
+
Learn about the [multiple ways one can login to Synapse](https://python-docs.synapse.org/tutorials/authentication/).
|
|
230
228
|
|
|
231
229
|
|
|
232
230
|
Synapse Utilities (synapseutils)
|
|
@@ -40,8 +40,6 @@ python_requires = >=3.8
|
|
|
40
40
|
install_requires =
|
|
41
41
|
requests>=2.22.0,<3.0
|
|
42
42
|
urllib3>=1.26.18,<2
|
|
43
|
-
keyring>=15,<23.5
|
|
44
|
-
keyrings.alt==3.1; sys_platform == "linux"
|
|
45
43
|
deprecated>=1.2.4,<2.0
|
|
46
44
|
opentelemetry-api~=1.21.0
|
|
47
45
|
opentelemetry-sdk~=1.21.0
|
|
@@ -53,6 +51,7 @@ tests_require =
|
|
|
53
51
|
pytest-xdist[psutil]>=2.2,<3.0.0
|
|
54
52
|
pytest-rerunfailures~=12.0
|
|
55
53
|
func-timeout~=4.3
|
|
54
|
+
pytest-cov~=4.1.0
|
|
56
55
|
|
|
57
56
|
[options.extras_require]
|
|
58
57
|
dev =
|
|
@@ -62,6 +61,7 @@ dev =
|
|
|
62
61
|
pytest-xdist[psutil]>=2.2,<3.0.0
|
|
63
62
|
pytest-rerunfailures~=12.0
|
|
64
63
|
func-timeout~=4.3
|
|
64
|
+
pytest-cov~=4.1.0
|
|
65
65
|
black
|
|
66
66
|
pre-commit
|
|
67
67
|
tests =
|
|
@@ -71,6 +71,7 @@ tests =
|
|
|
71
71
|
pytest-xdist[psutil]>=2.2,<3.0.0
|
|
72
72
|
pytest-rerunfailures~=12.0
|
|
73
73
|
func-timeout~=4.3
|
|
74
|
+
pytest-cov~=4.1.0
|
|
74
75
|
pandas =
|
|
75
76
|
pandas>=1.5,<2.1
|
|
76
77
|
pysftp =
|
|
@@ -78,9 +79,13 @@ pysftp =
|
|
|
78
79
|
boto3 =
|
|
79
80
|
boto3>=1.7.0,<2.0
|
|
80
81
|
docs =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
mkdocs>=1.5.3
|
|
83
|
+
mkdocs-material>=9.4.14
|
|
84
|
+
mkdocstrings>=0.24.0
|
|
85
|
+
mkdocstrings-python>=1.7.5
|
|
86
|
+
termynal>=0.11.1
|
|
87
|
+
mkdocs-open-in-new-tab~=1.0.3
|
|
88
|
+
markdown-include~=0.8.1
|
|
84
89
|
|
|
85
90
|
[options.entry_points]
|
|
86
91
|
console_scripts =
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
# Login Credentials #
|
|
3
3
|
###########################
|
|
4
4
|
|
|
5
|
-
## Used for logging in to Synapse
|
|
6
|
-
##
|
|
5
|
+
## Used for logging in to Synapse. See https://python-docs.synapse.org/tutorials/authentication/
|
|
6
|
+
## for information on retrieving an auth token.
|
|
7
7
|
#[authentication]
|
|
8
8
|
#username = <username>
|
|
9
9
|
#authtoken = <authtoken>
|
|
@@ -29,6 +29,7 @@ from .table import (
|
|
|
29
29
|
)
|
|
30
30
|
from .team import Team, UserProfile, UserGroupHeader, TeamMember
|
|
31
31
|
from .wiki import Wiki
|
|
32
|
+
from .core.models.permission import Permissions
|
|
32
33
|
|
|
33
34
|
# ref = importlib.resources.files(__name__).joinpath("synapsePythonClient")
|
|
34
35
|
# with ref.open("r") as fp:
|
|
@@ -66,6 +67,7 @@ __all__ = [
|
|
|
66
67
|
"SubmissionViewSchema",
|
|
67
68
|
"MaterializedViewSchema",
|
|
68
69
|
"Dataset",
|
|
70
|
+
"Permissions",
|
|
69
71
|
# functions
|
|
70
72
|
"login",
|
|
71
73
|
"build_table",
|