data() uses discover in case if dshape provided and data_source is string
- Dominant language
- Python
- Stars
- 3.2k
- Forks
- 389
- PR merge metrics
- No merged PRs in 30d
Description
The problem code:
```
>>> bz.Data("mongodb://localhost/scrapy::car", dshape = 'var * {url: string}')
Traceback (most recent call last):
File "", line 1, in
File "/Users/yuri/anaconda2/envs/ssguru/lib/python2.7/site-packages/blaze/interactive.py", line 129, in Data
return data(data_source, dshape=dshape, name=name, fields=fields, schema=schema, **kwargs)
File "/Users/yuri/anaconda2/envs/ssguru/lib/python2.7/site-packages/blaze/interactive.py", line 143, in data
return _Data(data_source, discover(data_source), name)
File "/Users/yuri/anaconda2/envs/ssguru/lib/python2.7/site-packages/multipledispatch/dispatcher.py", line 164, in __call__
return func(*args, **kwargs)
File "/Users/yuri/anaconda2/envs/ssguru/lib/python2.7/site-packages/odo/backends/mongo.py", line 33, in discover_pymongo_collection
raise ValueError("Consistent datashape not found")
ValueError: Consistent datashape not found
```
My collection structure is not plain and may be this is the problem for odo's discovery.
However this works ok:
```
>>> bz.Data(bz.resource("mongodb://localhost/scrapy::car"), dshape = 'var * {url: string}')
<'Collection' data; _name='_11', dshape='var * {url: string}'>
```
I see the following lines in https://github.com/blaze/blaze/blob/master/blaze/interactive.py around line 151
```
if isinstance(data_source, _strtypes):
data_source = resource(data_source, schema=schema, dshape=dshape, **kwargs)
return _Data(data_source, discover(data_source), name)
```
I guess that discover(data_source) is not needed if dshape provided on the third line.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in blaze/interactive.py around line 151 and compare the string data_source path with the bz.resource(...) path shown in the report. Reproduce the MongoDB example with a supplied dshape; done means the string form no longer fails because of unnecessary discovery and retains the requested dshape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100