Blasterai/codaio

Cannot get tables with filters applied

funkymonkeymonk opened this issue · 4 comments

Heya,

I ran a get table on my filtered view and I'm having some issues.

File "/home/codespace/.local/lib/python3.8/site-packages/codaio/coda.py", line 784, in get_table
    return Table.from_json(table_data, document=self)
  File "/home/codespace/.local/lib/python3.8/site-packages/codaio/coda.py", line 699, in from_json
    return cls(**js, document=document)
TypeError: __init__() got an unexpected keyword argument 'filter'

Digging into the code a bit it looks like the Table class doesn't have support for a filter argument here which why I'm getting this error. I'm happy to do the add myself but I'm just relearning python after nearly 10 years so some guidance would be appreciated.

Hi @funkymonkeymonk thanks for catching that. Try to make a pull request and I'll be more than happy to review it. If a field is missing you just need to add it like the other fields on the Table class.

I checked the API docs, since filter is a dictionary:

"filter": {
    "valid": true,
    "isVolatile": false,
    "hasUserFormula": false,
    "hasTodayFormula": false,
    "hasNowFormula": false
}

You first need to introduce a Filter class, then add it as an attribute to the Table class.

attrs makes it all quite simple, just take the Column class as an example.

Is this still an issue? It looks like it was resolved in #51 , and locally updating the library resolved this issue for my team.

I don't actively used coda anymore so it wouldn't impact me.