downloadTableColumns() function doesn't work when resultsAs="rowset" is set for for syn.tableQuery()

Description

None

Environment

None

Activity

Show:
Thomas Yu
September 8, 2016, 8:01 AM

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

Larsson Omberg
September 30, 2016, 10:23 PM

Documentation added

Yooree Chae
October 3, 2016, 6:09 PM

Still getting a KeyError rather than an exception with the latest version from the develop branch.

Thomas Yu
October 3, 2016, 6:31 PM

Whattt. Can you add code here that reproduces the error?

Yooree Chae
October 3, 2016, 6:40 PM
Edited

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().

  1.  

    1. your synapse project
      project = syn.get(...)

covers_dir = '/path/to/album/covers/'

  1.  

    1. 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))

  1.  

    1. 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"]]

  1.  

    1. upload album covers
      for row in data:
      file_handle = syn._uploadToFileHandleService(os.path.join(covers_dir, row[4]))
      row[4] = file_handle['id']

  1.  

    1. store the table data
      row_reference_set = syn.store(RowSet(columns=cols, schema=schema, rows=[Row(r) for r in data]))

  1.  

    1. 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'])

Assignee

Thomas Yu

Reporter

Yooree Chae

Labels

None

Validator

Yooree Chae

Development Area

None

Release Version History

None

Fix versions

Priority

Minor
Configure