Unify CLI patches for ease of editing
NUROISEA opened this issue · 0 comments
Problem
literally the same as #2 but for the !sed
commands
Currently the colab needs some patches so the notebook doesn't ^C
unexpectedly, so the following commands are required:
!sed -i -e '''/ prepare_environment()/a\ os.system\(f\"""sed -i -e ''\"s/self.logvar\\[t\\]/self.logvar\\[t.item()\\]/g\"'' /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py""")''' /content/stable-diffusion-webui/launch.py
!sed -i -e '''/ prepare_environment()/a\ os.system\(f\"""sed -i -e ''\"s/dict()))$/dict())).cuda()/gm\"'' /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py""")''' /content/stable-diffusion-webui/launch.py
Also since we are not using the latest commit of the webui, the ff is required for it to even launch:
!echo "fastapi==0.90.1" >> /content/stable-diffusion-webui/requirements_versions.txt
But what if I want to have the two-shot extension, and it requires another patch:
!git apply --ignore-whitespace extensions/stable-diffusion-webui-two-shot/cfg_denoised_callback-ea9bd9fc.patch
But what if we update the webui and we won't need that fastapi version, do we edit all notebooks again?
Solution (?)
Add those patches in configs/utility.py
.
patches = [
"paaaaaaaaaaaaaaaaaaaaaaatch",
]
But how do we deal with !sed
commands? I'm too lazy to escape everything and minor editing would be a pain in the ass.
Add a new file configs/patch_list.txt
which contains everything:
sed [...]
sed [,,,]
echo [,,,]
Probably figure out a way to fetch from a url and change the notebooks to this:
for patch in utility.patches:
!{patch}
and configs/utility.py
to this:
# hypothetical function to fetch a text file and return an array of lines
patches = fetch_text_file("configs/patch_list.txt")