Skip to content

Commit beb541a

Browse files
committed
Revert "Merge pull request #816 from jkiang13/SYNPY-1115-store-table-provenance"
This reverts commit effef31, reversing changes made to 1c55705.
1 parent db75f0d commit beb541a

File tree

2 files changed

+6
-113
lines changed

2 files changed

+6
-113
lines changed

synapseclient/client.py

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,7 @@ def store(self, obj, *, createOrUpdate=True, forceVersion=True, versionLabel=Non
999999
# _synapse_store hook
10001000
# for objects that know how to store themselves
10011001
if hasattr(obj, '_synapse_store'):
1002-
obj = obj._synapse_store(self)
1003-
return self._apply_provenance(
1004-
obj,
1005-
activity=activity,
1006-
used=used,
1007-
executed=executed,
1008-
activityName=activityName,
1009-
activityDescription=activityDescription,
1010-
)
1002+
return obj._synapse_store(self)
10111003

10121004
# Handle all non-Entity objects
10131005
if not (isinstance(obj, Entity) or type(obj) == dict):
@@ -1163,30 +1155,6 @@ def store(self, obj, *, createOrUpdate=True, forceVersion=True, versionLabel=Non
11631155
annotations = self.set_annotations(Annotations(properties['id'], properties['etag'], annotations))
11641156
properties['etag'] = annotations.etag
11651157

1166-
properties = self._apply_provenance(
1167-
properties,
1168-
activity=activity,
1169-
used=used,
1170-
executed=executed,
1171-
activityName=activityName,
1172-
activityDescription=activityDescription,
1173-
)
1174-
1175-
# Return the updated Entity object
1176-
entity = Entity.create(properties, annotations, local_state)
1177-
return self.get(entity, downloadFile=False)
1178-
1179-
def _apply_provenance(
1180-
self,
1181-
entity,
1182-
activity=None,
1183-
used=None,
1184-
executed=None,
1185-
activityName=None,
1186-
activityDescription=None
1187-
):
1188-
# apply any provenance passed to via the store method to the entity
1189-
11901158
# If the parameters 'used' or 'executed' are given, create an Activity object
11911159
if used or executed:
11921160
if activity is not None:
@@ -1198,12 +1166,14 @@ def _apply_provenance(
11981166

11991167
# If we have an Activity, set it as the Entity's provenance record
12001168
if activity:
1201-
self.setProvenance(entity, activity)
1169+
self.setProvenance(properties, activity)
12021170

12031171
# 'etag' has changed, so get the new Entity
1204-
entity = self._getEntity(entity)
1172+
properties = self._getEntity(properties)
12051173

1206-
return entity
1174+
# Return the updated Entity object
1175+
entity = Entity.create(properties, annotations, local_state)
1176+
return self.get(entity, downloadFile=False)
12071177

12081178
def _createAccessRequirementIfNone(self, entity):
12091179
"""

tests/unit/synapseclient/unit_test_client.py

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
SynapseFileNotFoundError,
3737
SynapseHTTPError,
3838
SynapseMd5MismatchError,
39-
SynapseProvenanceError,
4039
SynapseUnmetAccessRestrictions,
4140
)
4241
from synapseclient.core.logging_setup import DEFAULT_LOGGER_NAME, DEBUG_LOGGER_NAME, SILENT_LOGGER_NAME
@@ -2445,82 +2444,6 @@ def test_store__existing_no_update(syn):
24452444
assert not mock_updatentity.called
24462445

24472446

2448-
def test_store_self_stored_obj__provenance_applied(syn):
2449-
"""Verify that any object with its own _synapse_store mechanism (e.g. a table) will have
2450-
any passed provenance applied"""
2451-
2452-
obj = Mock()
2453-
del obj._before_synapse_store
2454-
obj._synapse_store = lambda x: x
2455-
2456-
activity_kwargs = {
2457-
'activity': MagicMock(spec=synapseclient.Activity),
2458-
'activityName': 'test name',
2459-
'activityDescription': 'test description',
2460-
'used': ['syn123'],
2461-
'executed': ['syn456'],
2462-
}
2463-
2464-
with patch.object(syn, '_apply_provenance') as mock_apply_provenance:
2465-
stored = syn.store(obj, **activity_kwargs)
2466-
assert mock_apply_provenance.called_once_with(obj, **activity_kwargs)
2467-
assert stored == mock_apply_provenance.return_value
2468-
2469-
2470-
def test_apply_provenance__duplicate_args(syn):
2471-
"""Verify that a SynapseProvenanceError is raised if both used/executed and an Activity is passed"""
2472-
with pytest.raises(SynapseProvenanceError):
2473-
syn._apply_provenance(
2474-
Mock(),
2475-
activity=MagicMock(spec=synapseclient.Activity),
2476-
used=['syn123'],
2477-
executed=['syn456'],
2478-
activityName='test name',
2479-
activityDescription='test description',
2480-
)
2481-
2482-
2483-
def test_apply_provenance__activity(syn):
2484-
"""Verify _apply_provenance behavior when an Activity is passed"""
2485-
2486-
obj = Mock()
2487-
activity = synapseclient.Activity(used=['syn123'])
2488-
with patch.object(syn, 'setProvenance') as mock_set_provenance, \
2489-
patch.object(syn, '_getEntity') as mock_get_entity:
2490-
result = syn._apply_provenance(obj, activity=activity)
2491-
2492-
mock_set_provenance.assert_called_once_with(obj, activity)
2493-
mock_get_entity.assert_called_once_with(obj)
2494-
assert result is mock_get_entity.return_value
2495-
2496-
2497-
def test_apply_provenance__used_executed(syn):
2498-
"""Verify _apply_provenance behavior with used and executed args"""
2499-
2500-
obj = Mock()
2501-
2502-
used = ['syn123']
2503-
executed = ['syn456']
2504-
name = 'test name'
2505-
description = 'test description'
2506-
2507-
expected_activity = synapseclient.Activity(used=used, executed=executed, name=name, description=description)
2508-
2509-
with patch.object(syn, 'setProvenance') as mock_set_provenance, \
2510-
patch.object(syn, '_getEntity') as mock_get_entity:
2511-
result = syn._apply_provenance(
2512-
obj,
2513-
used=used,
2514-
executed=executed,
2515-
activityName=name,
2516-
activityDescription=description
2517-
)
2518-
2519-
mock_set_provenance.assert_called_once_with(obj, expected_activity)
2520-
mock_get_entity.assert_called_once_with(obj)
2521-
assert result is mock_get_entity.return_value
2522-
2523-
25242447
def test_get_submission_with_annotations(syn):
25252448
"""Verify a getSubmission with annotation entityBundleJSON that
25262449
uses the old style annotations is converted to bundle v2 style

0 commit comments

Comments
 (0)