load extensions' git metadata in parallel to loading the main program to save a ton of time during startup
This commit is contained in:
parent
0d3a80e269
commit
0d2a4b608c
@ -83,6 +83,8 @@ def get_extension_config():
|
|||||||
ext_config = {}
|
ext_config = {}
|
||||||
|
|
||||||
for ext in extensions.extensions:
|
for ext in extensions.extensions:
|
||||||
|
ext.read_info_from_repo()
|
||||||
|
|
||||||
entry = {
|
entry = {
|
||||||
"name": ext.name,
|
"name": ext.name,
|
||||||
"path": ext.path,
|
"path": ext.path,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@ -24,6 +25,8 @@ def active():
|
|||||||
|
|
||||||
|
|
||||||
class Extension:
|
class Extension:
|
||||||
|
lock = threading.Lock()
|
||||||
|
|
||||||
def __init__(self, name, path, enabled=True, is_builtin=False):
|
def __init__(self, name, path, enabled=True, is_builtin=False):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.path = path
|
self.path = path
|
||||||
@ -42,8 +45,13 @@ class Extension:
|
|||||||
if self.is_builtin or self.have_info_from_repo:
|
if self.is_builtin or self.have_info_from_repo:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.have_info_from_repo = True
|
with self.lock:
|
||||||
|
if self.have_info_from_repo:
|
||||||
|
return
|
||||||
|
|
||||||
|
self.do_read_info_from_repo()
|
||||||
|
|
||||||
|
def do_read_info_from_repo(self):
|
||||||
repo = None
|
repo = None
|
||||||
try:
|
try:
|
||||||
if os.path.exists(os.path.join(self.path, ".git")):
|
if os.path.exists(os.path.join(self.path, ".git")):
|
||||||
@ -70,6 +78,8 @@ class Extension:
|
|||||||
print(f"Failed reading extension data from Git repository ({self.name}): {ex}", file=sys.stderr)
|
print(f"Failed reading extension data from Git repository ({self.name}): {ex}", file=sys.stderr)
|
||||||
self.remote = None
|
self.remote = None
|
||||||
|
|
||||||
|
self.have_info_from_repo = True
|
||||||
|
|
||||||
def list_files(self, subdir, extension):
|
def list_files(self, subdir, extension):
|
||||||
from modules import scripts
|
from modules import scripts
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
import threading
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import traceback
|
import traceback
|
||||||
@ -484,11 +485,18 @@ def refresh_available_extensions_from_data(hide_tags, sort_column, filter_text="
|
|||||||
return code, list(tags)
|
return code, list(tags)
|
||||||
|
|
||||||
|
|
||||||
|
def preload_extensions_git_metadata():
|
||||||
|
for extension in extensions.extensions:
|
||||||
|
extension.read_info_from_repo()
|
||||||
|
|
||||||
|
|
||||||
def create_ui():
|
def create_ui():
|
||||||
import modules.ui
|
import modules.ui
|
||||||
|
|
||||||
config_states.list_config_states()
|
config_states.list_config_states()
|
||||||
|
|
||||||
|
threading.Thread(target=preload_extensions_git_metadata).start()
|
||||||
|
|
||||||
with gr.Blocks(analytics_enabled=False) as ui:
|
with gr.Blocks(analytics_enabled=False) as ui:
|
||||||
with gr.Tabs(elem_id="tabs_extensions"):
|
with gr.Tabs(elem_id="tabs_extensions"):
|
||||||
with gr.TabItem("Installed", id="installed"):
|
with gr.TabItem("Installed", id="installed"):
|
||||||
@ -508,7 +516,8 @@ def create_ui():
|
|||||||
</span>
|
</span>
|
||||||
"""
|
"""
|
||||||
info = gr.HTML(html)
|
info = gr.HTML(html)
|
||||||
extensions_table = gr.HTML(lambda: extension_table())
|
extensions_table = gr.HTML('Loading...')
|
||||||
|
ui.load(fn=extension_table, inputs=[], outputs=[extensions_table])
|
||||||
|
|
||||||
apply.click(
|
apply.click(
|
||||||
fn=apply_and_restart,
|
fn=apply_and_restart,
|
||||||
@ -595,7 +604,8 @@ def create_ui():
|
|||||||
config_save_button = gr.Button(value="Save Current Config")
|
config_save_button = gr.Button(value="Save Current Config")
|
||||||
|
|
||||||
config_states_info = gr.HTML("")
|
config_states_info = gr.HTML("")
|
||||||
config_states_table = gr.HTML(lambda: update_config_states_table("Current"))
|
config_states_table = gr.HTML("Loading...")
|
||||||
|
ui.load(fn=update_config_states_table, inputs=[config_states_list], outputs=[config_states_table])
|
||||||
|
|
||||||
config_save_button.click(fn=save_config_state, inputs=[config_save_name], outputs=[config_states_list, config_states_info])
|
config_save_button.click(fn=save_config_state, inputs=[config_save_name], outputs=[config_states_list, config_states_info])
|
||||||
|
|
||||||
@ -608,4 +618,5 @@ def create_ui():
|
|||||||
outputs=[config_states_table],
|
outputs=[config_states_table],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
return ui
|
return ui
|
||||||
|
Loading…
Reference in New Issue
Block a user