Speed up library loading with shared runtime checks and browser cache
This commit is contained in:
@@ -287,9 +287,21 @@ class Handler(BaseHTTPRequestHandler):
|
||||
allowed.update(filter(None,os.environ.get('DECK_ALLOWED_HOSTS','').split(',')))
|
||||
return self.headers.get('Host') in allowed
|
||||
|
||||
def execution_setup(self, model, profile=None):
|
||||
installed={'stt':bool(self.server.runtime.status().get('active')),'chat':bool(self.server.runtime.status().get('active')),'image':self.server.image_runtime.status().get('installed',False),'audio':self.server.tts_runtime.status().get('installed',False),'video':self.server.video.status()['runtime']['installed'],'audio_cpp':self.server.audio_cpp_runtime.status()['installed'],'music_worker':True}
|
||||
return execution_assess(model,installed,profile)
|
||||
def execution_runtime_snapshot(self):
|
||||
# Installation checks need no video model/profile scan or worker status.
|
||||
chat = bool(self.server.runtime.status().get('active'))
|
||||
video_runtime = (self.server.video.original_runtime
|
||||
if self.server.video.runtime_kind() == 'original'
|
||||
else self.server.video.runtime)
|
||||
return {'stt':chat,'chat':chat,
|
||||
'image':self.server.image_runtime.status().get('installed',False),
|
||||
'audio':self.server.tts_runtime.status().get('installed',False),
|
||||
'video':video_runtime.status().get('installed',False),
|
||||
'audio_cpp':self.server.audio_cpp_runtime.status()['installed'],
|
||||
'music_worker':True}
|
||||
|
||||
def execution_setup(self, model, profile=None, installed=None):
|
||||
return execution_assess(model, self.execution_runtime_snapshot() if installed is None else installed, profile)
|
||||
|
||||
def do_GET(self):
|
||||
if not self.valid_host():
|
||||
@@ -342,7 +354,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
except Exception:return self.respond({'error':'Komponentenquelle nicht erreichbar. Bitte erneut versuchen.'},503)
|
||||
if self.path == '/api/v1/profiles':
|
||||
data=self.server.profiles.status()
|
||||
for p in data['profiles']:p['execution']=self.execution_setup(p.get('model') or {},p)
|
||||
installed=self.execution_runtime_snapshot()
|
||||
for p in data['profiles']:p['execution']=self.execution_setup(p.get('model') or {},p,installed)
|
||||
return self.respond(data)
|
||||
if self.path == '/api/v1/huggingface':return self.respond(self.server.catalog.hub_auth.status())
|
||||
if self.path == '/api/v1/hardware':
|
||||
@@ -382,7 +395,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return self.respond(overview(data['files'],self.server.hardware.snapshot()))
|
||||
if path.path=='/api/v1/catalog/files':
|
||||
data=dict(self.server.catalog.files(q.get('repo',[''])[0]));hardware=self.server.hardware.snapshot()
|
||||
data['files']=[dict(f,assessment=assess(f['size'],hardware,f['name']),execution=self.execution_setup(dict(repo=data['repo'],revision=data['revision'],file=f['name'],kind=q.get('kind',['chat'])[0],runtime_metadata=data.get('runtime_metadata',{})))) for f in data['files']]
|
||||
installed=self.execution_runtime_snapshot()
|
||||
data['files']=[dict(f,assessment=assess(f['size'],hardware,f['name']),execution=self.execution_setup(dict(repo=data['repo'],revision=data['revision'],file=f['name'],kind=q.get('kind',['chat'])[0],runtime_metadata=data.get('runtime_metadata',{})),installed=installed)) for f in data['files']]
|
||||
from profiles import component_recipe
|
||||
from catalog import file_role
|
||||
for f in data['files']:
|
||||
@@ -393,8 +407,9 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return self.respond(data)
|
||||
if path.path=='/api/v1/catalog':
|
||||
data=self.server.catalog.status()
|
||||
installed=self.execution_runtime_snapshot()
|
||||
for entry in data['entries']:
|
||||
entry['execution']=self.execution_setup(entry)
|
||||
entry['execution']=self.execution_setup(entry,installed=installed)
|
||||
entry['used_by_profiles']=self.server.profiles.references(entry['id'])
|
||||
return self.respond(data)
|
||||
except Exception as exc:
|
||||
|
||||
Reference in New Issue
Block a user