Annotations¶
Annotations are arbitrary metadata attached to Synapse entities. They can be accessed like ordinary object properties or like dictionary keys:
entity.my_annotation = 'This is one way to do it'
entity['other_annotation'] = 'This is another'
Annotations can be given in the constructor for Synapse Entities:
entity = File('data.xyz', parent=my_project, rating=9.1234)
Annotate the entity with location data:
entity.lat_long = [47.627477, -122.332154]
Record when we collected the data:
from datetime import datetime as Datetime
entity.collection_date = Datetime.now()
See:
Annotating data sources¶
Data sources are best recorded using Synapse’s provenance tools.
Implementation details¶
In Synapse, entities have both properties and annotations. Properties are used by the system, whereas annotations are completely user defined. In the Python client, we try to present this situation as a normal object, with one set of properties.
For more on the implementation and a few gotchas, see the documentation on synapseclient.entity
.
See also:
Classes¶
-
class
synapseclient.annotations.
Annotations
(id: Union[str, int, synapseclient.entity.Entity], etag: str, values: Optional[Dict] = None, **kwargs)¶ Represent Synapse Entity annotations as a flat dictionary with the system assigned properties id, etag as object attributes.
-
__init__
(id: Union[str, int, synapseclient.entity.Entity], etag: str, values: Optional[Dict] = None, **kwargs)¶ Create an Annotations object taking key value pairs from a dictionary or from keyword arguments. System properties id, etag, creationDate and uri become attributes of the object.
- Parameters
id – A Synapse ID, a Synapse Entity object, a plain dictionary in which ‘id’ maps to a Synapse ID
etag – etag of the Synapse Entity
values – (Optional) dictionary of values to be copied into annotations
**kwargs –
additional key-value pairs to be added as annotations
Example:
example1 = Annotations('syn123','40256475-6fb3-11ea-bb0a-9cb6d0d8d984', {'foo':'bar'}) example2 = Annotations('syn123','40256475-6fb3-11ea-bb0a-9cb6d0d8d984', foo='bar') example3 = Annotations('syn123','40256475-6fb3-11ea-bb0a-9cb6d0d8d984') example3['foo'] = 'bar'
-