Skip to content

Commit

Permalink
add progressbar to extension update check; do not check for updates f…
Browse files Browse the repository at this point in the history
…or disabled extensions
  • Loading branch information
AUTOMATIC1111 committed Jan 28, 2023
1 parent d04e3e9 commit f8feeaa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
20 changes: 17 additions & 3 deletions javascript/extensions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

function extensions_apply(_, _){
disable = []
update = []
var disable = []
var update = []

gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){
if(x.name.startsWith("enable_") && ! x.checked)
disable.push(x.name.substr(7))
Expand All @@ -16,11 +17,24 @@ function extensions_apply(_, _){
}

function extensions_check(){
var disable = []

gradioApp().querySelectorAll('#extensions input[type="checkbox"]').forEach(function(x){
if(x.name.startsWith("enable_") && ! x.checked)
disable.push(x.name.substr(7))
})

gradioApp().querySelectorAll('#extensions .extension_status').forEach(function(x){
x.innerHTML = "Loading..."
})

return []

var id = randomId()
requestProgress(id, gradioApp().getElementById('extensions_installed_top'), null, function(){

})

return [id, JSON.stringify(disable)]
}

function install_extension_from_index(button, url){
Expand Down
28 changes: 18 additions & 10 deletions modules/ui_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import errno

from modules import extensions, shared, paths

from modules.call_queue import wrap_gradio_gpu_call

available_extensions = {"extensions": []}

Expand Down Expand Up @@ -50,20 +50,27 @@ def apply_and_restart(disable_list, update_list):
shared.state.need_restart = True


def check_updates():
def check_updates(id_task, disable_list):
check_access()

for ext in extensions.extensions:
if ext.remote is None:
continue
disabled = json.loads(disable_list)
assert type(disabled) == list, f"wrong disable_list data for apply_and_restart: {disable_list}"

exts = [ext for ext in extensions.extensions if ext.remote is not None and ext.name not in disabled]
shared.state.job_count = len(exts)

for ext in exts:
shared.state.textinfo = ext.name

try:
ext.check_updates()
except Exception:
print(f"Error checking updates for {ext.name}:", file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)

return extension_table()
shared.state.nextjob()

return extension_table(), ""


def extension_table():
Expand Down Expand Up @@ -273,12 +280,13 @@ def create_ui():
with gr.Tabs(elem_id="tabs_extensions") as tabs:
with gr.TabItem("Installed"):

with gr.Row():
with gr.Row(elem_id="extensions_installed_top"):
apply = gr.Button(value="Apply and restart UI", variant="primary")
check = gr.Button(value="Check for updates")
extensions_disabled_list = gr.Text(elem_id="extensions_disabled_list", visible=False).style(container=False)
extensions_update_list = gr.Text(elem_id="extensions_update_list", visible=False).style(container=False)

info = gr.HTML()
extensions_table = gr.HTML(lambda: extension_table())

apply.click(
Expand All @@ -289,10 +297,10 @@ def create_ui():
)

check.click(
fn=check_updates,
fn=wrap_gradio_gpu_call(check_updates, extra_outputs=[gr.update()]),
_js="extensions_check",
inputs=[],
outputs=[extensions_table],
inputs=[info, extensions_disabled_list],
outputs=[extensions_table, info],
)

with gr.TabItem("Available"):
Expand Down

0 comments on commit f8feeaa

Please sign in to comment.