InvokeAI
InvokeAI copied to clipboard
feat: updater
Summary
Similar to #6215, add update logic that fetches and runs the latest installer.
The main difference is that most of the logic in here is in a python script:
- Check for new releases/prereleases
- Advises user of current version and latest
- Asks user if they want to update - if so, download and unzip the latest installer
The python script then ends and the invoke script picks up. All it needs to do is check if the install script exists, and if so, run it and exit.
This works as expected for the macOS/linux invoke.sh script.
I ported the logic to powershell and it mostly works, but there is some wonkiness when invokeai-web and the update helper exit. Powershell doesn't handle errors and exit codes (like when you Ctrl+C) for these non-.NET scripts nicely.
Depending on the combination of $ErrorActionPreference and whether or not you redirect stderr to stdout, you either catch every raised python error (including handled ones, bc they end up in stderr...) or none, and have to use a finally block to handle the signal from the python script. You cannot just catch the Ctrl+C and pass, letting the invoke script continue. If this sounds confusing, that's because it is.
Anyways, I'll revisit the powershell script later, maybe just write it in the batch file instead. Won't be hard, I just really wanted the powershell script to work bc it's so much more intelligible than batch.
Related Issues / Discussions
#6215
QA Instructions
Testing this is a bit convoluted. Two options:
- Use a built installer
- Build an installer from this branch (e.g.
make installer-zip). - Copy the wheel and the installer zip to the destination host.
- Run the install script with
--wheel InvokeAI-4.2.0a3-py3-none-any.whlto install from the wheel. - You should then have access to
invokeai-webandinvokeai-update-helperin your PATH, and the invoke launcher should work and update
- Use an editable install
- Do a normal install from any version to set up the root dir scripts
- Check out this branch on the destination host
- Activate your normal install's venv
- Manually install (e.g.
pip install -e .) into the normal install's venv - Copy and paste the launcher scripts from the branch to the install root (e.g. copy
invoke.sh.intoinvoke.sh) - You should then have access to
invokeai-webandinvokeai-update-helperin your PATH, and the invoke launcher should work and update
Ok, so then to make this more annoying, once you successfully use the updater to install, you will necessarily end up with a venv that no longer has the update functionality. So to test again, you need to repeat those steps to re-install from this branch, with update functionality...
Merge Plan
This needs testing on multiple platforms (once the windows portion is working), and some coordination for releasing.
Checklist
- [x] The PR has a short but descriptive title, suitable for a changelog
- [ ] Tests added / updated (if applicable)
- [ ] Documentation added / updated (if applicable)
TODO
- [ ] Add an option to installer to ignore the pip cache. Should mitigate issues with troublesome packages like
controlnet_auxwhere sometimes a broken version is cached. See https://github.com/invoke-ai/InvokeAI/issues/6365#issuecomment-2111253020 - [ ] Consider making the launcher itself a python script. Would simplify the whole thing, but I'm unsure of the technicalities of activating a venv and running a python script within another python script.