Skip to content

Commit e2e3004

Browse files
committed
improved deprecation
1 parent 4e2ed0b commit e2e3004

1 file changed

Lines changed: 84 additions & 6 deletions

File tree

synapseutils/sync.py

Lines changed: 84 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,11 +1133,6 @@ def syncToSynapse(
11331133
) -> None:
11341134
"""Synchronizes files specified in the manifest file to Synapse.
11351135
1136-
.. deprecated:: 4.13.0
1137-
Use :meth:`synapseclient.models.Project.sync_to_synapse` or
1138-
:meth:`synapseclient.models.Folder.sync_to_synapse` instead.
1139-
This function will be removed in v5.0.0.
1140-
11411136
Given a file describing all of the uploads, this uploads the content to Synapse and
11421137
optionally notifies you via Synapse messagging (email) at specific intervals, on
11431138
errors and on completion.
@@ -1177,6 +1172,21 @@ def syncToSynapse(
11771172
11781173
Returns:
11791174
None
1175+
1176+
Example: Migration to new method
1177+
 
1178+
1179+
```python
1180+
# Old approach (DEPRECATED)
1181+
# import synapseutils
1182+
# synapseutils.syncToSynapse(syn, manifestFile="path/to/manifest.tsv")
1183+
1184+
# New approach (RECOMMENDED)
1185+
from synapseclient.models import Project
1186+
1187+
project = Project(id="syn1234")
1188+
project.sync_to_synapse(manifest_path="path/to/manifest.csv")
1189+
```
11801190
"""
11811191
wrap_async_to_sync(
11821192
coroutine=syncToSynapse_async(
@@ -1191,6 +1201,13 @@ def syncToSynapse(
11911201
)
11921202

11931203

1204+
@deprecated(
1205+
version="4.13.0",
1206+
reason=(
1207+
"To be removed in 5.0.0. Use Project.sync_to_synapse_async or "
1208+
"Folder.sync_to_synapse_async from synapseclient.models instead."
1209+
),
1210+
)
11941211
async def syncToSynapse_async(
11951212
syn: Synapse,
11961213
manifestFile,
@@ -1200,7 +1217,68 @@ async def syncToSynapse_async(
12001217
merge_existing_annotations: bool = True,
12011218
associate_activity_to_new_version: bool = False,
12021219
) -> None:
1203-
"""Async version of syncToSynapse."""
1220+
"""Synchronizes files specified in the manifest file to Synapse.
1221+
1222+
.. deprecated:: 4.13.0
1223+
Use :meth:`synapseclient.models.Project.sync_to_synapse` or
1224+
:meth:`synapseclient.models.Folder.sync_to_synapse` instead.
1225+
This function will be removed in v5.0.0.
1226+
1227+
Given a file describing all of the uploads, this uploads the content to Synapse and
1228+
optionally notifies you via Synapse messaging (email) at specific intervals, on
1229+
errors and on completion.
1230+
1231+
[Read more about the manifest file format](../../explanations/manifest_tsv/)
1232+
1233+
There are a few conversions around annotations to call out here.
1234+
1235+
## Conversion of annotations from the TSV file to Python native objects
1236+
1237+
The first annotation conversion is from the TSV file into a Python native object. For
1238+
example Pandas will read a TSV file and convert the string "True" into a boolean True,
1239+
however, Pandas will NOT convert our comma delimited and bracket wrapped list of
1240+
annotations into their Python native objects. This means that we need to do that
1241+
conversion here after splitting them apart.
1242+
1243+
## Conversion of Python native objects for the REST API
1244+
1245+
The second annotation conversion occurs when we are taking the Python native objects
1246+
and converting them into a string that can be sent to the REST API. For example
1247+
the datetime objects which may have timezone information are converted to milliseconds
1248+
since epoch.
1249+
1250+
Arguments:
1251+
syn: A Synapse object with user's login, e.g. syn = synapseclient.login()
1252+
manifestFile: A tsv file with file locations and metadata to be pushed to Synapse.
1253+
dryRun: Performs validation without uploading if set to True.
1254+
sendMessages: Sends out messages on completion if set to True.
1255+
retries: Number of retries to attempt if an error occurs.
1256+
merge_existing_annotations: If True, will merge the annotations in the manifest
1257+
file with the existing annotations on Synapse. If False, will overwrite the
1258+
existing annotations on Synapse with the annotations in the manifest file.
1259+
associate_activity_to_new_version: If True, and a version update occurs, the
1260+
existing activity in Synapse will be associated with the new version. The
1261+
exception is if you are specifying new values to be used/executed, it will
1262+
create a new activity for the new version of the entity.
1263+
1264+
Returns:
1265+
None
1266+
1267+
Example: Migration to new method
1268+
 
1269+
1270+
```python
1271+
# Old approach (DEPRECATED)
1272+
# import synapseutils
1273+
# await synapseutils.syncToSynapse_async(syn, manifestFile="path/to/manifest.tsv")
1274+
1275+
# New approach (RECOMMENDED)
1276+
from synapseclient.models import Project
1277+
1278+
project = Project(id="syn1234")
1279+
await project.sync_to_synapse_async(manifest_path="path/to/manifest.csv")
1280+
```
1281+
"""
12041282
df = await readManifestFile_async(syn, manifestFile)
12051283

12061284
sizes = [

0 commit comments

Comments
 (0)