Skip to content

Commit

Permalink
fix: handle get_all_models()'s requests.get call to github if netwo…
Browse files Browse the repository at this point in the history
…rk problems occur (#248)
  • Loading branch information
tazlin authored Jun 7, 2023
1 parent 550b0c3 commit da95d83
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions worker/bridge_data/stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,18 @@ def get_all_models(self, style=""):
return self._all_model_names[:]

logger.info("Refreshing the list of all available models")
data = requests.get(
"https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/stable_diffusion.json",
).json()
response = None
try:
response = requests.get(
url="https://raw.githubusercontent.com/Haidra-Org/AI-Horde-image-model-reference/main/stable_diffusion.json",
timeout=10,
)
response.raise_for_status()
except (requests.exceptions.RequestException, requests.exceptions.HTTPError) as e:
logger.error(f"Failed to retrieve the list of all available models: {e}")
return self.models_to_load if self.models_to_load else []

data = response.json()

# Get all interesting models
models = []
Expand Down

0 comments on commit da95d83

Please sign in to comment.