Skip WebUI prompt if --bridge passed, Detailed error messages if bridgeData.py fails to load (#1483)

# Description

Please include:
- [x] relevant motivation
- [x] a summary of the change
- [ ] which issue is fixed.
- [x] any additional dependencies that are required for this change.

Fixes a small typo of "Bridg" in horde_bridge.sh
Makes webui.sh skip asking for StreamLit/Gradio if --bridge is passed
More detailed error messages if bridgeData.py is missing/malformed
(previously it would only say no bridgeData found, which caused
confusion when bridgeData did exist but was incorrectly formatted)

# Checklist:

- [x] I have changed the base branch to `dev`
- [x] I have performed a self-review of my own code
- [x] I have commented my code in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation

Co-authored-by: mechanopixel <takatarumc@gmail.com>
This commit is contained in:
MechanoPixel 2022-10-11 19:23:04 +09:00 committed by GitHub
parent 994341efba
commit 2215a3b403
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 16 deletions

View File

@ -162,7 +162,7 @@ start_initialization () {
echo "Your model file does not exist! Place it in 'models/ldm/stable-diffusion-v1' with the name 'model.ckpt'." echo "Your model file does not exist! Place it in 'models/ldm/stable-diffusion-v1' with the name 'model.ckpt'."
exit 1 exit 1
fi fi
printf "\nStarting Stable Horde Bridg: Please Wait...\n"; python scripts/relauncher.py --bridge -v "$@"; break; printf "\nStarting Stable Horde Bridge: Please Wait...\n"; python scripts/relauncher.py --bridge -v "$@"; break;
} }

View File

@ -2783,22 +2783,33 @@ if __name__ == '__main__':
if opt.bridge: if opt.bridge:
try: try:
import bridgeData as cd import bridgeData as cd
except: except ModuleNotFoundError as e:
logger.warning("No bridgeData found. Falling back to default where no CLI args are set.")
logger.warning(str(e))
except SyntaxError as e:
logger.warning("bridgeData found, but is malformed. Falling back to default where no CLI args are set.")
logger.warning(str(e))
except Exception as e:
logger.warning("No bridgeData found, use default where no CLI args are set") logger.warning("No bridgeData found, use default where no CLI args are set")
class temp(object): logger.warning(str(e))
def __init__(self): finally:
random.seed() try: # check if cd exists (i.e. bridgeData loaded properly)
self.horde_url = "https://stablehorde.net" cd
# Give a cool name to your instance except: # if not, create defaults
self.horde_name = f"Automated Instance #{random.randint(-100000000, 100000000)}" class temp(object):
# The api_key identifies a unique user in the horde def __init__(self):
self.horde_api_key = "0000000000" random.seed()
# Put other users whose prompts you want to prioritize. self.horde_url = "https://stablehorde.net"
# The owner's username is always included so you don't need to add it here, unless you want it to have lower priority than another user # Give a cool name to your instance
self.horde_priority_usernames = [] self.horde_name = f"Automated Instance #{random.randint(-100000000, 100000000)}"
self.horde_max_power = 8 # The api_key identifies a unique user in the horde
self.nsfw = True self.horde_api_key = "0000000000"
cd = temp() # Put other users whose prompts you want to prioritize.
# The owner's username is always included so you don't need to add it here, unless you want it to have lower priority than another user
self.horde_priority_usernames = []
self.horde_max_power = 8
self.nsfw = True
cd = temp()
horde_api_key = opt.horde_api_key if opt.horde_api_key else cd.horde_api_key horde_api_key = opt.horde_api_key if opt.horde_api_key else cd.horde_api_key
horde_name = opt.horde_name if opt.horde_name else cd.horde_name horde_name = opt.horde_name if opt.horde_name else cd.horde_name
horde_url = opt.horde_url if opt.horde_url else cd.horde_url horde_url = opt.horde_url if opt.horde_url else cd.horde_url

View File

@ -154,6 +154,13 @@ post_processor_model_loading () {
# Show the user a prompt asking them which version of the WebUI they wish to use, Streamlit or Gradio # Show the user a prompt asking them which version of the WebUI they wish to use, Streamlit or Gradio
launch_webui () { launch_webui () {
# skip the prompt if --bridge command-line argument is detected
for arg in "$@"; do
if [ "$arg" == "--bridge" ]; then
python -u scripts/relauncher.py "$@"
return
fi
done
printf "\n\n########## LAUNCH USING STREAMLIT OR GRADIO? ##########\n\n" printf "\n\n########## LAUNCH USING STREAMLIT OR GRADIO? ##########\n\n"
printf "Do you wish to run the WebUI using the Gradio or StreamLit Interface?\n\n" printf "Do you wish to run the WebUI using the Gradio or StreamLit Interface?\n\n"
printf "Streamlit: \nHas A More Modern UI \nMore Features Planned \nWill Be The Main UI Going Forward \nCurrently In Active Development \nMissing Some Gradio Features\n\n" printf "Streamlit: \nHas A More Modern UI \nMore Features Planned \nWill Be The Main UI Going Forward \nCurrently In Active Development \nMissing Some Gradio Features\n\n"