I haven't quite figured out why, though I suspect it is due to a change in how reticulate handles more complex/special python objects.
> synapse_id = "syn48391601"
> value = 'Mus musculus'
> key = 'species'
> entity <- .syn$get_annotations(synapse_id)
> entity[key] <- value
> .syn$set_annotations(entity)
Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
TypeError: Expected a synapseclient.Annotations object
Run `reticulate::py_last_error()` for details.
What I have determined so far is that get_annotations should be returning an Annotations object, and presumably did at some point, but with several versions of synapseclient that I’ve tested (2.4-3.2), it appears to get coerced to an R list.
Then, I can modify the key/value pair with out issues, like before.
But when I go to set annotations, entity is not converted back to an Annotations object (maybe just a regular dict instead?) so set_annotations fails.
Based on the lack of changes in nfportalutils to this function (aka it’s never changed) and the same behavior in a variety of synapseclient versions, I suspect reticulate got smarter and previously didn’t coerce the result of get_annotations where it now is.
If I use the higher-level synapser functions, it seems to work fine. I wonder if I should just switch this to use synapser?
https://github.com/nf-osi/nfportalutils/blame/b3e25c334ae225648445a4d06b5922ea061452ec/R/convert_to_stringlist.R#L109
I haven't quite figured out why, though I suspect it is due to a change in how reticulate handles more complex/special python objects.
What I have determined so far is that get_annotations should be returning an Annotations object, and presumably did at some point, but with several versions of synapseclient that I’ve tested (2.4-3.2), it appears to get coerced to an R list. Then, I can modify the key/value pair with out issues, like before.
But when I go to set annotations, entity is not converted back to an Annotations object (maybe just a regular dict instead?) so set_annotations fails.
Based on the lack of changes in nfportalutils to this function (aka it’s never changed) and the same behavior in a variety of synapseclient versions, I suspect reticulate got smarter and previously didn’t coerce the result of get_annotations where it now is.
If I use the higher-level synapser functions, it seems to work fine. I wonder if I should just switch this to use synapser?