Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic committed Nov 11, 2023
1 parent 7f0827d commit 39085ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def gb(val: float):
process = psutil.Process(os.getpid())
res = process.memory_info()
ram_total = 100 * res.rss / process.memory_percent()
return f'used={gb(res.rss)} total={gb(ram_total)}'
return f'{gb(res.rss)}/{gb(ram_total)}'


def start_server(immediate=True, server=None):
Expand All @@ -145,7 +145,7 @@ def start_server(immediate=True, server=None):
if not immediate:
time.sleep(3)
if collected > 0:
installer.log.debug(f'Memory {get_memory_stats()} Collected {collected}')
installer.log.debug(f'Memory: {get_memory_stats()} collected={collected}')
module_spec = importlib.util.spec_from_file_location('webui', 'webui.py')
server = importlib.util.module_from_spec(module_spec)
installer.log.debug(f'Starting module: {server}')
Expand Down Expand Up @@ -233,7 +233,7 @@ def start_server(immediate=True, server=None):
if round(time.time()) % 120 == 0:
state = f'job="{instance.state.job}" {instance.state.job_no}/{instance.state.job_count}' if instance.state.job != '' or instance.state.job_no != 0 or instance.state.job_count != 0 else 'idle'
uptime = round(time.time() - instance.state.server_start)
installer.log.debug(f'Server alive={alive} jobs={instance.state.total_jobs} requests={requests} uptime={uptime} memory {get_memory_stats()} {state}')
installer.log.debug(f'Server: alive={alive} jobs={instance.state.total_jobs} requests={requests} uptime={uptime} memory={get_memory_stats()} backend={instance.backend} {state}')
if not alive:
if uv is not None and uv.wants_restart:
installer.log.info('Server restarting...')
Expand Down
9 changes: 6 additions & 3 deletions modules/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,11 +1239,14 @@ def webpath(fn):


def html_head():
script_js = os.path.join(script_path, "javascript", "script.js")
head = f'<script type="text/javascript" src="{webpath(script_js)}"></script>\n'
head = ''
main = ['script.js']
for js in main:
script_js = os.path.join(script_path, "javascript", js)
head += f'<script type="text/javascript" src="{webpath(script_js)}"></script>\n'
added = []
for script in modules.scripts.list_scripts("javascript", ".js"):
if script.path == script_js:
if script.filename in main:
continue
head += f'<script type="text/javascript" src="{webpath(script.path)}"></script>\n'
added.append(script.path)
Expand Down
3 changes: 2 additions & 1 deletion webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
pass

state = shared.state
backend = shared.backend
if not modules.loader.initialized:
timer.startup.record("libraries")
log.setLevel(logging.DEBUG if cmd_opts.debug else logging.INFO)
Expand Down Expand Up @@ -274,7 +275,7 @@ def start_ui():
shared.log.info(f'API Docs: {local_url[:-1]}/docs') # pylint: disable=unsubscriptable-object
if share_url is not None:
shared.log.info(f'Share URL: {share_url}')
shared.log.debug(f'Gradio registered functions: {len(shared.demo.fns)}')
shared.log.debug(f'Gradio functions: registered={len(shared.demo.fns)}')
shared.demo.server.wants_restart = False
setup_middleware(app, cmd_opts)

Expand Down

0 comments on commit 39085ab

Please sign in to comment.