Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaginatedCollection raising AttributeError on next #74

Closed
vpipkt opened this issue Oct 6, 2020 · 1 comment · Fixed by #75
Closed

PaginatedCollection raising AttributeError on next #74

vpipkt opened this issue Oct 6, 2020 · 1 comment · Fixed by #75

Comments

@vpipkt
Copy link
Contributor

vpipkt commented Oct 6, 2020

Consider this innocent looking example.

next(dataset.data_rows(DataRow.uid == datarow_id))

This raises:

Stack trace
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-50-dc7c6a64cb8a> in <module>
----> 1 next(dataset.data_rows(DataRow.uid == datarow_id))

~/projects/p-street/.venv/lib/python3.7/site-packages/labelbox/pagination.py in __next__(self)
     41 
     42     def __next__(self):
---> 43         if len(self._data) <= self._data_ind:
     44             if self._fetched_all:
     45                 raise StopIteration()

AttributeError: 'PaginatedCollection' object has no attribute '_data_ind'

Root cause seems to be that PaginatedCollection does not initialize self._data_ind in constructor.

In current implementation, the above attempt must be called as:

next(iter(dataset.data_rows(DataRow.uid == datarow_id)))
@vpipkt
Copy link
Contributor Author

vpipkt commented Oct 6, 2020

I note also that the PaginatedCollection docs say it is for internal use. However, the pattern for public calls in such a case as above is unclear to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant