LibrePhotos / librephotos

A self-hosted open source photo management service. This is the repository of the backend.
MIT License
7.01k stars 309 forks source link

exception in backend NetworkXError #237

Closed rickysarraf closed 3 years ago

rickysarraf commented 3 years ago

🐛 Bug Report

What Operating system and version is LibrePhotos running on:

Debian Unstable

What architecture is LibrePhotos running on:

x64

How is LibrePhotos installed:

Docker

If running via Docker or Kubernetes please list version including docker-compose:

3.8

Are you running LibrePhotos on a virtual machine if so please list:

No

How is you picture library mounted on the host (or in the virtual machine):

Local file system BTRFS

Description of issue:

Exception seen when doing some random operation on the UI

proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:13 +0000] "GET /api/rqavailable/ HTTP/1.1" 200 427 "http://lenovo:3000/recent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:15 +0000] "GET /api/rqavailable/ HTTP/1.1" 200 427 "http://lenovo:3000/recent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:17 +0000] "GET /api/rqavailable/ HTTP/1.1" 200 427 "http://lenovo:3000/recent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:19 +0000] "GET /api/rqavailable/ HTTP/1.1" 200 427 "http://lenovo:3000/recent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:21 +0000] "GET /api/rqavailable/ HTTP/1.1" 200 427 "http://lenovo:3000/recent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:23 +0000] "GET /api/rqavailable/ HTTP/1.1" 200 427 "http://lenovo:3000/recent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:25 +0000] "GET /api/rqavailable/ HTTP/1.1" 200 427 "http://lenovo:3000/recent" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"
backend_1   | Internal Server Error: /api/socialgraph
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.8/site-packages/networkx/utils/decorators.py", line 396, in _random_state
backend_1   |     random_state_arg = args[random_state_index]
backend_1   | IndexError: tuple index out of range
backend_1   | 
backend_1   | The above exception was the direct cause of the following exception:
backend_1   | 
backend_1   | Traceback (most recent call last):
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
backend_1   |     response = get_response(request)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
backend_1   |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
backend_1   |     return view_func(*args, **kwargs)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
backend_1   |     return self.dispatch(request, *args, **kwargs)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
backend_1   |     response = self.handle_exception(exc)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
backend_1   |     self.raise_uncaught_exception(exc)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
backend_1   |     raise exc
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
backend_1   |     response = handler(request, *args, **kwargs)
backend_1   |   File "/code/api/views.py", line 1444, in get
backend_1   |     res = build_social_graph(request.user)
backend_1   |   File "/code/api/social_graph.py", line 25, in build_social_graph
backend_1   |     pos = nx.spring_layout(G, k=1/2, scale=1000, iterations=20)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/decorator.py", line 231, in fun
backend_1   |     return caller(func, *(extras + args), **kw)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/networkx/utils/decorators.py", line 400, in _random_state
backend_1   |     raise nx.NetworkXError("random_state_index is incorrect") from e
backend_1   | networkx.exception.NetworkXError: random_state_index is incorrect
proxy_1     | 10.42.0.24 - - [22/Apr/2021:13:32:25 +0000] "GET /api/socialgraph HTTP/1.1" 500 145 "http://lenovo:3000/socialgraph" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36"

How can we reproduce it:

I think it triggered when clicking feature Social Graph

rickysarraf commented 3 years ago

Yes. I can confirm now that it happens when clicking Data Viz => Social Graph

tomamplius commented 3 years ago

Can you execute the bellow query on postgres?


        with face as (
            select photo_id,  person_id, name
            from api_face join api_person on api_person.id = person_id
            where person_label_is_inferred = false
        )
        select f1.name, f2.name
        from face f1 join face f2 using (photo_id)
        where f1.person_id != f2.person_id
        group by f1.name, f2.name
rickysarraf commented 3 years ago

Can you execute the bellow query on postgres?

        with face as (
          select photo_id,  person_id, name
          from api_face join api_person on api_person.id = person_id
          where person_label_is_inferred = false
        )
        select f1.name, f2.name
        from face f1 join face f2 using (photo_id)
        where f1.person_id != f2.person_id
        group by f1.name, f2.name

I hope this is what you expected me to execute.

root@dd0ef23a8d0f:/# psql librephotos docker -c 'with face as ( select photo_id, person_id, name from api_face join api_person on api_person.id = person_id where person_label_is_inferred = false ) select f1.name, f2.name from face f1 join face f2 using (photo_id) where f1.person_id != f2.person_id group by f1.name, f2.name'
 name | name 
------+------
(0 rows)
tomamplius commented 3 years ago

Great, there is no data. (you have not photo with 2 faces) i will fix this case with a PR. thanks

rickysarraf commented 3 years ago

Perfect. I just started evaluating this software today. I'm glad I could be of help. :pray: