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

Multiple issues with get_search_term_examples #175

Closed
derneuere opened this issue Feb 18, 2021 · 5 comments
Closed

Multiple issues with get_search_term_examples #175

derneuere opened this issue Feb 18, 2021 · 5 comments
Labels
backend bug Something isn't working

Comments

@derneuere
Copy link
Member

The search is working, but still gets an ValueError, which isn't logged... It usually selects random elements to always populate the list with interesting things.
from random.sample docs:
If the sample size is larger than the population size, a ValueError is raised.
It should always return some examples regardless of the number of photos scanned

Also some people reported, that get_search_term_examples throws exceptions:

Librephotos-backend | File "/miniconda/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
Librephotos-backend | response = handler(request, *args, **kwargs)
Librephotos-backend | File "/code/api/views.py", line 1424, in get
Librephotos-backend | search_term_examples = get_search_term_examples(request.user)
Librephotos-backend | File "/code/api/api_util.py", line 163, in get_search_term_examples
Librephotos-backend | term_thing = random.choice(datum['things'])
Librephotos-backend | File "/miniconda/lib/python3.8/random.py", line 290, in choice
Librephotos-backend | raise IndexError('Cannot choose from an empty sequence') from None
@guystreeter
Copy link

This one is keeping my scan from completing.

@derneuere
Copy link
Member Author

@guystreeter This has nothing to do with the scan process :) You probably have a different issue.

I resolved the problem.

@derneuere
Copy link
Member Author

The error is back, yay:

Internal Server Error: /api/searchtermexamples/
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/code/api/views/views.py", line 956, in get
    search_term_examples = get_search_term_examples(request.user)
  File "/code/api/api_util.py", line 143, in get_search_term_examples
    terms_things = p.captions_json['places365'][
TypeError: 'NoneType' object is not subscriptable

@derneuere derneuere reopened this Jul 27, 2021
@derneuere
Copy link
Member Author

Fixed a performance issue and an exception. But this should still be refactored to something more useful

@lumy
Copy link

lumy commented Oct 29, 2021

if that can help i got trouble with the same function:

librephotos-docker-backend-1   | Internal Server Error: /api/searchtermexamples/
librephotos-docker-backend-1   | Traceback (most recent call last):
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/exception.py", line 47, in inner
librephotos-docker-backend-1   |     response = get_response(request)
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/base.py", line 181, in _get_response
librephotos-docker-backend-1   |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
librephotos-docker-backend-1   |     return view_func(*args, **kwargs)
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/django/views/generic/base.py", line 70, in view
librephotos-docker-backend-1   |     return self.dispatch(request, *args, **kwargs)
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/rest_framework/views.py", line 509, in dispatch
librephotos-docker-backend-1   |     response = self.handle_exception(exc)
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/rest_framework/views.py", line 469, in handle_exception
librephotos-docker-backend-1   |     self.raise_uncaught_exception(exc)
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
librephotos-docker-backend-1   |     raise exc
librephotos-docker-backend-1   |   File "/usr/local/lib/python3.9/dist-packages/rest_framework/views.py", line 506, in dispatch
librephotos-docker-backend-1   |     response = handler(request, *args, **kwargs)
librephotos-docker-backend-1   |   File "/code/api/views/views.py", line 1171, in get
librephotos-docker-backend-1   |     search_term_examples = get_search_term_examples(request.user)
librephotos-docker-backend-1   |   File "/code/api/api_util.py", line 154, in get_search_term_examples
librephotos-docker-backend-1   |     possible_ids = random.choices(possible_ids, k=100)
librephotos-docker-backend-1   |   File "/usr/lib/python3.9/random.py", line 487, in choices
librephotos-docker-backend-1   |     return [population[floor(random() * n)] for i in _repeat(None, k)]
librephotos-docker-backend-1   |   File "/usr/lib/python3.9/random.py", line 487, in <listcomp>
librephotos-docker-backend-1   |     return [population[floor(random() * n)] fo

AnkurPrabhu pushed a commit to AnkurPrabhu/librephotos that referenced this issue Oct 22, 2023
…on_for_motion_photos

initial implementation for motion photos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants