cleanup/refactor state history

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-09-12 16:12:43 -04:00
parent a8b850adf4
commit 175e9cbe29
41 changed files with 172 additions and 171 deletions
+4 -2
View File
@@ -53,7 +53,7 @@ def download_diffusers_model(hub_id: str, cache_dir: str = None, download_config
if hub_id is None or len(hub_id) == 0:
return None
from diffusers import DiffusionPipeline
shared.state.begin('HuggingFace')
jobid = shared.state.begin('Download')
if hub_id.startswith('huggingface/'):
hub_id = hub_id.replace('huggingface/', '')
if download_config is None:
@@ -98,9 +98,11 @@ def download_diffusers_model(hub_id: str, cache_dir: str = None, download_config
debug(f'Diffusers download error: id="{hub_id}" {e}')
if 'gated' in str(e):
shared.log.error(f'Diffusers download error: id="{hub_id}" model access requires login')
shared.state.end(jobid)
return None
if pipeline_dir is None:
shared.log.error(f'Diffusers download error: id="{hub_id}" {err}')
shared.state.end(jobid)
return None
try:
model_info_dict = hf.model_info(hub_id).cardData if pipeline_dir is not None else None
@@ -113,7 +115,7 @@ def download_diffusers_model(hub_id: str, cache_dir: str = None, download_config
f.write("True")
if pipeline_dir is not None:
shared.writefile(model_info_dict, os.path.join(pipeline_dir, "model_info.json"))
shared.state.end()
shared.state.end(jobid)
return pipeline_dir