We're updating the issue view to help you get more done. 

Storing schema is rejected despite no changes being made since last fetch

Description

If I create and store a Synapse Table, then call the table.schema.addColumn method on the object returned by syn.store and attempt to store the newly updated schema, I see an exception that the schema has been updated since I last fetched it.

1 2 SynapseHTTPError: 412 Client Error: Object: syn18909359 was updated since you last fetched it, retrieve it again and re-apply the update

Here is code to reproduce the exception:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 import synapseclient import uuid import pandas def new_project(syn): project = synapseclient.Project(str(uuid.uuid4())) project = syn.store(project) return project def table_schema(project_obj): cols = [synapseclient.Column(name="recordId", columnType="INTEGER"), synapseclient.Column(name="externalId", columnType="STRING")] schema = synapseclient.Schema(name = str(uuid.uuid4()), columns = cols, parent = project_obj["id"]) return schema def main(): syn = synapseclient.login() sample_data = pandas.DataFrame({ "recordId": [123, 456], "externalId": ["ABC", "DEF"]}) project = new_project(syn) schema = table_schema(project) table = syn.store(synapseclient.Table(schema, sample_data)) new_column = synapseclient.Column( columnType="STRING", maximumSize=5, name="new_col") table.schema.addColumn(new_column) try: syn.store(table.schema) finally: syn.delete(project) if __name__ == "__main__": main()

and here is the full exception:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 SynapseHTTPError Traceback (most recent call last) <ipython-input-91-5779e94df576> in <module> ----> 1 testing.main() ~/Documents/synapsebridgehelpers/synapsebridgehelpers/testing.py in main() 30 print(type(table.schema)) 31 table.schema.addColumn(new_column) ---> 32 syn.store(table.schema) ~/miniconda3/lib/python3.6/site-packages/synapseclient/client.py in store(self, obj, **kwargs) 995 # Create or update Entity in Synapse 996 if 'id' in properties: --> 997 properties = self._updateEntity(properties, forceVersion, versionLabel) 998 else: 999 # If Link, get the target name, version number and concrete type and store in link properties ~/miniconda3/lib/python3.6/site-packages/synapseclient/client.py in _updateEntity(self, entity, incrementVersion, versionLabel) 3246 entity['versionLabel'] = str(versionLabel) 3247 -> 3248 return self.restPUT(uri, body=json.dumps(get_properties(entity))) 3249 3250 def findEntityId(self, name, parent=None): ~/miniconda3/lib/python3.6/site-packages/synapseclient/client.py in restPUT(self, uri, body, endpoint, headers, retryPolicy, **kwargs) 3366 response = _with_retry(lambda: self._requests_session.put(uri, data=body, headers=headers, **kwargs), 3367 verbose=self.debug, **retryPolicy) -> 3368 exceptions._raise_for_status(response, verbose=self.debug) 3369 return self._return_rest_body(response) 3370 ~/miniconda3/lib/python3.6/site-packages/synapseclient/exceptions.py in _raise_for_status(response, verbose) 151 message += "\nCould not append all response info" 152 --> 153 raise SynapseHTTPError(message, response=response) SynapseHTTPError: 412 Client Error: Object: syn18909359 was updated since you last fetched it, retrieve it again and re-apply the update

 

Environment

python 3.6.7 and 3.7.3

Status

Assignee

Kimyen Truong

Reporter

Phil Snyder

Labels

Validator

Phil Snyder

Release Version History

None

Affects versions

py-1.9.2

Priority

Major