qri-io/qri-python

RuntimeError: Unknown type: "number" Using ds.body()

Closed this issue · 6 comments

Trying to get the dataset body using
ds = qri.get('xristosk/ucla_law_covid_prison_history') ds.body()

This same error comes up with all of my other datasets.

Getting the RuntimeError: Unknown type. Here's the traceback

----> 1 ds.body()

~/datasets/notebooks/qri/dataset.py in body(self)
     92       raise RuntimeError('Only csv body format is supported')
     93     if self.body_component is None:
---> 94       df = loader.load_body(self.username, self.name, self.structure)
     95       self.body_component = df
     96     return self.body_component

~/datasets/notebooks/qri/loader.py in load_body(username, dsname, structure)
     15   columns = [e for e in structure.schema['items']['items']]
     16   col_names = [c['title'] for c in columns]
---> 17   types = {c['title']: pd_type(c['type']) for c in columns}
     18   header = 0 if structure.format_config.get('headerRow') else None
     19   df = None

~/datasets/notebooks/qri/loader.py in <dictcomp>(.0)
     15   columns = [e for e in structure.schema['items']['items']]
     16   col_names = [c['title'] for c in columns]
---> 17   types = {c['title']: pd_type(c['type']) for c in columns}
     18   header = 0 if structure.format_config.get('headerRow') else None
     19   df = None

~/datasets/notebooks/qri/loader.py in pd_type(t)
     33   elif t == 'string':
     34     return 'string'
---> 35   raise RuntimeError('Unknown type: "%s"' % t)

RuntimeError: Unknown type: "number"`

This should hopefully be fixed by 7ea527f.

@dustmop Still getting the same error. However, a couple datasets worked like xristosk/hennepin_county_inmates_in_pandemic and xristosk/list_of_epidemics.

You ran git pull inside the cloned qri-python repository? Could you try again, and if there's still an error, post the traceback?

@dustmop I ran git fetch . but just did a pull as well, and everything seems up-to-date. Here's the traceback:

RuntimeError                              Traceback (most recent call last)
<ipython-input-51-d01a755dc9c0> in <module>
----> 1 ds.body

~/datasets/notebooks/qri/dataset.py in body(self)
     92       raise RuntimeError('Only csv body format is supported')
     93     if self.body_component is None:
---> 94       df = loader.load_body(self.username, self.name, self.structure)
     95       self.body_component = df
     96     return self.body_component

~/datasets/notebooks/qri/loader.py in load_body(username, dsname, structure)
     15   columns = [e for e in structure.schema['items']['items']]
     16   col_names = [c['title'] for c in columns]
---> 17   types = {c['title']: pd_type(c['type']) for c in columns}
     18   header = 0 if structure.format_config.get('headerRow') else None
     19   df = None

~/datasets/notebooks/qri/loader.py in <dictcomp>(.0)
     15   columns = [e for e in structure.schema['items']['items']]
     16   col_names = [c['title'] for c in columns]
---> 17   types = {c['title']: pd_type(c['type']) for c in columns}
     18   header = 0 if structure.format_config.get('headerRow') else None
     19   df = None

~/datasets/notebooks/qri/loader.py in pd_type(t)
     33   elif t == 'number':
     34     return 'float64'
---> 35   elif t == 'string':
     36     return 'string'
     37   elif t == 'bool':

RuntimeError: Unknown type: "number"

Ah, that stack track is interesting. You've also got to restart the Jupyter kernel (Kernel -> Restart) or (Kernel -> Restart & Run All). Unfortunately this will restart the state of the notebook, hope this is not too inconvenient.

Awesome, yea that worked. I'm able to grab the body now. Thanks!