mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Fix the configure script crash when no TTY is allocated (e.g. a container) (#2080)
* (config) avoid failure when huggingface token is not set it is not required for model download, and we are handling the saving of the token during huggingface authentication phase elsewhere. * (config) safely print to non-tty terminals where width can not be determined
This commit is contained in:
parent
1ba40db361
commit
ab2972f320
@ -212,7 +212,7 @@ def HfLogin(access_token) -> str:
|
|||||||
#-------------------------------Authenticate against Hugging Face
|
#-------------------------------Authenticate against Hugging Face
|
||||||
def authenticate(yes_to_all=False):
|
def authenticate(yes_to_all=False):
|
||||||
print('** LICENSE AGREEMENT FOR WEIGHT FILES **')
|
print('** LICENSE AGREEMENT FOR WEIGHT FILES **')
|
||||||
print("=" * os.get_terminal_size()[0])
|
print("=" * shutil.get_terminal_size()[0])
|
||||||
print('''
|
print('''
|
||||||
By downloading the Stable Diffusion weight files from the official Hugging Face
|
By downloading the Stable Diffusion weight files from the official Hugging Face
|
||||||
repository, you agree to have read and accepted the CreativeML Responsible AI License.
|
repository, you agree to have read and accepted the CreativeML Responsible AI License.
|
||||||
@ -221,7 +221,7 @@ The license terms are located here:
|
|||||||
https://huggingface.co/spaces/CompVis/stable-diffusion-license
|
https://huggingface.co/spaces/CompVis/stable-diffusion-license
|
||||||
|
|
||||||
''')
|
''')
|
||||||
print("=" * os.get_terminal_size()[0])
|
print("=" * shutil.get_terminal_size()[0])
|
||||||
|
|
||||||
if not yes_to_all:
|
if not yes_to_all:
|
||||||
accepted = False
|
accepted = False
|
||||||
@ -237,7 +237,7 @@ The license terms are located here:
|
|||||||
# Authenticate to Huggingface using environment variables.
|
# Authenticate to Huggingface using environment variables.
|
||||||
# If successful, authentication will persist for either interactive or non-interactive use.
|
# If successful, authentication will persist for either interactive or non-interactive use.
|
||||||
# Default env var expected by HuggingFace is HUGGING_FACE_HUB_TOKEN.
|
# Default env var expected by HuggingFace is HUGGING_FACE_HUB_TOKEN.
|
||||||
print("=" * os.get_terminal_size()[0])
|
print("=" * shutil.get_terminal_size()[0])
|
||||||
print('Authenticating to Huggingface')
|
print('Authenticating to Huggingface')
|
||||||
hf_envvars = [ "HUGGING_FACE_HUB_TOKEN", "HUGGINGFACE_TOKEN" ]
|
hf_envvars = [ "HUGGING_FACE_HUB_TOKEN", "HUGGINGFACE_TOKEN" ]
|
||||||
if not (access_token := HfFolder.get_token()):
|
if not (access_token := HfFolder.get_token()):
|
||||||
@ -294,7 +294,7 @@ You may re-run the configuration script again in the future if you do not wish t
|
|||||||
print()
|
print()
|
||||||
print(f"Re-run the configuration script without '--yes' to set the HuggingFace token interactively, or use one of the environment variables: {', '.join(hf_envvars)}")
|
print(f"Re-run the configuration script without '--yes' to set the HuggingFace token interactively, or use one of the environment variables: {', '.join(hf_envvars)}")
|
||||||
|
|
||||||
print("=" * os.get_terminal_size()[0])
|
print("=" * shutil.get_terminal_size()[0])
|
||||||
|
|
||||||
return access_token
|
return access_token
|
||||||
|
|
||||||
@ -330,13 +330,10 @@ def download_weight_datasets(models:dict, access_token:str):
|
|||||||
successful[mod] = True
|
successful[mod] = True
|
||||||
if len(successful) < len(models):
|
if len(successful) < len(models):
|
||||||
print(f'\n\n** There were errors downloading one or more files. **')
|
print(f'\n\n** There were errors downloading one or more files. **')
|
||||||
print('Please double-check your license agreements, and your access token.')
|
|
||||||
HfFolder.delete_token()
|
|
||||||
print('Press any key to try again. Type ^C to quit.\n')
|
print('Press any key to try again. Type ^C to quit.\n')
|
||||||
input()
|
input()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
HfFolder.save_token(access_token)
|
|
||||||
keys = ', '.join(successful.keys())
|
keys = ', '.join(successful.keys())
|
||||||
print(f'Successfully installed {keys}')
|
print(f'Successfully installed {keys}')
|
||||||
return successful
|
return successful
|
||||||
|
Loading…
x
Reference in New Issue
Block a user