solvebio/solvebio-python

Confusing error on dataset creation if there is a folder with the same name in that folder path

Closed this issue · 1 comments

For example, if I try to create a new dataset called meow in my personal vault, which already contains a folder named meow.
The front-end will create a dataset named meow-1 (which I find a little confusing too, but I guess better than this error)

In [18]: target = Dataset.get_or_create_by_full_path('~/meow')
------------------------------------------------------------------------
Exception                              Traceback (most recent call last)
/Users/dandan/anaconda2/lib/python2.7/site-packages/solvebio/cli/ipython.pyc in <module>()
----> 1 target = Dataset.get_or_create_by_full_path('~/meow')

/Users/dandan/anaconda2/lib/python2.7/site-packages/solvebio/resource/dataset.pyc in get_or_create_by_full_path(cls, full_path, **kwargs)
     78 
     79         try:
---> 80             return Dataset.get_by_full_path(full_path, client=_client)
     81         except NotFoundError:
     82             pass

/Users/dandan/anaconda2/lib/python2.7/site-packages/solvebio/resource/dataset.pyc in get_by_full_path(cls, full_path, **kwargs)
     63         test_path, _ = Object.validate_full_path(full_path, client=_client)
     64         obj = Object.get_by_full_path(test_path, client=_client)
---> 65         dataset = Dataset.retrieve(obj['dataset_id'], client=_client, **kwargs)
     66         return dataset
     67 

/Users/dandan/anaconda2/lib/python2.7/site-packages/solvebio/resource/apiresource.pyc in retrieve(cls, id, **params)
     36     def retrieve(cls, id, **params):
     37         instance = cls(id, **params)
---> 38         instance.refresh()
     39         return instance
     40 

/Users/dandan/anaconda2/lib/python2.7/site-packages/solvebio/resource/apiresource.pyc in refresh(self)
     40 
     41     def refresh(self):
---> 42         self.refresh_from(self.request('get', self.instance_url()))
     43         return self
     44 

/Users/dandan/anaconda2/lib/python2.7/site-packages/solvebio/resource/apiresource.pyc in instance_url(self)
     68                 'Could not determine which URL to request: %s instance '
     69                 'has invalid ID: %r' % (type(self).__name__, id_),
---> 70                 self.ID_ATTR)
     71 
     72 

Exception: ('Could not determine which URL to request: Dataset instance has invalid ID: None', 'id')

This branch should fix it: #230