downloadTableColumns() function doesn't work when resultsAs="rowset" is set for for syn.tableQuery()
Description
Environment
Activity
It's the code on the python docs site for tables, the only difference is that I tried running it with resultsAs="rowset" in syn.tableQuery().
Â
your synapse project
project = syn.get(...)
covers_dir = '/path/to/album/covers/'
Â
store the table's schema
cols = [
Column(name='artist', columnType='STRING', maximumSize=50),
Column(name='album', columnType='STRING', maximumSize=50),
Column(name='year', columnType='INTEGER'),
Column(name='catalog', columnType='STRING', maximumSize=50),
Column(name='cover', columnType='FILEHANDLEID')]
schema = syn.store(Schema(name='Jazz Albums', columns=cols, parent=project))
Â
the actual data
data = [["John Coltrane", "Blue Train", 1957, "BLP 1577", "coltraneBlueTrain.jpg"],
["Sonny Rollins", "Vol. 2", 1957, "BLP 1558", "rollinsBN1558.jpg"],
["Sonny Rollins", "Newk's Time", 1958, "BLP 4001", "rollinsBN4001.jpg"],
["Kenny Burrel", "Kenny Burrel", 1956, "BLP 1543", "burrellWarholBN1543.jpg"]]
Â
upload album covers
for row in data:
file_handle = syn._uploadToFileHandleService(os.path.join(covers_dir, row[4]))
row[4] = file_handle['id']
Â
store the table data
row_reference_set = syn.store(RowSet(columns=cols, schema=schema, rows=[Row(r) for r in data]))
Â
Later, we'll want to query the table and download our album covers
results = syn.tableQuery("select artist, album, year, catalog, cover from %s where artist = 'Sonny Rollins'" % schema.id,resultsAs="rowset"
)
cover_files = syn.downloadTableColumns(results, ['cover'])
Whattt. Can you add code here that reproduces the error?
Still getting a KeyError rather than an exception with the latest version from the develop branch.
Documentation added
Throw error if tableQuery results are in "rowset" form. However, I think the code can be fixed to also allow for it. Not sure what is the best implementation. https://github.com/Sage-Bionetworks/synapsePythonClient/pull/321