Skip to main content
Version: 0.95

snorkelflow.client.annotations.update_annotation

snorkelflow.client.annotations.update_annotation(node, annotation_uid, label, metadata=None)

Updates the value of an already-created annotation. This will maintain the original author and timestamp of the annotation. Use sf.delete_annotation and sf.add_annotation` for hard overwrites, where you want to overwrite all annotation data.

Examples

>>> sf.get_annotations(0).loc["doc::0"].loc[123]
{'annotation_uid': 123, 'x_uid': 'doc::0', 'label': 'POS'}
>>> sf.update_annotation(0, 123, "NEG", metadata={"updated by": "sdk"})
>>> sf.get_annotations(0).loc["doc::0"].loc[123]
{'annotation_uid': 123, 'x_uid': 'doc::0', 'label': 'NEG', metadata={"updated by": "sdk"}}

Parameters

NameTypeDefaultInfo
nodeintThe UID of the node the annotation is in.
annotation_uidintThe UID for the annotation to update.
labelstrThe new label for the annotation.
metadataOptional[Dict]NoneOptional metadata to update, by default None.

Raises

  • ValueError – If the label supplied is not valid for the given node

  • ValueError – If we are unable to successfully fetch the node information

  • ValueError – If updating the annotation fails

Return type

None