as.list() doesn't work on synGetChildren() results of a single entity type

Description

Using synapser 0.1.28 and PythonEmbedInR 0.1.15 I try to get all child files of a folder with synGetChildren(includeTypes = "file"). Converting the result to a list with as.list() fails:

I get the same error with includeTypes = "folder", but no error if I use includeTypes = list("file", "folder") or if I leave out includeTypes altogether.

Environment

None

Activity

Show:
Kimyen Truong
April 18, 2018, 12:06 AM
Edited

This is another conversion problem between R and Python. At a low level, we do not know if user meant to pass a single character or a list of one character.

Per , for this specific case, the Python client could allow user to either pass in a single value or a list of values to filter.

I will move this issue to Python to add a fix there. But this would be validated in both Python and synapser client.
This issue come up often. I would like to think more about this and look into PythonEmbedInR before making the change in the Python client. Otherwise, we would end up changing majority of functions in Python client to work with synapser.

Kimyen Truong
October 25, 2018, 5:48 PM

, this problem occurs because when you type synGetChildren(includeTypes = "file"), your input is an R vector. When we converted to Python, a vector contains 1 value is converted to a single value.

synGetChildren(includeTypes = list("file")) should work here to solve the problem. I created to document this more widely.

Kara Woo
October 25, 2018, 6:11 PM

Ok, I'm glad there is a solution, though it is really not idiomatic in R to use a list here.

For the documentation of synGetChildren() specifically, we currently show three different ways to call the function, only one of which is correct, so we should make sure to clarify that as well:

Kimyen Truong
October 25, 2018, 7:43 PM

I totally agree. I will update the documentation to:
1. Clearly state what string values can be used here.
2. Document the case where user has to use list() for a single value input.

Kara Woo
January 24, 2019, 6:16 PM

documentation looks good now, thanks!

Assignee

Kimyen Truong

Reporter

Kara Woo

Validator

Kara Woo

Development Area

None

Release Version History

None

Sprint

None

Fix versions

Priority

Minor
Configure