fusion44 / blitz_api

A management backend for the RaspiBlitz project written in Python / FastAPI
MIT License
19 stars 18 forks source link

Abstract platform implementations away #149

Closed fusion44 closed 1 year ago

fusion44 commented 2 years ago

Currently RaspiBlitz platform "bleeds" into native python platform a lot which leads to undesired behaviour and spaghetti code. Abstract away the code for each platform so the don't intermingle.

See https://github.com/fusion44/blitz_api/issues/143 ToDo:

lgtm-com[bot] commented 2 years ago

This pull request introduces 3 alerts and fixes 13 when merging e67b07299b0a34bf1fc045c0df41efd6a31956fa into 4408a6a58cb5e5ac94f8cf41e109bb33df58c39c - view on LGTM.com

new alerts:

fixed alerts:

lgtm-com[bot] commented 2 years ago

This pull request introduces 3 alerts and fixes 13 when merging b181c86b2e97ff241fb0ca1106aa61e6d4f6dcca into a4e9f7bf23e4b30e67aef3fb3c0208c11a2f1cd3 - view on LGTM.com

new alerts:

fixed alerts:

lgtm-com[bot] commented 1 year ago

This pull request introduces 3 alerts and fixes 13 when merging 799eb8deeff93a6a6c89c725b4fb3b33cd9e5a44 into 4f5216b502765ce7edf69b639d9abc19e45f2061 - view on LGTM.com

new alerts:

fixed alerts:

lgtm-com[bot] commented 1 year ago

This pull request introduces 11 alerts and fixes 14 when merging e3f0350c72384f7be8cceb39f085443ca1a35253 into 967a174c17b7e450e7a1b8baeab6b022e874b0ed - view on LGTM.com

new alerts:

fixed alerts:

lgtm-com[bot] commented 1 year ago

This pull request introduces 8 alerts and fixes 15 when merging 04eadf9caadf35704967c988f1bb68b125d6851f into 967a174c17b7e450e7a1b8baeab6b022e874b0ed - view on LGTM.com

new alerts:

fixed alerts:

lgtm-com[bot] commented 1 year ago

This pull request introduces 8 alerts and fixes 15 when merging 3ab007138ed685a12531b9f48f70b6a58ab033ea into 967a174c17b7e450e7a1b8baeab6b022e874b0ed - view on LGTM.com

new alerts:

fixed alerts:

fusion44 commented 1 year ago

@rootzoll @cstenglein This should be pretty much ready, please test. From my tests everything should work as expected. I can't really test the setup part right now though.

lgtm-com[bot] commented 1 year ago

This pull request introduces 8 alerts and fixes 15 when merging f06d84c29f0c585fa7dbbd685c512d2fa865ba81 into 967a174c17b7e450e7a1b8baeab6b022e874b0ed - view on LGTM.com

new alerts:

fixed alerts:

lgtm-com[bot] commented 1 year ago

This pull request introduces 8 alerts and fixes 15 when merging 36e2d525b7b0b0ceffe45f01178338be839a3a02 into 967a174c17b7e450e7a1b8baeab6b022e874b0ed - view on LGTM.com

new alerts:

fixed alerts:

lgtm-com[bot] commented 1 year ago

This pull request introduces 6 alerts and fixes 15 when merging 2053f0ea3b8ff4374b7903d2d25cda4e8df99dd3 into 967a174c17b7e450e7a1b8baeab6b022e874b0ed - view on LGTM.com

new alerts:

fixed alerts:

ChuckNorrison commented 1 year ago

@rootzoll @cstenglein This should be pretty much ready, please test. From my tests everything should work as expected. I can't really test the setup part right now though.

i tried to test the branch on my pi by removing the api and install manually with the requirements.txt fix. After login into the webinterface it ends on a white page. No errors in journal found.

i think the web and api branches are not compatible

maybe this can help to get the webui fixed

cstenglein commented 1 year ago

Thanks for testing @ChuckNorrison !

when using this branch from the webui, the screen should appear again. will need to test refresh token & setup though.

https://github.com/cstenglein/raspiblitz-web/pull/505

cstenglein commented 1 year ago

Tried to install this branch with the 1.8.0c image:


--- Logging error ---
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/utils/logging.py", line 177, in emit
    self.console.print(renderable, overflow="ignore", crop=False, style=style)
  File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/rich/console.py", line 1752, in print
    extend(render(renderable, render_options))
  File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/rich/console.py", line 1390, in render
    for render_output in iter_render:
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/utils/logging.py", line 134, in __rich_console__
    for line in lines:
  File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/rich/segment.py", line 245, in split_lines
    for segment in segments:
  File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/rich/console.py", line 1368, in render
    renderable = rich_cast(renderable)
  File "/usr/local/lib/python3.9/dist-packages/pip/_vendor/rich/protocol.py", line 36, in rich_cast
    renderable = cast_method()
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/self_outdated_check.py", line 130, in __rich__
    pip_cmd = get_best_invocation_for_this_pip()
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/utils/entrypoints.py", line 58, in get_best_invocation_for_this_pip
    if found_executable and os.path.samefile(
  File "/usr/lib/python3.9/genericpath.py", line 101, in samefile
    s2 = os.stat(f2)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/pip3.9'
Call stack:
  File "/usr/local/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/main.py", line 70, in main
    return command.main(cmd_args)
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/base_command.py", line 101, in main
    return self._main(args)
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/base_command.py", line 223, in _main
    self.handle_pip_version_check(options)
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/cli/req_command.py", line 148, in handle_pip_version_check
    pip_self_version_check(session, options)
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/self_outdated_check.py", line 237, in pip_self_version_check
    logger.info("[present-rich] %s", upgrade_prompt)
  File "/usr/lib/python3.9/logging/__init__.py", line 1442, in info
    self._log(INFO, msg, args, **kwargs)
  File "/usr/lib/python3.9/logging/__init__.py", line 1585, in _log
    self.handle(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 1595, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 1657, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.9/logging/__init__.py", line 948, in handle
    self.emit(record)
  File "/usr/local/lib/python3.9/dist-packages/pip/_internal/utils/logging.py", line 179, in emit
    self.handleError(record)
Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.1.2', new='22.3.1'),)
error='pip install failed'
fusion44 commented 1 year ago

Tried to install this branch with the 1.8.0c image:

--- Logging error ---
...

This should be fixed with this issue: https://github.com/fusion44/blitz_api/issues/161#issuecomment-1324037652

cstenglein commented 1 year ago

Updated to this branch with the latest dev image & restarted.

API failed with the following error:

Nov 28 06:37:22 raspberrypi systemd[1]: Started BlitzBackendAPI.
Nov 28 06:37:25 raspberrypi python[39690]: Traceback (most recent call last):
Nov 28 06:37:25 raspberrypi python[39690]:   File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
Nov 28 06:37:25 raspberrypi python[39690]:     return _run_code(code, main_globals, None,
Nov 28 06:37:25 raspberrypi python[39690]:   File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
Nov 28 06:37:25 raspberrypi python[39690]:     exec(code, run_globals)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/uvicorn/__main__.py", line 4, in <module>
Nov 28 06:37:25 raspberrypi python[39690]:     uvicorn.main()
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
Nov 28 06:37:25 raspberrypi python[39690]:     return self.main(*args, **kwargs)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
Nov 28 06:37:25 raspberrypi python[39690]:     rv = self.invoke(ctx)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
Nov 28 06:37:25 raspberrypi python[39690]:     return ctx.invoke(self.callback, **ctx.params)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
Nov 28 06:37:25 raspberrypi python[39690]:     return __callback(*args, **kwargs)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/uvicorn/main.py", line 408, in main
Nov 28 06:37:25 raspberrypi python[39690]:     run(
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/uvicorn/main.py", line 576, in run
Nov 28 06:37:25 raspberrypi python[39690]:     server.run()
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
Nov 28 06:37:25 raspberrypi python[39690]:     return asyncio.run(self.serve(sockets=sockets))
Nov 28 06:37:25 raspberrypi python[39690]:   File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
Nov 28 06:37:25 raspberrypi python[39690]:     return loop.run_until_complete(main)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
Nov 28 06:37:25 raspberrypi python[39690]:     return future.result()
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/uvicorn/server.py", line 67, in serve
Nov 28 06:37:25 raspberrypi python[39690]:     config.load()
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/uvicorn/config.py", line 479, in load
Nov 28 06:37:25 raspberrypi python[39690]:     self.loaded_app = import_from_string(self.app)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/home/blitzapi/blitz_api/venv/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
Nov 28 06:37:25 raspberrypi python[39690]:     module = importlib.import_module(module_str)
Nov 28 06:37:25 raspberrypi python[39690]:   File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
Nov 28 06:37:25 raspberrypi python[39690]:     return _bootstrap._gcd_import(name[level:], package, level)
Nov 28 06:37:25 raspberrypi python[39690]:   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
Nov 28 06:37:25 raspberrypi python[39690]:   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
Nov 28 06:37:25 raspberrypi python[39690]:   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
Nov 28 06:37:25 raspberrypi python[39690]:   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
Nov 28 06:37:25 raspberrypi python[39690]:   File "<frozen importlib._bootstrap_external>", line 790, in exec_module
Nov 28 06:37:25 raspberrypi python[39690]:   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
Nov 28 06:37:25 raspberrypi python[39690]:   File "./app/main.py", line 20, in <module>
Nov 28 06:37:25 raspberrypi python[39690]:     from app.api.warmup import (
Nov 28 06:37:25 raspberrypi python[39690]:   File "./app/api/warmup.py", line 6, in <module>
Nov 28 06:37:25 raspberrypi python[39690]:     from app.lightning.service import (
Nov 28 06:37:25 raspberrypi python[39690]:   File "./app/lightning/service.py", line 59, in <module>
Nov 28 06:37:25 raspberrypi python[39690]:     ln = LnNode()
Nov 28 06:37:25 raspberrypi python[39690]: NameError: name 'LnNode' is not defined
lgtm-com[bot] commented 1 year ago

This pull request introduces 8 alerts and fixes 16 when merging 05f686e32fc2fc70394b5d1a7135a9d7260beb05 into e256a166f89b626df3c6952d9a56c2a594a7e0a7 - view on LGTM.com

new alerts:

fixed alerts:

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine :gear: that powers LGTM.com. For more information, please check out our post on the GitHub blog.

lgtm-com[bot] commented 1 year ago

This pull request introduces 8 alerts and fixes 16 when merging 36be181e77291da242de9b430285b9fd05011d1c into c328e1e5a37041c58a2f264dd053917bb5e0297e - view on LGTM.com

new alerts:

fixed alerts:

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine :gear: that powers LGTM.com. For more information, please check out our post on the GitHub blog.

fusion44 commented 1 year ago

Closing this PR as the branch will be renamed to dev and will live on.