kizniche / Mycodo

An environmental monitoring and regulation system
http://kylegabriel.com/projects/
GNU General Public License v3.0
2.95k stars 494 forks source link

Input plugin dependency grpcio install loop #1199

Closed moneal closed 2 years ago

moneal commented 2 years ago

Describe the problem/bug

I'm attempting to write an input plugin that uses GCP PubSub topics and needs the grpcio python library. When I add it to my dependencies it attempts to install but says the dependency is already met and completes. Anytime I attempt to add the input, it again asks to install the same grpcio dependency getting stuck in a loop. The dependency requirement is never met. Removing the dependency requirement allows the input to be added but would be unable to use pubsub.

Versions:

Reproducibility

  1. Import Input Module
  2. Navigate to /input
  3. Select newly uploaded input
  4. Click Add button
  5. Install dialog appears asking to install grpcio, click Install
  6. Installation completes, click Close
  7. With input still selected click Add again
  8. Install dependency dialog appears asking to install grpcio again.

Install Dialog

Install Dependencies for Google Cloud PubSub Subscribe (JSON payload)

There were unmet dependencies encountered when adding the following device: Google Cloud PubSub Subscribe (JSON payload) (GOOGLE_PUBSUB_JSON)

Dependencies not installed: grpcio==1.44.0

To install these dependencies, click the Install button below and wait for the install to complete before attempting to add the device again. Note that the frontend and the backend will be restarted following the install to allow detection of the newly-installed modules.

Expected behavior

I would expect when the dependency install script completes the action the input can be added and configured.

Mycodo Dependency Log

[2022-05-27 09:27:29] 
[2022-05-27 09:27:29] #### Installing/updating grpcio==1.44.0 (pip-pypi)
[2022-05-27 09:27:33] WARNING: Ignoring invalid distribution -rpcio (/home/pi/Mycodo/env/lib/python3.9/site-packages)
[2022-05-27 09:27:33] WARNING: Ignoring invalid distribution -rpcio (/home/pi/Mycodo/env/lib/python3.9/site-packages)
[2022-05-27 09:27:33] Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
[2022-05-27 09:27:33] Requirement already satisfied: grpcio==1.44.0 in ./env/lib/python3.9/site-packages (1.44.0)
[2022-05-27 09:27:40] Requirement already satisfied: six>=1.5.2 in ./env/lib/python3.9/site-packages (from grpcio==1.44.0) (1.16.0)
[2022-05-27 09:27:40] WARNING: Ignoring invalid distribution -rpcio (/home/pi/Mycodo/env/lib/python3.9/site-packages)
[2022-05-27 09:27:45] WARNING: Ignoring invalid distribution -rpcio (/home/pi/Mycodo/env/lib/python3.9/site-packages)
[2022-05-27 09:27:45] WARNING: Ignoring invalid distribution -rpcio (/home/pi/Mycodo/env/lib/python3.9/site-packages)
[2022-05-27 09:27:45] WARNING: Ignoring invalid distribution -rpcio (/home/pi/Mycodo/env/lib/python3.9/site-packages)

[2022-05-27 09:27:46] End install of grpcio

[2022-05-27 09:27:46] 
[2022-05-27 09:27:46] #### Setting permissions

[2022-05-27 09:27:49] #### Dependencies installed. Restarting frontend and backend...

[2022-05-27 09:28:05] #### Dependency install complete.

Additional context

INPUT_INFORMATION = {
    ...
    'dependencies_module': [
        ('pip-pypi', 'google.cloud', 'google-cloud-pubsub==2.12.1'),
        ('pip-pypi', 'grpcio', 'grpcio==1.44.0'),
        ('pip-pypi', 'jmespath', 'jmespath==0.10.0'),
    ],
    ...
}
kizniche commented 2 years ago

The second item in the dependency tuples is the name of the module that's imported. In the case of the pypi package grpcio, that would be "grpc":

import grpc

The name of the imported module and pypi package are not always the same.

moneal commented 2 years ago

Thank you