Skip to content

Commit 63c38e5

Browse files
committed
Deprecate getProvenance and create get_activity
1 parent 3a6db21 commit 63c38e5

3 files changed

Lines changed: 42 additions & 10 deletions

File tree

synapseclient/__main__.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import re
1717
import shutil
1818

19+
import deprecated
20+
1921
import synapseclient
2022
import synapseutils
2123

@@ -341,7 +343,7 @@ def show(args, syn):
341343
syn.printEntity(ent)
342344
sys.stdout.write("Provenance:\n")
343345
try:
344-
prov = syn.getProvenance(ent)
346+
prov = syn.get_activity(ent)
345347
syn.logger.info(prov)
346348
except SynapseHTTPError:
347349
syn.logger.error(" No Activity specified.\n")
@@ -405,8 +407,8 @@ def setProvenance(args, syn):
405407
)
406408

407409

408-
def getProvenance(args, syn):
409-
activity = syn.getProvenance(args.id, args.version)
410+
def get_activity(args, syn: synapseclient.Synapse):
411+
activity = syn.get_activity(args.id, args.version)
410412

411413
if args.output is None or args.output == "STDOUT":
412414
syn.logger.info(json.dumps(activity, sort_keys=True, indent=2))
@@ -416,6 +418,14 @@ def getProvenance(args, syn):
416418
f.write("\n")
417419

418420

421+
@deprecated.sphinx.deprecated(
422+
version="3.1.0",
423+
reason="deprecated and replaced with :py:meth:`get_activity`",
424+
)
425+
def getProvenance(args, syn: synapseclient.Synapse):
426+
get_activity(args, syn)
427+
428+
419429
def setAnnotations(args, syn):
420430
"""Method to set annotations on an entity.
421431
@@ -1483,7 +1493,7 @@ def build_parser():
14831493
type=str,
14841494
help="Output the provenance record in JSON format",
14851495
)
1486-
parser_get_provenance.set_defaults(func=getProvenance)
1496+
parser_get_provenance.set_defaults(func=get_activity)
14871497

14881498
parser_set_annotations = subparsers.add_parser(
14891499
"set-annotations", help="create annotations records"

synapseclient/client.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import collections.abc
77
import configparser
88
import csv
9+
import numbers
910
import deprecated
1011
import errno
1112
import functools
@@ -846,7 +847,7 @@ def get(self, entity, **kwargs):
846847
847848
# Determine the provenance of a locally stored file as indicated in Synapse
848849
entity = syn.get('/path/to/file.txt', limitSearch='syn12312')
849-
print(syn.getProvenance(entity))
850+
print(syn.get_activity(entity))
850851
851852
"""
852853
# If entity is a local file determine the corresponding synapse entity
@@ -2187,9 +2188,9 @@ def setPermissions(
21872188
############################################################
21882189
# Provenance #
21892190
############################################################
2190-
2191-
# TODO: rename these to Activity
2192-
def getProvenance(self, entity, version=None):
2191+
def get_activity(
2192+
self, entity: typing.Union[Entity, str, numbers.Number], version: str = None
2193+
) -> any:
21932194
"""
21942195
Retrieve provenance information for a Synapse Entity.
21952196
@@ -2211,6 +2212,27 @@ def getProvenance(self, entity, version=None):
22112212
uri = "/entity/%s/generatedBy" % id_of(entity)
22122213
return Activity(data=self.restGET(uri))
22132214

2215+
@deprecated.sphinx.deprecated(
2216+
version="3.1.0",
2217+
reason="deprecated and replaced with :py:meth:`get_activity`",
2218+
)
2219+
def getProvenance(
2220+
self, entity: typing.Union[Entity, str, numbers.Number], version: str = None
2221+
):
2222+
"""
2223+
Deprecated and replaced with :py:meth:`get_activity`.
2224+
2225+
Retrieve provenance information for a Synapse Entity.
2226+
2227+
:param entity: An Entity or Synapse ID to lookup
2228+
:param version: The version of the Entity to retrieve.
2229+
Gets the most recent version if omitted
2230+
2231+
:returns: An Activity object or
2232+
raises exception if no provenance record exists
2233+
"""
2234+
return self.get_activity(entity, version)
2235+
22142236
def setProvenance(self, entity, activity):
22152237
"""
22162238
Stores a record of the code and data used to derive a Synapse entity.
@@ -2237,7 +2259,7 @@ def deleteProvenance(self, entity):
22372259
:param entity: An Entity or Synapse ID to modify
22382260
"""
22392261

2240-
activity = self.getProvenance(entity)
2262+
activity = self.get_activity(entity)
22412263
if not activity:
22422264
return
22432265

synapseutils/copy_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ def _copyFile(
564564
# if existing, check if provenance exists
565565
elif setProvenance == "existing":
566566
try:
567-
act = syn.getProvenance(ent.id)
567+
act = syn.get_activity(ent.id)
568568
except SynapseHTTPError as e:
569569
if e.response.status_code == 404:
570570
act = None

0 commit comments

Comments
 (0)