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

Can't run the backend with docker #287

Open
suspiciousRaccoon opened this issue Dec 3, 2024 · 3 comments
Open

Can't run the backend with docker #287

suspiciousRaccoon opened this issue Dec 3, 2024 · 3 comments

Comments

@suspiciousRaccoon
Copy link

suspiciousRaccoon commented Dec 3, 2024

/ᐠ. ̫ .ᐟ\ฅ heya!

I tried running the project with docker but there are a few problems.

  1. TypeError: 'type' object is not subscriptable
    This is the first error I encountered. A quick google search led me to this problem originating from the type hints. Older python versions had a different API, so they're not compatible with the dockerfile's python version. Upgrading the python version to 3.10 fixed this.
  2. Missing dependencies
    backend/api/server.py imports the module waitress, which isn't in the projects requirements.txt, adding it fixes this
    backend/hardware/gpiochip/gpiod.py imports the module gpiod, but when I added it to requirements.txt I got a new error:
2024-12-03 06:13:11,667 [ERROR]: [Errno 2] No such file or directory
                                 Traceback (most recent call last):
                                   File "/app/hardware/core.py", line 63, in loadHardware
                                     self.devices = devicelist.setupDevices(deviceDefinition)
                                   File "/app/hardware/devicelist.py", line 67, in setupDevices
                                     devices[deviceID] = gpiochip.createGPIOChip(device, devices)
                                   File "/app/hardware/gpiochip/core.py", line 11, in createGPIOChip
                                     return GPIODChip(gpioConfig)
                                   File "/app/hardware/gpiochip/gpiod.py", line 23, in __init__
                                     self.chip = gpiod.Chip(gpio_config['chipName'])
                                   File "/usr/local/lib/python3.10/site-packages/gpiod/chip.py", line 58, in __init__
                                     self._chip = _ext.Chip(path)
                                 FileNotFoundError: [Errno 2] No such file or directory
2024-12-03 06:13:11,658 [INFO]: Starting backend waitress server
2024-12-03 06:13:11,658 [INFO]: Loading device "gpio-primary".
2024-12-03 06:13:11,637 [INFO]: ### STARTING API ###
2024-12-03 06:13:11,635 [INFO]: Loading microlab hardware configuration.
2024-12-03 06:13:11,634 [INFO]: ### STARTING MICROLAB HARDWARE CONTROLLER ###
2024-12-03 06:13:11,633 [INFO]: 
2024-12-03 06:13:11,627 [INFO]: ### STARTING MAIN MICROLAB SERVICE ###

I'm not really sure how to fix that

The changes I've done are in this branch

This should also probably go into another issue but the project is missing dependencies and all tests are passing.

@0phelia36
Copy link
Collaborator

Hello! Thanks for the issue.

The gpiod error you're running into is due to the fact that gpiod is not supposed to be installed via pip at the moment and instead has to be installed as a system package via apt to be used using sudo apt install python3-libgpiod. If you're just trying to run the code for development or testing you can instead go into the frontend, go to settings, and change the value of the lab hardware config dropdown to "simulation-pi" and that error will be avoided as it won't attempt to import and use gpiod to control the state of the gpio pins, and will instead use stub functions for gpio control that basically do nothing.

I don't think anyone has run the project with docker in a while so it might take some work to get that fully running, at the very least the docker-compose file will need to add volumes mounted for /etc/microlab and /var/lib/microlab for the microlabs configuration and recipe data to persist, not sure if there's anything else that's changed that might cause issues.

@phaseloop
Copy link
Contributor

I'll try to run it and fix those errors. @suspiciousRaccoon this "No such file or directory" error may be caused by GPIO device being unavailable. Are you running this on raspberry? If so - did you enable raspberry GPIO support/driver and uncomment docker-compose path mapping?

@phaseloop
Copy link
Contributor

Will be fixed by #296

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

No branches or pull requests

3 participants