Revert "Made copies of global scriptrunners, now we clear the copied scriptrunner of alwayson_scripts and only add back the ones that that were requested"
This reverts commit dfa258de5f
.
This commit is contained in:
parent
db602b100e
commit
f371579571
@ -3,7 +3,6 @@ import io
|
|||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import uvicorn
|
import uvicorn
|
||||||
import copy
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from gradio.processing_utils import decode_base64_to_file
|
from gradio.processing_utils import decode_base64_to_file
|
||||||
@ -203,7 +202,6 @@ class Api:
|
|||||||
script_args[0] = 0
|
script_args[0] = 0
|
||||||
|
|
||||||
# Now check for always on scripts
|
# Now check for always on scripts
|
||||||
alwayson_script_to_run = [] # list to replace the one from the global ScriptRunner we copied
|
|
||||||
if request.alwayson_scripts and (len(request.alwayson_scripts) > 0):
|
if request.alwayson_scripts and (len(request.alwayson_scripts) > 0):
|
||||||
for alwayson_script_name in request.alwayson_scripts.keys():
|
for alwayson_script_name in request.alwayson_scripts.keys():
|
||||||
alwayson_script = self.get_script(alwayson_script_name, script_runner)
|
alwayson_script = self.get_script(alwayson_script_name, script_runner)
|
||||||
@ -212,21 +210,13 @@ class Api:
|
|||||||
# Selectable script in always on script param check
|
# Selectable script in always on script param check
|
||||||
if alwayson_script.alwayson == False:
|
if alwayson_script.alwayson == False:
|
||||||
raise HTTPException(status_code=422, detail=f"Cannot have a selectable script in the always on scripts params")
|
raise HTTPException(status_code=422, detail=f"Cannot have a selectable script in the always on scripts params")
|
||||||
# all good, so add to run list and set its args if any
|
# always on script with no arg should always run so you don't really need to add them to the requests
|
||||||
alwayson_script_to_run.append(alwayson_script)
|
|
||||||
if "args" in request.alwayson_scripts[alwayson_script_name]:
|
if "args" in request.alwayson_scripts[alwayson_script_name]:
|
||||||
script_args[alwayson_script.args_from:alwayson_script.args_to] = request.alwayson_scripts[alwayson_script_name]["args"]
|
script_args[alwayson_script.args_from:alwayson_script.args_to] = request.alwayson_scripts[alwayson_script_name]["args"]
|
||||||
|
|
||||||
# Remove always on scripts that were not included in the request by resetting the script list in out ScriptRunner
|
|
||||||
script_runner.alwayson_scripts.clear()
|
|
||||||
script_runner.alwayson_scripts = alwayson_script_to_run
|
|
||||||
script_runner.scripts.clear()
|
|
||||||
script_runner.scripts = alwayson_script_to_run + script_runner.selectable_scripts
|
|
||||||
|
|
||||||
return script_args
|
return script_args
|
||||||
|
|
||||||
def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI):
|
def text2imgapi(self, txt2imgreq: StableDiffusionTxt2ImgProcessingAPI):
|
||||||
script_runner = copy.copy(scripts.scripts_txt2img) # copy so we don't overwrite our globals
|
script_runner = scripts.scripts_txt2img
|
||||||
if not script_runner.scripts:
|
if not script_runner.scripts:
|
||||||
script_runner.initialize_scripts(False)
|
script_runner.initialize_scripts(False)
|
||||||
ui.create_ui()
|
ui.create_ui()
|
||||||
@ -278,7 +268,7 @@ class Api:
|
|||||||
if mask:
|
if mask:
|
||||||
mask = decode_base64_to_image(mask)
|
mask = decode_base64_to_image(mask)
|
||||||
|
|
||||||
script_runner = copy.copy(scripts.scripts_img2img) # copy so we don't overwrite our globals
|
script_runner = scripts.scripts_img2img
|
||||||
if not script_runner.scripts:
|
if not script_runner.scripts:
|
||||||
script_runner.initialize_scripts(True)
|
script_runner.initialize_scripts(True)
|
||||||
ui.create_ui()
|
ui.create_ui()
|
||||||
|
Loading…
Reference in New Issue
Block a user