Don't git pull on "Install/update extensions requirements"

This commit is contained in:
oobabooga 2024-03-04 12:35:41 -08:00
parent fbe83854ca
commit 2d74660733

View File

@ -317,29 +317,30 @@ def install_extensions_requirements():
run_cmd(f"python -m pip install -r {extension_req_path} --upgrade", assert_success=False, environment=True)
def update_requirements(initial_installation=False):
def update_requirements(initial_installation=False, pull=True):
# Create .git directory if missing
if not os.path.exists(os.path.join(script_dir, ".git")):
git_creation_cmd = 'git init -b main && git remote add origin https://github.com/oobabooga/text-generation-webui && git fetch && git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main && git reset --hard origin/main && git branch --set-upstream-to=origin/main'
run_cmd(git_creation_cmd, environment=True, assert_success=True)
files_to_check = [
'start_linux.sh', 'start_macos.sh', 'start_windows.bat', 'start_wsl.bat',
'update_linux.sh', 'update_macos.sh', 'update_windows.bat', 'update_wsl.bat',
'one_click.py'
]
if pull:
print_big_message("Updating the local copy of the repository with \"git pull\"")
print_big_message("Updating the local copy of the repository with \"git pull\"")
files_to_check = [
'start_linux.sh', 'start_macos.sh', 'start_windows.bat', 'start_wsl.bat',
'update_linux.sh', 'update_macos.sh', 'update_windows.bat', 'update_wsl.bat',
'one_click.py'
]
before_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
run_cmd("git pull --autostash", assert_success=True, environment=True)
after_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
before_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
run_cmd("git pull --autostash", assert_success=True, environment=True)
after_pull_hashes = {file_name: calculate_file_hash(file_name) for file_name in files_to_check}
# Check for differences in installation file hashes
for file_name in files_to_check:
if before_pull_hashes[file_name] != after_pull_hashes[file_name]:
print_big_message(f"File '{file_name}' was updated during 'git pull'. Please run the script again.")
exit(1)
# Check for differences in installation file hashes
for file_name in files_to_check:
if before_pull_hashes[file_name] != after_pull_hashes[file_name]:
print_big_message(f"File '{file_name}' was updated during 'git pull'. Please run the script again.")
exit(1)
# Update PyTorch
if not initial_installation:
@ -427,7 +428,7 @@ if __name__ == "__main__":
update_requirements()
elif choice == 'B':
install_extensions_requirements()
update_requirements()
update_requirements(pull=False)
elif choice == 'C':
run_cmd("git reset --hard", assert_success=True, environment=True)
elif choice == 'N':