Allow deleting unused library files with profile guards
This commit is contained in:
@@ -143,6 +143,9 @@ class Profiles:
|
||||
if kind in ('image','video') and (params['width']%64 or params['height']%64):raise ValueError('Breite und Höhe müssen durch 64 teilbar sein.')
|
||||
if kind=='chat' and params['ubatch']>params['batch']:raise ValueError('Microbatch darf nicht größer als Batch sein.')
|
||||
with self.lock:
|
||||
# Recheck under the profile lock so a concurrent library deletion cannot
|
||||
# leave a newly saved profile pointing at a removed file.
|
||||
self.catalog.entry(data['model_id'])
|
||||
existing=next((p for p in self.rows if p['id']==data['id']),None)
|
||||
if data['id'] is not None and not existing:raise ValueError('Profil nicht gefunden.')
|
||||
if data['revision']!=(existing['revision'] if existing else 0):raise ValueError('Profil wurde zwischenzeitlich geändert. Ansicht neu laden.')
|
||||
@@ -154,6 +157,12 @@ class Profiles:
|
||||
temp=self.path.with_suffix('.tmp');temp.write_text(json.dumps(rows));temp.replace(self.path);self.rows=rows
|
||||
return row
|
||||
|
||||
def references(self,model_id):
|
||||
with self.lock:
|
||||
return [dict(id=p['id'],name=p['name'],kind=p['kind']) for p in self.rows
|
||||
if model_id in (p.get('model_id'),p.get('parameters',{}).get('vision_projector'))
|
||||
or model_id in (p.get('components') or {}).values()]
|
||||
|
||||
def configure_prompt_enhancer(self,data):
|
||||
if not isinstance(data,dict) or set(data)!={'id','revision','prompt_enhancer'}:raise ValueError('Ungültige Prompt-Aufwerter-Einstellung.')
|
||||
config=data['prompt_enhancer']
|
||||
|
||||
Reference in New Issue
Block a user