Read production LoRA names in Studio 2
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""Export only LoRA labels/triggers; invoked by the host's catalog change watcher."""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
def export(source, destination):
|
||||
catalog = json.loads(Path(source).read_text())
|
||||
result = {key: {name: value for name, value in catalog.get(key, {}).items()
|
||||
if isinstance(value, str)} for key in ('loraAliases', 'loraTriggers')}
|
||||
target = Path(destination)
|
||||
content = json.dumps(result, ensure_ascii=False)
|
||||
if target.exists() and target.read_text() == content:
|
||||
return
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
temporary = target.with_suffix('.tmp')
|
||||
temporary.write_text(content)
|
||||
os.chmod(temporary, 0o644)
|
||||
temporary.replace(target)
|
||||
|
||||
if __name__ == '__main__':
|
||||
export(*sys.argv[1:])
|
||||
Reference in New Issue
Block a user