Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle error #317

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions bizyair_extras/nodes_trellis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ class BizyAir_IF_TrellisCheckpointLoader(BizyAirBaseNode):
@classmethod
def INPUT_TYPES(cls):
"""Define input types with device-specific options."""
device_options = []
if torch.cuda.is_available():
device_options.append("cuda")
if hasattr(torch.backends, "mps") and torch.backends.mps.is_available():
device_options.append("mps")
device_options.append("cpu")
device_options = ["cuda"]

return {
"required": {
Expand Down Expand Up @@ -201,5 +196,5 @@ def main(self, url, file_name):
return (output,)

@classmethod
def IS_CHANGED(self, url, file_name):
def IS_CHANGED(self, url, file_name, *args, **kwargs):
return uuid.uuid4().hex
24 changes: 23 additions & 1 deletion src/bizyair/common/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,34 @@ def send_request(
response_data = response.read().decode("utf-8")
except urllib.error.URLError as e:
error_message = str(e)
response_body = e.read().decode("utf-8") if hasattr(e, "read") else "N/A"
if verbose:
print(f"URLError encountered: {error_message}")
print(f"Response Body: {response_data}")
code, message = "N/A", "N/A"
try:
response_dict = json.loads(response_body)
if isinstance(response_dict, dict):
code = response_dict.get("code", "N/A")
message = response_dict.get("message", "N/A")

except json.JSONDecodeError:
if verbose:
print("Failed to decode response body as JSON.")

if "Unauthorized" in error_message:
raise PermissionError(
"Key is invalid, please refer to https://cloud.siliconflow.cn to get the API key.\n"
"If you have the key, please click the 'BizyAir Key' button at the bottom right to set the key."
"If you have the key, please click the 'API Key' button at the bottom right to set the key."
)
elif code != "N/A" and message != "N/A":
raise ConnectionError(
f"Failed to handle your request: {error_message}.\n"
+ f" Error code: {code}.\n"
+ f" Error message: {message}\n."
+ "The cause of this issue may be incorrect parameter status or ongoing background tasks. \n"
+ "If retrying after waiting for a while still does not resolve the issue, please report it to "
+ "Bizyair's official support."
)
else:
raise ConnectionError(
Expand Down
Loading