hassio-addons / addon-appdaemon

AppDaemon4 - Home Assistant Community Add-ons
https://addons.community
MIT License
151 stars 47 forks source link

Cache system/python packages #237

Closed chatziko closed 1 year ago

chatziko commented 1 year ago

Proposed Changes

The AppDaemon addon re-installs user-configured system and python packages on every restart. Apart from being slow, this has the serious drawback of completely breaking the setup if no internet connection is available (going completely against the HA philosophy).

With this PR package installation happens in two phases:

  1. Packages with their dependencies are downloaded into /data/package-cache/{apk,pip} using apk fetch and pip download.
  2. Packages are installed from the cache.

The first step is skipped if the cache already exists, so future restarts are fast and require no internet connection.

To increase robustness:

  1. The cache is tagged with the exact addon version and package list (file /data/package-cache/{apk,pip}/tag). So if the addon is upgraded, or the package list changes, the full cache is rebuilt, avoiding issues with old cached packages.
  2. If the installation fails the cache is cleared, to allow recovering from errors.

Related Issues

235 #216

chatziko commented 1 year ago

I'm all for adding a way to get it running without internet, but I'm not a fan of this approach. It is way too hacky and funky for me to consider adding.

You mean the general approach of caching packages? What would be a better approach, given the constraints of the addon system?

frenck commented 1 year ago

What would be a better approach

I dunno, but the current offered solution in this PR is not something I'm consider to add.

chatziko commented 1 year ago

In case you want to reconsider:

If you want other changes I'd be happy to implement them. If nothing can make you reconsider, well... one more fork to maintain :smile:

PS. In any case, many thanks for your amazing work on HA!

github-actions[bot] commented 1 year ago

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.