mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-05-06 16:36:45 -03:00
Compare commits
15 Commits
ba3f15dbc6
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6dd6938b0 | ||
|
|
727d0ef043 | ||
|
|
9344d86332 | ||
|
|
d36b16c213 | ||
|
|
33a7f07558 | ||
|
|
4f599aeced | ||
|
|
30db8c3d1d | ||
|
|
05636712f0 | ||
|
|
d8e5fe1247 | ||
|
|
3e9210394a | ||
|
|
4dd2c0526f | ||
|
|
9bdb337962 | ||
|
|
f93baf5fc0 | ||
|
|
14cb7fec47 | ||
|
|
f3b3e0adad |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,6 +15,7 @@ model_cache/
|
||||
# agent
|
||||
.opencode/
|
||||
.claude/
|
||||
.codex
|
||||
|
||||
# Vue widgets development cache (but keep build output)
|
||||
vue-widgets/node_modules/
|
||||
|
||||
@@ -9,17 +9,17 @@
|
||||
"Insomnia Art Designs",
|
||||
"megakirbs",
|
||||
"Brennok",
|
||||
"wackop",
|
||||
"2018cfh",
|
||||
"W+K+White",
|
||||
"wackop",
|
||||
"Takkan",
|
||||
"stone9k",
|
||||
"Carl G.",
|
||||
"$MetaSamsara",
|
||||
"itismyelement",
|
||||
"onesecondinosaur",
|
||||
"Carl G.",
|
||||
"stone9k",
|
||||
"Rosenthal",
|
||||
"Francisco Tatis",
|
||||
"Tobi_Swagg",
|
||||
"Andrew Wilson",
|
||||
"Greybush",
|
||||
"Gooohokrbe",
|
||||
@@ -29,18 +29,16 @@
|
||||
"VantAI",
|
||||
"runte3221",
|
||||
"FreelancerZ",
|
||||
"Julian V",
|
||||
"Edgar Tejeda",
|
||||
"Birdy",
|
||||
"Liam MacDougal",
|
||||
"Fraser Cross",
|
||||
"Polymorphic Indeterminate",
|
||||
"Birdy",
|
||||
"Marc Whiffen",
|
||||
"Kiba",
|
||||
"Jorge Hussni",
|
||||
"Reno Lam",
|
||||
"Kiba",
|
||||
"Skalabananen",
|
||||
"esthe",
|
||||
"Reno Lam",
|
||||
"sig",
|
||||
"Christian Byrne",
|
||||
"DM",
|
||||
@@ -49,24 +47,22 @@
|
||||
"J\\B/ 8r0wns0n",
|
||||
"Snaggwort",
|
||||
"Arlecchino Shion",
|
||||
"Charles Blakemore",
|
||||
"Rob Williams",
|
||||
"ClockDaemon",
|
||||
"KD",
|
||||
"Omnidex",
|
||||
"Tyler Trebuchon",
|
||||
"Release Cabrakan",
|
||||
"confiscated Zyra",
|
||||
"Tobi_Swagg",
|
||||
"SG",
|
||||
"carozzz",
|
||||
"James Dooley",
|
||||
"zenbound",
|
||||
"Buzzard",
|
||||
"jmack",
|
||||
"Adam Shaw",
|
||||
"Tee Gee",
|
||||
"Mark Corneglio",
|
||||
"SarcasticHashtag",
|
||||
"Anthony Rizzo",
|
||||
"tarek helmi",
|
||||
"Cosmosis",
|
||||
"iamresist",
|
||||
"RedrockVP",
|
||||
@@ -75,45 +71,34 @@
|
||||
"James Todd",
|
||||
"Steven Pfeiffer",
|
||||
"Tim",
|
||||
"Timmy",
|
||||
"Johnny",
|
||||
"Lisster",
|
||||
"Michael Wong",
|
||||
"Illrigger",
|
||||
"whudunit",
|
||||
"Tom Corrigan",
|
||||
"JackieWang",
|
||||
"fnkylove",
|
||||
"Julian V",
|
||||
"Steven Owens",
|
||||
"Yushio",
|
||||
"Vik71it",
|
||||
"lh qwe",
|
||||
"Echo",
|
||||
"Lilleman",
|
||||
"Robert Stacey",
|
||||
"PM",
|
||||
"Todd Keck",
|
||||
"Briton Heilbrun",
|
||||
"Mozzel",
|
||||
"Gingko Biloba",
|
||||
"Felipe dos Santos",
|
||||
"Penfore",
|
||||
"BadassArabianMofo",
|
||||
"Sterilized",
|
||||
"BadassArabianMofo",
|
||||
"Pascal Dahle",
|
||||
"Markus",
|
||||
"quarz",
|
||||
"Greg",
|
||||
"Douglas Gaspar",
|
||||
"Penfore",
|
||||
"JSST",
|
||||
"AlexDuKaNa",
|
||||
"George",
|
||||
"esthe",
|
||||
"lmsupporter",
|
||||
"Phil",
|
||||
"Charles Blakemore",
|
||||
"IamAyam",
|
||||
"wfpearl",
|
||||
"Rob Williams",
|
||||
"Baekdoosixt",
|
||||
"Jonathan Ross",
|
||||
"Jack B Nimble",
|
||||
@@ -125,127 +110,118 @@
|
||||
"contrite831",
|
||||
"Alex",
|
||||
"bh",
|
||||
"confiscated Zyra",
|
||||
"Marlon Daniels",
|
||||
"Starkselle",
|
||||
"Aaron Bleuer",
|
||||
"LacesOut!",
|
||||
"Graham Colehour",
|
||||
"greebles",
|
||||
"Adam Shaw",
|
||||
"Tee Gee",
|
||||
"Anthony Rizzo",
|
||||
"tarek helmi",
|
||||
"M Postkasse",
|
||||
"Tomohiro Baba",
|
||||
"David Ortega",
|
||||
"ASLPro3D",
|
||||
"Jacob Hoehler",
|
||||
"FinalyFree",
|
||||
"Weasyl",
|
||||
"Lex Song",
|
||||
"Timmy",
|
||||
"Johnny",
|
||||
"Cory Paza",
|
||||
"Tak",
|
||||
"Gonzalo Andre Allendes Lopez",
|
||||
"Zach Gonser",
|
||||
"Big Red",
|
||||
"Jimmy Ledbetter",
|
||||
"whudunit",
|
||||
"Luc Job",
|
||||
"dl0901dm",
|
||||
"Philip Hempel",
|
||||
"corde",
|
||||
"Nick Walker",
|
||||
"lh qwe",
|
||||
"Bishoujoker",
|
||||
"conner",
|
||||
"aai",
|
||||
"Yaboi",
|
||||
"Briton Heilbrun",
|
||||
"Tori",
|
||||
"wildnut",
|
||||
"Princess Bright Eyes",
|
||||
"Damon Cunliffe",
|
||||
"CryptoTraderJK",
|
||||
"Davaitamin",
|
||||
"AbstractAss",
|
||||
"Felipe dos Santos",
|
||||
"ViperC",
|
||||
"jean jahren",
|
||||
"Aleksander Wujczyk",
|
||||
"AM Kuro",
|
||||
"jean jahren",
|
||||
"Ran C",
|
||||
"tedcor",
|
||||
"Markus",
|
||||
"S Sang",
|
||||
"MagnaInsomnia",
|
||||
"Akira_HentAI",
|
||||
"Karl P.",
|
||||
"Akira_HentAI",
|
||||
"MagnaInsomnia",
|
||||
"Gordon Cole",
|
||||
"yuxz69",
|
||||
"MadSpin",
|
||||
"Douglas Gaspar",
|
||||
"AlexDuKaNa",
|
||||
"George",
|
||||
"andrew.tappan",
|
||||
"dw",
|
||||
"N/A",
|
||||
"The Spawn",
|
||||
"Phil",
|
||||
"graysock",
|
||||
"Greenmoustache",
|
||||
"zounic",
|
||||
"Gamalonia",
|
||||
"fancypants",
|
||||
"Vir",
|
||||
"Joboshy",
|
||||
"Digital",
|
||||
"JaxMax",
|
||||
"takyamtom",
|
||||
"Bohemian Corporal",
|
||||
"奚明 刘",
|
||||
"Dan",
|
||||
"Seth Christensen",
|
||||
"Jwk0205",
|
||||
"Bro Xie",
|
||||
"Draven T",
|
||||
"yer fey",
|
||||
"준희 김",
|
||||
"batblue",
|
||||
"carey6409",
|
||||
"Olive",
|
||||
"太郎 ゲーム",
|
||||
"Some Guy Named Barry",
|
||||
"jinxedx",
|
||||
"Aquatic Coffee",
|
||||
"Max Marklund",
|
||||
"Tomohiro Baba",
|
||||
"David Ortega",
|
||||
"AELOX",
|
||||
"Dankin",
|
||||
"Nicfit23",
|
||||
"Noora",
|
||||
"ethanfel",
|
||||
"wamekukyouzin",
|
||||
"drum matthieu",
|
||||
"Dogmaster",
|
||||
"Matt Wenzel",
|
||||
"Mattssn",
|
||||
"Frank Nitty",
|
||||
"Lex Song",
|
||||
"John Saveas",
|
||||
"Focuschannel",
|
||||
"Christopher Michel",
|
||||
"Serge Bekenkamp",
|
||||
"Jimmy Ledbetter",
|
||||
"LeoZero",
|
||||
"Antonio Pontes",
|
||||
"ApathyJones",
|
||||
"nahinahi9",
|
||||
"Anthony Faxlandez",
|
||||
"Dustin Chen",
|
||||
"dan",
|
||||
"Blackfish95",
|
||||
"Yaboi",
|
||||
"Mouthlessman",
|
||||
"Steam Steam",
|
||||
"Paul Kroll",
|
||||
"Damon Cunliffe",
|
||||
"CryptoTraderJK",
|
||||
"Davaitamin",
|
||||
"otaku fra",
|
||||
"semicolon drainpipe",
|
||||
"Thesharingbrother",
|
||||
"Ran C",
|
||||
"tedcor",
|
||||
"Fotek Design",
|
||||
"Bas Imagineer",
|
||||
"Pat Hen",
|
||||
"ResidentDeviant",
|
||||
"Adam Taylor",
|
||||
"JC",
|
||||
"Weird_With_A_Beard",
|
||||
"Prompt Pirate",
|
||||
"MadSpin",
|
||||
"Pozadine1",
|
||||
"uwutismxd",
|
||||
"Qarob",
|
||||
"AIGooner",
|
||||
"inbijiburu",
|
||||
"decoy",
|
||||
"Luc",
|
||||
"ProtonPrince",
|
||||
"DiffDuck",
|
||||
@@ -258,53 +234,54 @@
|
||||
"thesoftwaredruid",
|
||||
"wundershark",
|
||||
"mr_dinosaur",
|
||||
"Tyrswood",
|
||||
"linnfrey",
|
||||
"zenobeus",
|
||||
"Jackthemind",
|
||||
"Stryker",
|
||||
"Gamalonia",
|
||||
"Vir",
|
||||
"Pkrsky",
|
||||
"raf8osz",
|
||||
"blikkies",
|
||||
"Joboshy",
|
||||
"Bohemian Corporal",
|
||||
"Dan",
|
||||
"Josef Lanzl",
|
||||
"Seth Christensen",
|
||||
"Griffin Dahlberg",
|
||||
"준희 김",
|
||||
"Draven T",
|
||||
"yer fey",
|
||||
"Error_Rule34_Not_found",
|
||||
"Gerald Welly",
|
||||
"Shock Shockor",
|
||||
"Roslynd",
|
||||
"Geolog",
|
||||
"Goldwaters",
|
||||
"jinxedx",
|
||||
"Neco28",
|
||||
"Zude",
|
||||
"Aquatic Coffee",
|
||||
"Dankin",
|
||||
"ethanfel",
|
||||
"Cristian Vazquez",
|
||||
"Kyler",
|
||||
"Frank Nitty",
|
||||
"Magic Noob",
|
||||
"aRtFuL_DodGeR",
|
||||
"X",
|
||||
"Focuschannel",
|
||||
"DougPeterson",
|
||||
"Jeff",
|
||||
"Bruce",
|
||||
"CrimsonDX",
|
||||
"Kevin John Duck",
|
||||
"Anthony Faxlandez",
|
||||
"Kevin Christopher",
|
||||
"Ouro Boros",
|
||||
"DarkSunset",
|
||||
"Blackfish95",
|
||||
"dd",
|
||||
"Billy Gladky",
|
||||
"Probis",
|
||||
"shrshpp",
|
||||
"Dušan Ryban",
|
||||
"ItsGeneralButtNaked",
|
||||
"sjon kreutz",
|
||||
"Nimess",
|
||||
"Paul Kroll",
|
||||
"MiraiKuriyamaSy",
|
||||
"semicolon drainpipe",
|
||||
"Thesharingbrother",
|
||||
"Bas Imagineer",
|
||||
"Pat Hen",
|
||||
"John Statham",
|
||||
"Youguang",
|
||||
"ResidentDeviant",
|
||||
"Nihongasuki",
|
||||
"Metryman55",
|
||||
"andrewzpong",
|
||||
"FrxzenSnxw",
|
||||
"BossGame",
|
||||
"JC",
|
||||
"Prompt Pirate",
|
||||
"uwutismxd",
|
||||
"decoy",
|
||||
"Tyrswood",
|
||||
"Ray Wing",
|
||||
"Ranzitho",
|
||||
"Gus",
|
||||
@@ -316,7 +293,6 @@
|
||||
"WRL_SPR",
|
||||
"capn",
|
||||
"Joseph",
|
||||
"lrdchs",
|
||||
"Mirko Katzula",
|
||||
"dan",
|
||||
"Piccio08",
|
||||
@@ -326,51 +302,135 @@
|
||||
"Moon Knight",
|
||||
"몽타주",
|
||||
"Kland",
|
||||
"Hailshem",
|
||||
"zenobeus",
|
||||
"Jackthemind",
|
||||
"ryoma",
|
||||
"John Martin",
|
||||
"Stryker",
|
||||
"raf8osz",
|
||||
"ElitaSSJ4",
|
||||
"blikkies",
|
||||
"Chris",
|
||||
"Brian M",
|
||||
"Nerezza",
|
||||
"sanborondon",
|
||||
"moranqianlong",
|
||||
"Taylor Funk",
|
||||
"aezin",
|
||||
"Thought2Form",
|
||||
"jcay015",
|
||||
"Kevin Picco",
|
||||
"Erik Lopez",
|
||||
"Shock Shockor",
|
||||
"Mateo Curić",
|
||||
"Haru Yotu",
|
||||
"Goldwaters",
|
||||
"Zude",
|
||||
"Eris3D",
|
||||
"m",
|
||||
"Pierce McBride",
|
||||
"Joshua Gray",
|
||||
"Kyler",
|
||||
"Mikko Hemilä",
|
||||
"Matura Arbeit",
|
||||
"aRtFuL_DodGeR",
|
||||
"Jamie Ogletree",
|
||||
"TBitz33",
|
||||
"Emil Bernhoff",
|
||||
"a _",
|
||||
"SendingRavens",
|
||||
"James Coleman",
|
||||
"CrimsonDX",
|
||||
"Martial",
|
||||
"battu",
|
||||
"Emil Andersson",
|
||||
"Chad Idk",
|
||||
"Michael Docherty",
|
||||
"DarkSunset",
|
||||
"Billy Gladky",
|
||||
"Yuji Kaneko",
|
||||
"Probis",
|
||||
"Dušan Ryban",
|
||||
"ItsGeneralButtNaked",
|
||||
"Jordan Shaw",
|
||||
"Rops Alot",
|
||||
"Sam",
|
||||
"sjon kreutz",
|
||||
"Nimess",
|
||||
"SRDB",
|
||||
"Ace Ventura",
|
||||
"g unit",
|
||||
"Youguang",
|
||||
"Metryman55",
|
||||
"andrewzpong",
|
||||
"FrxzenSnxw",
|
||||
"BossGame",
|
||||
"lrdchs",
|
||||
"momokai",
|
||||
"Hailshem",
|
||||
"kudari",
|
||||
"Naomi Hale Danchi",
|
||||
"dc7431",
|
||||
"ken",
|
||||
"Inversity",
|
||||
"AIVORY3D",
|
||||
"epicgamer0020690",
|
||||
"Joshua Porrata",
|
||||
"keemun",
|
||||
"SuBu",
|
||||
"RedPIXel",
|
||||
"Kevinj",
|
||||
"Wind",
|
||||
"Nexus",
|
||||
"Ramneek“Guy”Ashok",
|
||||
"squid_actually",
|
||||
"Nat_20",
|
||||
"Edward Weeks",
|
||||
"kyoumei",
|
||||
"RadStorm04",
|
||||
"JohnDoe42054",
|
||||
"BillyHill",
|
||||
"emyth",
|
||||
"chriphost",
|
||||
"KitKatM",
|
||||
"socrasteeze",
|
||||
"ResidentDeviant",
|
||||
"gzmzmvp",
|
||||
"Welkor",
|
||||
"John Martin",
|
||||
"Richard",
|
||||
"Andrew",
|
||||
"Robert Wegemund",
|
||||
"Littlehuggy",
|
||||
"moranqianlong",
|
||||
"Gregory Kozhemiak",
|
||||
"mrjuan",
|
||||
"Brian Buie",
|
||||
"Sadlip",
|
||||
"Haru Yotu",
|
||||
"Eric Whitney",
|
||||
"Joey Callahan",
|
||||
"Ivan Tadic",
|
||||
"Mike Simone",
|
||||
"Morgandel",
|
||||
"Kyron Mahan",
|
||||
"Matura Arbeit",
|
||||
"Noah",
|
||||
"Jacob McDaniel",
|
||||
"X",
|
||||
"Sloan Steddy",
|
||||
"TBitz33",
|
||||
"Anonym dkjglfleeoeldldldlkf",
|
||||
"Temikus",
|
||||
"Artokun",
|
||||
"Michael Taylor",
|
||||
"SendingRavens",
|
||||
"Derek Baker",
|
||||
"Michael Anthony Scott",
|
||||
"Atilla Berke Pekduyar",
|
||||
"Michael Docherty",
|
||||
"Nathan",
|
||||
"Decx _",
|
||||
"Paul Hartsuyker",
|
||||
"elitassj",
|
||||
"Jacob Winter",
|
||||
"Jordan Shaw",
|
||||
"Sam",
|
||||
"Rops Alot",
|
||||
"SRDB",
|
||||
"g unit",
|
||||
"Ace Ventura",
|
||||
"Distortik",
|
||||
"David",
|
||||
"Meilo",
|
||||
"Pen Bouryoung",
|
||||
"四糸凜音",
|
||||
"shinonomeiro",
|
||||
"Snille",
|
||||
"MaartenAlbers",
|
||||
@@ -378,101 +438,104 @@
|
||||
"xybrightsummer",
|
||||
"jreedatchison",
|
||||
"PhilW",
|
||||
"momokai",
|
||||
"Tree Tagger",
|
||||
"Janik",
|
||||
"kudari",
|
||||
"Naomi Hale Danchi",
|
||||
"dc7431",
|
||||
"ken",
|
||||
"Inversity",
|
||||
"Crocket",
|
||||
"AIVORY3D",
|
||||
"epicgamer0020690",
|
||||
"Joshua Porrata",
|
||||
"Cruel",
|
||||
"keemun",
|
||||
"SuBu",
|
||||
"RedPIXel",
|
||||
"MRBlack",
|
||||
"Kevinj",
|
||||
"Wind",
|
||||
"Nexus",
|
||||
"Mitchell Robson",
|
||||
"Ramneek“Guy”Ashok",
|
||||
"squid_actually",
|
||||
"Nat_20",
|
||||
"Kiyoe",
|
||||
"Edward Weeks",
|
||||
"kyoumei",
|
||||
"RadStorm04",
|
||||
"JohnDoe42054",
|
||||
"BillyHill",
|
||||
"humptynutz",
|
||||
"emyth",
|
||||
"michael.isaza",
|
||||
"Kalnei",
|
||||
"chriphost",
|
||||
"KitKatM",
|
||||
"socrasteeze",
|
||||
"ResidentDeviant",
|
||||
"Whitepinetrader",
|
||||
"OrganicArtifact",
|
||||
"Scott",
|
||||
"gzmzmvp",
|
||||
"Welkor",
|
||||
"MudkipMedkitz",
|
||||
"deanbrian",
|
||||
"POPPIN",
|
||||
"Alex Wortman",
|
||||
"Cody",
|
||||
"Raku",
|
||||
"smart.edge5178",
|
||||
"emadsultan",
|
||||
"InformedViewz",
|
||||
"CHKeeho80",
|
||||
"Bubbafett",
|
||||
"leaf",
|
||||
"Menard",
|
||||
"Skyfire83",
|
||||
"Adam Rinehart",
|
||||
"D",
|
||||
"Pitpe11",
|
||||
"TheD1rtyD03",
|
||||
"moonpetal",
|
||||
"SomeDude",
|
||||
"g9p0o",
|
||||
"nanana",
|
||||
"TheHolySheep",
|
||||
"Monte Won",
|
||||
"SpringBootisTrash",
|
||||
"carsten",
|
||||
"ikok",
|
||||
"Buecyb99",
|
||||
"4IXplr0r3r",
|
||||
"dfklsjfkljslfjd",
|
||||
"hayden",
|
||||
"Richard",
|
||||
"ahoystan",
|
||||
"Leland Saunders",
|
||||
"Andrew",
|
||||
"Wolfe7D1",
|
||||
"Ink Temptation",
|
||||
"Bob Barker",
|
||||
"Robert Wegemund",
|
||||
"Littlehuggy",
|
||||
"Gregory Kozhemiak",
|
||||
"mrjuan",
|
||||
"edk",
|
||||
"Kalli Core",
|
||||
"Aeternyx",
|
||||
"Brian Buie",
|
||||
"elleshar666",
|
||||
"YOU SINWOO",
|
||||
"Sadlip",
|
||||
"ja s",
|
||||
"Eric Whitney",
|
||||
"Doug Mason",
|
||||
"Joey Callahan",
|
||||
"Ivan Tadic",
|
||||
"y2Rxy7FdXzWo",
|
||||
"Kauffy",
|
||||
"Jeremy Townsend",
|
||||
"Mike Simone",
|
||||
"EpicElric",
|
||||
"Sean voets",
|
||||
"Owen Gwosdz",
|
||||
"Morgandel",
|
||||
"John J Linehan",
|
||||
"Elliot E",
|
||||
"Thomas Wanner",
|
||||
"Kyron Mahan",
|
||||
"Theerat Jiramate",
|
||||
"Noah",
|
||||
"Jacob McDaniel",
|
||||
"Edward Kennedy",
|
||||
"Justin Blaylock",
|
||||
"Devil Lude",
|
||||
"Nick Kage",
|
||||
"kevin stoddard",
|
||||
"Sloan Steddy",
|
||||
"Jack Dole",
|
||||
"Vane Holzer",
|
||||
"psytrax",
|
||||
"Ezokewn",
|
||||
"Temikus",
|
||||
"Artokun",
|
||||
"Michael Taylor",
|
||||
"Derek Baker",
|
||||
"Michael Anthony Scott",
|
||||
"Atilla Berke Pekduyar",
|
||||
"hexxish",
|
||||
"CptNeo",
|
||||
"notedfakes",
|
||||
"Maso",
|
||||
"Nathan",
|
||||
"Decx _",
|
||||
"Eric Ketchum",
|
||||
"NICHOLAS BAXLEY",
|
||||
"Michael Scott",
|
||||
"Kevin Wallace",
|
||||
"Matheus Couto",
|
||||
"Paul Hartsuyker",
|
||||
"Saya",
|
||||
"ChicRic",
|
||||
"mercur",
|
||||
"J C",
|
||||
"Distortik",
|
||||
"Ed Wang",
|
||||
"Ryan Presley Ng",
|
||||
"Wes Sims",
|
||||
"Donor4115",
|
||||
"Yves Poezevara",
|
||||
"Teriak47",
|
||||
"Just me",
|
||||
"Raf Stahelin",
|
||||
"Вячеслав Маринин",
|
||||
"Lyavph",
|
||||
"Filippo Ferrari",
|
||||
"Cola Matthew",
|
||||
"OniNoKen",
|
||||
"Iain Wisely",
|
||||
@@ -505,117 +568,100 @@
|
||||
"RevyHiep",
|
||||
"Captain_Swag",
|
||||
"obkircher",
|
||||
"Tree Tagger",
|
||||
"gwyar",
|
||||
"D",
|
||||
"edgecase",
|
||||
"Neoxena",
|
||||
"mrmhalo",
|
||||
"dg",
|
||||
"Whitepinetrader",
|
||||
"Maarten Harms",
|
||||
"OrganicArtifact",
|
||||
"四糸凜音",
|
||||
"MudkipMedkitz",
|
||||
"Israel",
|
||||
"deanbrian",
|
||||
"POPPIN",
|
||||
"Muratoraccio",
|
||||
"SelfishMedic",
|
||||
"Ginnie",
|
||||
"Alex Wortman",
|
||||
"Cody",
|
||||
"adderleighn",
|
||||
"Raku",
|
||||
"smart.edge5178",
|
||||
"emadsultan",
|
||||
"InformedViewz",
|
||||
"CHKeeho80",
|
||||
"Bubbafett",
|
||||
"leaf",
|
||||
"Menard",
|
||||
"Skyfire83",
|
||||
"Adam Rinehart",
|
||||
"D",
|
||||
"Pitpe11",
|
||||
"TheD1rtyD03",
|
||||
"EnragedAntelope",
|
||||
"moonpetal",
|
||||
"SomeDude",
|
||||
"g9p0o",
|
||||
"nanana",
|
||||
"TheHolySheep",
|
||||
"Monte Won",
|
||||
"SpringBootisTrash",
|
||||
"carsten",
|
||||
"ikok",
|
||||
"Buecyb99",
|
||||
"4IXplr0r3r",
|
||||
"Alan+Cano",
|
||||
"FeralOpticsAI",
|
||||
"Pavlaki",
|
||||
"generic404",
|
||||
"Mateusz+Kosela",
|
||||
"Doug+Rintoul",
|
||||
"Noor",
|
||||
"Yorunai",
|
||||
"Bula",
|
||||
"quantenmecha",
|
||||
"abattoirblues",
|
||||
"Jason+Nash",
|
||||
"BillyBoy84",
|
||||
"DarkRoast",
|
||||
"zounik",
|
||||
"letzte",
|
||||
"Nasty+Hobbit",
|
||||
"SgtFluffles",
|
||||
"lrdchs2",
|
||||
"Duk3+Rand0m",
|
||||
"KUJYAKU",
|
||||
"NathenChoi",
|
||||
"Thomas+Reck",
|
||||
"Larses",
|
||||
"cocona",
|
||||
"Coeur+de+cochon",
|
||||
"David Schenck",
|
||||
"han b",
|
||||
"Nico",
|
||||
"Wolfe7D1",
|
||||
"Banana Joe",
|
||||
"_ G3n",
|
||||
"Donovan Jenkins",
|
||||
"Ink Temptation",
|
||||
"edk",
|
||||
"JBsuede",
|
||||
"Michael Eid",
|
||||
"beersandbacon",
|
||||
"Maximilian Pyko",
|
||||
"Invis",
|
||||
"Kalli Core",
|
||||
"Justin Houston",
|
||||
"Time Valentine",
|
||||
"james",
|
||||
"elleshar666",
|
||||
"OrochiNights",
|
||||
"Michael Zhu",
|
||||
"ACTUALLY_the_Real_Willem_Dafoe",
|
||||
"gonzalo",
|
||||
"Seraphy",
|
||||
"Михал Михалыч",
|
||||
"雨の心 落",
|
||||
"Matt",
|
||||
"AllTimeNoobie",
|
||||
"jumpd",
|
||||
"John C",
|
||||
"Kauffy",
|
||||
"Rim",
|
||||
"Dismem",
|
||||
"EpicElric",
|
||||
"John J Linehan",
|
||||
"Frogmilk",
|
||||
"SPJ",
|
||||
"Xan Dionysus",
|
||||
"Nathan lee",
|
||||
"Mewtora",
|
||||
"Elliot E",
|
||||
"Middo",
|
||||
"Forbidden Atelier",
|
||||
"Edward Kennedy",
|
||||
"Justin Blaylock",
|
||||
"Bryan Rutkowski",
|
||||
"Adictedtohumping",
|
||||
"Devil Lude",
|
||||
"Nick Kage",
|
||||
"Towelie",
|
||||
"Vane Holzer",
|
||||
"psytrax",
|
||||
"Cyrus Fett",
|
||||
"Jean-françois SEMA",
|
||||
"Kurt",
|
||||
"hexxish",
|
||||
"giani kidd",
|
||||
"CptNeo",
|
||||
"notedfakes",
|
||||
"max blo",
|
||||
"Xenon Xue",
|
||||
"JackJohnnyJim",
|
||||
"Edward Ten Eyck",
|
||||
"Chase Kwon",
|
||||
"Inyoshu",
|
||||
"Goober719",
|
||||
"Eric Ketchum",
|
||||
"Chad Barnes",
|
||||
"NICHOLAS BAXLEY",
|
||||
"Michael Scott",
|
||||
"James Ming",
|
||||
"vanditking",
|
||||
"kripitonga",
|
||||
"Rizzi",
|
||||
"nimin",
|
||||
"OMAR LUCIANO",
|
||||
"hannibal",
|
||||
"Jo+Example",
|
||||
"BrentBertram",
|
||||
"eumelzocker",
|
||||
@@ -623,5 +669,5 @@
|
||||
"L C",
|
||||
"Dude"
|
||||
],
|
||||
"totalCount": 620
|
||||
"totalCount": 666
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "Ausgeschlossene Basismodelle konnten nicht gespeichert werden: {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "Bereits heruntergeladene Modellversionen überspringen",
|
||||
"help": "Wenn aktiviert, überspringt LoRA Manager den Download einer Modellversion, wenn der Download-Verlaufsdienst diese spezifische Version als bereits heruntergeladen erfasst hat. Gilt für alle Download-Abläufe."
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "Anzeige-Dichte",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "Zusätzliche Ordnerpfade",
|
||||
"help": "Fügen Sie zusätzliche Modellordner außerhalb der Standardpfade von ComfyUI hinzu. Diese Pfade werden separat gespeichert und zusammen mit den Standardordnern gescannt.",
|
||||
"description": "Konfigurieren Sie zusätzliche Ordner zum Scannen von Modellen. Diese Pfade sind spezifisch für LoRA Manager und werden mit den Standardpfaden von ComfyUI zusammengeführt.",
|
||||
"description": "Zusätzliche Modellstammverzeichnisse, die ausschließlich für LoRA Manager gelten. Laden Sie Modelle von Speicherorten außerhalb der Standardordner von ComfyUI – ideal für große Bibliotheken, die ComfyUI sonst verlangsamen würden.",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "LoRA-Pfade",
|
||||
"checkpoint": "Checkpoint-Pfade",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Embedding-Pfade"
|
||||
},
|
||||
"pathPlaceholder": "/pfad/zu/extra/modellen",
|
||||
"saveSuccess": "Zusätzliche Ordnerpfade aktualisiert.",
|
||||
"saveSuccess": "Zusätzliche Ordnerpfade aktualisiert. Neustart erforderlich, um Änderungen anzuwenden.",
|
||||
"saveError": "Fehler beim Aktualisieren der zusätzlichen Ordnerpfade: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "Dieser Pfad ist bereits konfiguriert"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "In {otherType}-Ordner verschieben",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "An Workflow senden"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -325,7 +325,7 @@
|
||||
},
|
||||
"downloadSkipBaseModels": {
|
||||
"label": "Skip downloads for base models",
|
||||
"help": "When a model version uses one of these base models, LoRA Manager will skip the download before any file transfer starts. Applies to all download flows. Only supported base models can be selected here.",
|
||||
"help": "When enabled, versions using the selected base models will be skipped.",
|
||||
"searchPlaceholder": "Filter base models...",
|
||||
"empty": "No base models match the current search.",
|
||||
"summary": {
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "Unable to save excluded base models: {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "Skip previously downloaded model versions",
|
||||
"help": "When enabled, versions downloaded before will be skipped."
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "Display Density",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "Extra Folder Paths",
|
||||
"help": "Add additional model folders outside of ComfyUI's standard paths. These paths are stored separately and scanned alongside the default folders.",
|
||||
"description": "Configure additional folders to scan for models. These paths are specific to LoRA Manager and will be merged with ComfyUI's default paths.",
|
||||
"description": "Additional model root paths exclusive to LoRA Manager. Load models from locations outside ComfyUI's standard folders—ideal for large libraries that would otherwise slow down ComfyUI.",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "LoRA Paths",
|
||||
"checkpoint": "Checkpoint Paths",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Embedding Paths"
|
||||
},
|
||||
"pathPlaceholder": "/path/to/extra/models",
|
||||
"saveSuccess": "Extra folder paths updated.",
|
||||
"saveSuccess": "Extra folder paths updated. Restart required to apply changes.",
|
||||
"saveError": "Failed to update extra folder paths: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "This path is already configured"
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "No se pudieron guardar los modelos base excluidos: {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "Omitir versiones de modelos previamente descargadas",
|
||||
"help": "Cuando está habilitado, LoRA Manager omitirá la descarga de una versión de modelo si el servicio de historial de descargas registra esa versión exacta como ya descargada. Aplica a todos los flujos de descarga."
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "Densidad de visualización",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "Rutas de carpetas adicionales",
|
||||
"help": "Agregue carpetas de modelos adicionales fuera de las rutas estándar de ComfyUI. Estas rutas se almacenan por separado y se escanean junto con las carpetas predeterminadas.",
|
||||
"description": "Configure carpetas adicionales para escanear modelos. Estas rutas son específicas de LoRA Manager y se fusionarán con las rutas predeterminadas de ComfyUI.",
|
||||
"description": "Rutas raíz de modelos adicionales exclusivas para LoRA Manager. Cargue modelos desde ubicaciones fuera de las carpetas estándar de ComfyUI, ideal para bibliotecas grandes que de otro modo ralentizarían ComfyUI.",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "Rutas de LoRA",
|
||||
"checkpoint": "Rutas de Checkpoint",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Rutas de Embedding"
|
||||
},
|
||||
"pathPlaceholder": "/ruta/a/modelos/extra",
|
||||
"saveSuccess": "Rutas de carpetas adicionales actualizadas.",
|
||||
"saveSuccess": "Rutas de carpetas adicionales actualizadas. Se requiere reinicio para aplicar los cambios.",
|
||||
"saveError": "Error al actualizar las rutas de carpetas adicionales: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "Esta ruta ya está configurada"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "Mover a la carpeta {otherType}",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "Enviar al flujo de trabajo"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "Impossible d’enregistrer les modèles de base exclus : {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "Ignorer les versions de modèles précédemment téléchargées",
|
||||
"help": "Lorsque activé, LoRA Manager ignorera le téléchargement d'une version de modèle si le service d'historique des téléchargements enregistre cette version exacte comme déjà téléchargée. S'applique à tous les flux de téléchargement."
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "Densité d'affichage",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "Chemins de dossiers supplémentaires",
|
||||
"help": "Ajoutez des dossiers de modèles supplémentaires en dehors des chemins standard de ComfyUI. Ces chemins sont stockés séparément et analysés aux côtés des dossiers par défaut.",
|
||||
"description": "Configurez des dossiers supplémentaires pour l'analyse de modèles. Ces chemins sont spécifiques à LoRA Manager et seront fusionnés avec les chemins par défaut de ComfyUI.",
|
||||
"description": "Chemins racine de modèles supplémentaires exclusifs à LoRA Manager. Chargez des modèles depuis des emplacements en dehors des dossiers standard de ComfyUI, idéal pour les grandes bibliothèques qui ralentiraient autrement ComfyUI.",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "Chemins LoRA",
|
||||
"checkpoint": "Chemins Checkpoint",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Chemins Embedding"
|
||||
},
|
||||
"pathPlaceholder": "/chemin/vers/modèles/supplémentaires",
|
||||
"saveSuccess": "Chemins de dossiers supplémentaires mis à jour.",
|
||||
"saveSuccess": "Chemins de dossiers supplémentaires mis à jour. Redémarrage requis pour appliquer les changements.",
|
||||
"saveError": "Échec de la mise à jour des chemins de dossiers supplémentaires: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "Ce chemin est déjà configuré"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "Déplacer vers le dossier {otherType}",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "Envoyer vers le workflow"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "לא ניתן לשמור את מודלי הבסיס המוחרגים: {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "דלג על גרסאות מודלים שהורדו בעבר",
|
||||
"help": "כאשר מופעל, LoRA Manager ידלג על הורדת גרסת מודל אם שירות היסטוריית ההורדות רושם את הגרסה המדויקת הזו ככבר שהורדה. חל על כל תהליכי ההורדה."
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "צפיפות תצוגה",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "נתיבי תיקיות נוספים",
|
||||
"help": "הוסף תיקיות מודלים נוספות מחוץ לנתיבים הסטנדרטיים של ComfyUI. נתיבים אלה נשמרים בנפרד ונסרקים לצד תיקיות ברירת המחדל.",
|
||||
"description": "הגדר תיקיות נוספות לסריקת מודלים. נתיבים אלה ספציפיים ל-LoRA Manager וימוזגו עם נתיבי ברירת המחדל של ComfyUI.",
|
||||
"description": "נתיבי שורש מודלים נוספים בלעדיים ל-LoRA Manager. טען מודלים ממיקומים מחוץ לתיקיות הסטנדרטיות של ComfyUI - אידיאלי לספריות גדולות שאחרת יאטו את ComfyUI.",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "נתיבי LoRA",
|
||||
"checkpoint": "נתיבי Checkpoint",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "נתיבי Embedding"
|
||||
},
|
||||
"pathPlaceholder": "/נתיב/למודלים/נוספים",
|
||||
"saveSuccess": "נתיבי תיקיות נוספים עודכנו.",
|
||||
"saveSuccess": "נתיבי תיקיות נוספים עודכנו. נדרשת הפעלה מחדש כדי להחיל את השינויים.",
|
||||
"saveError": "נכשל בעדכון נתיבי תיקיות נוספים: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "נתיב זה כבר מוגדר"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "העבר לתיקיית {otherType}",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "שלח ל-workflow"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "除外するベースモデルを保存できませんでした: {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "以前にダウンロードしたモデルバージョンをスキップ",
|
||||
"help": "有効にすると、ダウンロード履歴サービスがそのバージョンが既にダウンロード済みと記録している場合、LoRA Managerはそのモデルバージョンのダウンロードをスキップします。すべてのダウンロードフローに適用されます。"
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "表示密度",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "追加フォルダーパス",
|
||||
"help": "ComfyUIの標準パスの外部に追加のモデルフォルダを追加します。これらのパスは別々に保存され、デフォルトのフォルダと一緒にスキャンされます。",
|
||||
"description": "モデルをスキャンするための追加フォルダを設定します。これらのパスはLoRA Manager固有であり、ComfyUIのデフォルトパスとマージされます。",
|
||||
"description": "LoRA Manager専用の追加モデルルートパス。ComfyUIの標準フォルダー外の場所からモデルを読み込みます。ComfyUIの動作を低下させる可能性のある大規模ライブラリに最適です。",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "LoRAパス",
|
||||
"checkpoint": "Checkpointパス",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Embeddingパス"
|
||||
},
|
||||
"pathPlaceholder": "/追加モデルへのパス",
|
||||
"saveSuccess": "追加フォルダーパスを更新しました。",
|
||||
"saveSuccess": "追加フォルダーパスを更新しました。変更を適用するには再起動が必要です。",
|
||||
"saveError": "追加フォルダーパスの更新に失敗しました: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "このパスはすでに設定されています"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "{otherType} フォルダに移動",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "ワークフローに送信"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "제외된 기본 모델을 저장할 수 없습니다: {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "이전에 다운로드한 모델 버전 건너뛰기",
|
||||
"help": "활성화하면 다운로드 기록 서비스가 해당 버전이 이미 다운로드되었음을 기록한 경우 LoRA Manager는 해당 모델 버전 다운로드를 건너뜁니다. 모든 다운로드 플로우에 적용됩니다."
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "표시 밀도",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "추가 폴다 경로",
|
||||
"help": "ComfyUI의 표준 경로 외부에 추가 모델 폴드를 추가하세요. 이러한 경로는 별도로 저장되며 기본 폴와 함께 스캔됩니다.",
|
||||
"description": "모델을 스캔하기 위한 추가 폴를 설정하세요. 이러한 경로는 LoRA Manager 특유의 것이며 ComfyUI의 기본 경로와 병합됩니다.",
|
||||
"description": "LoRA Manager 전용 추가 모델 루트 경로입니다. ComfyUI의 표준 폴더 외부 위치에서 모델을 로드하여 대규모 라이브러리로 인한 성능 저하를 방지합니다.",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "LoRA 경로",
|
||||
"checkpoint": "Checkpoint 경로",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Embedding 경로"
|
||||
},
|
||||
"pathPlaceholder": "/추가/모델/경로",
|
||||
"saveSuccess": "추가 폴다 경로가 업데이트되었습니다.",
|
||||
"saveSuccess": "추가 폴다 경로가 업데이트되었습니다. 변경 사항을 적용하려면 재시작이 필요합니다.",
|
||||
"saveError": "추가 폴다 경로 업데이트 실패: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "이 경로는 이미 구성되어 있습니다"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "{otherType} 폴더로 이동",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "워크플로우로 전송"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "Не удалось сохранить исключённые базовые модели: {message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "Пропускать ранее загруженные версии моделей",
|
||||
"help": "Если включено, LoRA Manager будет пропускать загрузку версии модели, если сервис истории загрузок записал, что эта конкретная версия уже загружена. Применяется ко всем потокам загрузки."
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "Плотность отображения",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "Дополнительные пути к папкам",
|
||||
"help": "Добавьте дополнительные папки моделей за пределами стандартных путей ComfyUI. Эти пути хранятся отдельно и сканируются вместе с папками по умолчанию.",
|
||||
"description": "Настройте дополнительные папки для сканирования моделей. Эти пути специфичны для LoRA Manager и будут объединены с путями по умолчанию ComfyUI.",
|
||||
"description": "Дополнительные корневые пути моделей, эксклюзивные для LoRA Manager. Загружайте модели из расположений за пределами стандартных папок ComfyUI — идеально подходит для больших библиотек, которые иначе замедлили бы ComfyUI.",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "Пути LoRA",
|
||||
"checkpoint": "Пути Checkpoint",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Пути Embedding"
|
||||
},
|
||||
"pathPlaceholder": "/путь/к/дополнительным/моделям",
|
||||
"saveSuccess": "Дополнительные пути к папкам обновлены.",
|
||||
"saveSuccess": "Дополнительные пути к папкам обновлены. Требуется перезапуск для применения изменений.",
|
||||
"saveError": "Не удалось обновить дополнительные пути к папкам: {message}",
|
||||
"validation": {
|
||||
"duplicatePath": "Этот путь уже настроен"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "Переместить в папку {otherType}",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "Отправить в workflow"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "无法保存已排除的基础模型:{message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "跳过已下载的模型版本",
|
||||
"help": "启用后,如果下载历史服务记录显示该版本已下载,LoRA Manager 将跳过下载该模型版本。适用于所有下载流程。"
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "显示密度",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "额外文件夹路径",
|
||||
"help": "在 ComfyUI 的标准路径之外添加额外的模型文件夹。这些路径单独存储,并与默认文件夹一起扫描。",
|
||||
"description": "配置额外的文件夹以扫描模型。这些路径是 LoRA Manager 特有的,将与 ComfyUI 的默认路径合并。",
|
||||
"description": "LoRA Manager 专属的额外模型根目录。从 ComfyUI 标准文件夹之外的位置加载模型,特别适合管理大型模型库,避免影响 ComfyUI 性能。",
|
||||
"restartRequired": "需要重启才能生效",
|
||||
"modelTypes": {
|
||||
"lora": "LoRA 路径",
|
||||
"checkpoint": "Checkpoint 路径",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Embedding 路径"
|
||||
},
|
||||
"pathPlaceholder": "/额外/模型/路径",
|
||||
"saveSuccess": "额外文件夹路径已更新。",
|
||||
"saveSuccess": "额外文件夹路径已更新,需要重启才能生效。",
|
||||
"saveError": "更新额外文件夹路径失败:{message}",
|
||||
"validation": {
|
||||
"duplicatePath": "此路径已配置"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "移动到 {otherType} 文件夹",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "发送到工作流"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
@@ -341,6 +341,10 @@
|
||||
"saveFailed": "無法儲存已排除的基礎模型:{message}"
|
||||
}
|
||||
},
|
||||
"skipPreviouslyDownloadedModelVersions": {
|
||||
"label": "跳過已下載的模型版本",
|
||||
"help": "啟用後,如果下載歷史服務記錄顯示該版本已下載,LoRA Manager 將跳過下載該模型版本。適用於所有下載流程。"
|
||||
},
|
||||
"layoutSettings": {
|
||||
"displayDensity": "顯示密度",
|
||||
"displayDensityOptions": {
|
||||
@@ -393,8 +397,8 @@
|
||||
},
|
||||
"extraFolderPaths": {
|
||||
"title": "額外資料夾路徑",
|
||||
"help": "在 ComfyUI 的標準路徑之外新增額外的模型資料夾。這些路徑單獨儲存,並與預設資料夾一起掃描。",
|
||||
"description": "設定額外的資料夾以掃描模型。這些路徑是 LoRA Manager 特有的,將與 ComfyUI 的預設路徑合併。",
|
||||
"description": "LoRA Manager 專屬的額外模型根目錄。從 ComfyUI 標準資料夾之外的位置載入模型,特別適合管理大型模型庫,避免影響 ComfyUI 效能。",
|
||||
"restartRequired": "Requires restart to take effect",
|
||||
"modelTypes": {
|
||||
"lora": "LoRA 路徑",
|
||||
"checkpoint": "Checkpoint 路徑",
|
||||
@@ -402,7 +406,7 @@
|
||||
"embedding": "Embedding 路徑"
|
||||
},
|
||||
"pathPlaceholder": "/額外/模型/路徑",
|
||||
"saveSuccess": "額外資料夾路徑已更新。",
|
||||
"saveSuccess": "額外資料夾路徑已更新,需要重啟才能生效。",
|
||||
"saveError": "更新額外資料夾路徑失敗:{message}",
|
||||
"validation": {
|
||||
"duplicatePath": "此路徑已設定"
|
||||
@@ -827,7 +831,7 @@
|
||||
},
|
||||
"contextMenu": {
|
||||
"moveToOtherTypeFolder": "移動到 {otherType} 資料夾",
|
||||
"sendToWorkflow": "[TODO: Translate] Send to Workflow"
|
||||
"sendToWorkflow": "傳送到工作流"
|
||||
}
|
||||
},
|
||||
"embeddings": {
|
||||
|
||||
61
py/config.py
61
py/config.py
@@ -25,6 +25,31 @@ standalone_mode = (
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _resolve_valid_default_root(
|
||||
current: str, primary_paths: List[str], name: str
|
||||
) -> str:
|
||||
"""Return a valid default root from the current primary path set."""
|
||||
|
||||
valid_paths = [path for path in primary_paths if isinstance(path, str) and path.strip()]
|
||||
if not valid_paths:
|
||||
return ""
|
||||
|
||||
if current in valid_paths:
|
||||
return current
|
||||
|
||||
if current:
|
||||
logger.info(
|
||||
"Repaired stale %s from '%s' to '%s'",
|
||||
name,
|
||||
current,
|
||||
valid_paths[0],
|
||||
)
|
||||
else:
|
||||
logger.info("Auto-setting %s to '%s'", name, valid_paths[0])
|
||||
|
||||
return valid_paths[0]
|
||||
|
||||
|
||||
def _normalize_folder_paths_for_comparison(
|
||||
folder_paths: Mapping[str, Iterable[str]],
|
||||
) -> Dict[str, Set[str]]:
|
||||
@@ -197,25 +222,23 @@ class Config:
|
||||
"Failed to rename legacy 'default' library: %s", rename_error
|
||||
)
|
||||
|
||||
default_lora_root = comfy_library.get("default_lora_root", "")
|
||||
if not default_lora_root and len(self.loras_roots) == 1:
|
||||
default_lora_root = self.loras_roots[0]
|
||||
default_lora_root = _resolve_valid_default_root(
|
||||
comfy_library.get("default_lora_root", ""),
|
||||
list(self.loras_roots or []),
|
||||
"default_lora_root",
|
||||
)
|
||||
|
||||
default_checkpoint_root = comfy_library.get("default_checkpoint_root", "")
|
||||
if (
|
||||
not default_checkpoint_root
|
||||
and self.checkpoints_roots
|
||||
and len(self.checkpoints_roots) == 1
|
||||
):
|
||||
default_checkpoint_root = self.checkpoints_roots[0]
|
||||
default_checkpoint_root = _resolve_valid_default_root(
|
||||
comfy_library.get("default_checkpoint_root", ""),
|
||||
list(self.checkpoints_roots or []),
|
||||
"default_checkpoint_root",
|
||||
)
|
||||
|
||||
default_embedding_root = comfy_library.get("default_embedding_root", "")
|
||||
if (
|
||||
not default_embedding_root
|
||||
and self.embeddings_roots
|
||||
and len(self.embeddings_roots) == 1
|
||||
):
|
||||
default_embedding_root = self.embeddings_roots[0]
|
||||
default_embedding_root = _resolve_valid_default_root(
|
||||
comfy_library.get("default_embedding_root", ""),
|
||||
list(self.embeddings_roots or []),
|
||||
"default_embedding_root",
|
||||
)
|
||||
|
||||
metadata = dict(comfy_library.get("metadata", {}))
|
||||
metadata.setdefault("display_name", "ComfyUI")
|
||||
@@ -706,7 +729,9 @@ class Config:
|
||||
return unique_paths
|
||||
|
||||
@staticmethod
|
||||
def _normalize_path_for_comparison(path: str, *, resolve_realpath: bool = False) -> str:
|
||||
def _normalize_path_for_comparison(
|
||||
path: str, *, resolve_realpath: bool = False
|
||||
) -> str:
|
||||
"""Normalize a path for equality checks across platforms."""
|
||||
candidate = os.path.realpath(path) if resolve_realpath else path
|
||||
return os.path.normcase(os.path.normpath(candidate)).replace(os.sep, "/")
|
||||
|
||||
@@ -4,15 +4,21 @@ from typing import Awaitable, Callable, Dict, List
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
# Use wildcard for CivitAI to support their CDN subdomains (e.g., image-b2.civitai.com)
|
||||
# Security note: This is acceptable because:
|
||||
# 1. CSP img-src only controls image/video loading, not script execution
|
||||
# 2. All *.civitai.com subdomains are controlled by Civitai
|
||||
# 3. Explicit domain list would require constant updates as Civitai adds CDN nodes
|
||||
REMOTE_MEDIA_SOURCES = (
|
||||
"https://image.civitai.com",
|
||||
"https://*.civitai.com",
|
||||
"https://img.genur.art",
|
||||
)
|
||||
|
||||
|
||||
@web.middleware
|
||||
async def relax_csp_for_remote_media(
|
||||
request: web.Request, handler: Callable[[web.Request], Awaitable[web.StreamResponse]]
|
||||
request: web.Request,
|
||||
handler: Callable[[web.Request], Awaitable[web.StreamResponse]],
|
||||
) -> web.StreamResponse:
|
||||
"""Allow LoRA Manager media previews to load from trusted remote domains.
|
||||
|
||||
@@ -43,7 +49,9 @@ async def relax_csp_for_remote_media(
|
||||
directive_order.append(name)
|
||||
directives[name] = values
|
||||
|
||||
def merge_sources(name: str, sources: List[str], defaults: List[str] | None = None) -> None:
|
||||
def merge_sources(
|
||||
name: str, sources: List[str], defaults: List[str] | None = None
|
||||
) -> None:
|
||||
existing = directives.get(name, list(defaults or []))
|
||||
|
||||
for source in sources:
|
||||
|
||||
@@ -8,6 +8,7 @@ and tracks the cycle progress which persists across workflow save/load.
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from ..utils.utils import get_lora_info
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -54,6 +55,9 @@ class LoraCyclerLM:
|
||||
current_index = cycler_config.get("current_index", 1) # 1-based
|
||||
model_strength = float(cycler_config.get("model_strength", 1.0))
|
||||
clip_strength = float(cycler_config.get("clip_strength", 1.0))
|
||||
use_same_clip_strength = cycler_config.get("use_same_clip_strength", True)
|
||||
use_preset_strength = cycler_config.get("use_preset_strength", False)
|
||||
preset_strength_scale = float(cycler_config.get("preset_strength_scale", 1.0))
|
||||
sort_by = "filename"
|
||||
|
||||
# Include "no lora" option
|
||||
@@ -131,6 +135,39 @@ class LoraCyclerLM:
|
||||
else:
|
||||
# Normalize path separators
|
||||
lora_path = lora_path.replace("/", os.sep)
|
||||
|
||||
if use_preset_strength:
|
||||
lora_metadata = await lora_service.get_lora_metadata_by_filename(
|
||||
current_lora["file_name"]
|
||||
)
|
||||
if lora_metadata:
|
||||
recommended_strength = (
|
||||
lora_service.get_recommended_strength_from_lora_data(
|
||||
lora_metadata
|
||||
)
|
||||
)
|
||||
if recommended_strength is not None:
|
||||
model_strength = round(
|
||||
recommended_strength * preset_strength_scale, 2
|
||||
)
|
||||
|
||||
if use_same_clip_strength:
|
||||
clip_strength = model_strength
|
||||
else:
|
||||
recommended_clip_strength = (
|
||||
lora_service.get_recommended_clip_strength_from_lora_data(
|
||||
lora_metadata
|
||||
)
|
||||
)
|
||||
if recommended_clip_strength is not None:
|
||||
clip_strength = round(
|
||||
recommended_clip_strength * preset_strength_scale, 2
|
||||
)
|
||||
elif use_same_clip_strength:
|
||||
clip_strength = model_strength
|
||||
elif use_same_clip_strength:
|
||||
clip_strength = model_strength
|
||||
|
||||
lora_stack = [(lora_path, model_strength, clip_strength)]
|
||||
|
||||
# Calculate next index (wrap to 1 if at end)
|
||||
|
||||
@@ -751,6 +751,7 @@ class ServiceRegistryAdapter:
|
||||
get_lora_scanner: Callable[[], Awaitable]
|
||||
get_checkpoint_scanner: Callable[[], Awaitable]
|
||||
get_embedding_scanner: Callable[[], Awaitable]
|
||||
get_downloaded_version_history_service: Callable[[], Awaitable]
|
||||
|
||||
|
||||
class ModelLibraryHandler:
|
||||
@@ -764,6 +765,41 @@ class ModelLibraryHandler:
|
||||
self._service_registry = service_registry
|
||||
self._metadata_provider_factory = metadata_provider_factory
|
||||
|
||||
@staticmethod
|
||||
def _normalize_model_type(model_type: str | None) -> str | None:
|
||||
if not isinstance(model_type, str):
|
||||
return None
|
||||
normalized = model_type.strip().lower()
|
||||
if normalized in {"lora", "locon", "dora"}:
|
||||
return "lora"
|
||||
if normalized == "checkpoint":
|
||||
return "checkpoint"
|
||||
if normalized in {"embedding", "textualinversion"}:
|
||||
return "embedding"
|
||||
return None
|
||||
|
||||
async def _get_scanner_for_type(self, model_type: str | None):
|
||||
normalized_type = self._normalize_model_type(model_type)
|
||||
if normalized_type == "lora":
|
||||
return normalized_type, await self._service_registry.get_lora_scanner()
|
||||
if normalized_type == "checkpoint":
|
||||
return normalized_type, await self._service_registry.get_checkpoint_scanner()
|
||||
if normalized_type == "embedding":
|
||||
return normalized_type, await self._service_registry.get_embedding_scanner()
|
||||
return None, None
|
||||
|
||||
async def _get_download_history_service(self):
|
||||
return await self._service_registry.get_downloaded_version_history_service()
|
||||
|
||||
@staticmethod
|
||||
def _with_downloaded_flag(versions: list[dict]) -> list[dict]:
|
||||
enriched: list[dict] = []
|
||||
for version in versions:
|
||||
entry = dict(version)
|
||||
entry.setdefault("hasBeenDownloaded", True)
|
||||
enriched.append(entry)
|
||||
return enriched
|
||||
|
||||
async def check_model_exists(self, request: web.Request) -> web.Response:
|
||||
try:
|
||||
model_id_str = request.query.get("modelId")
|
||||
@@ -819,11 +855,30 @@ class ModelLibraryHandler:
|
||||
exists = True
|
||||
model_type = "embedding"
|
||||
|
||||
history_service = await self._get_download_history_service()
|
||||
has_been_downloaded = False
|
||||
history_type = model_type
|
||||
if history_type:
|
||||
has_been_downloaded = await history_service.has_been_downloaded(
|
||||
history_type,
|
||||
model_version_id,
|
||||
)
|
||||
else:
|
||||
for candidate_type in ("lora", "checkpoint", "embedding"):
|
||||
if await history_service.has_been_downloaded(
|
||||
candidate_type,
|
||||
model_version_id,
|
||||
):
|
||||
has_been_downloaded = True
|
||||
history_type = candidate_type
|
||||
break
|
||||
|
||||
return web.json_response(
|
||||
{
|
||||
"success": True,
|
||||
"exists": exists,
|
||||
"modelType": model_type if exists else None,
|
||||
"modelType": model_type if exists else history_type,
|
||||
"hasBeenDownloaded": has_been_downloaded,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -841,23 +896,166 @@ class ModelLibraryHandler:
|
||||
|
||||
model_type = None
|
||||
versions = []
|
||||
downloaded_version_ids = []
|
||||
history_service = await self._get_download_history_service()
|
||||
if lora_versions:
|
||||
model_type = "lora"
|
||||
versions = lora_versions
|
||||
versions = self._with_downloaded_flag(lora_versions)
|
||||
downloaded_version_ids = await history_service.get_downloaded_version_ids(
|
||||
model_type,
|
||||
model_id,
|
||||
)
|
||||
elif checkpoint_versions:
|
||||
model_type = "checkpoint"
|
||||
versions = checkpoint_versions
|
||||
versions = self._with_downloaded_flag(checkpoint_versions)
|
||||
downloaded_version_ids = await history_service.get_downloaded_version_ids(
|
||||
model_type,
|
||||
model_id,
|
||||
)
|
||||
elif embedding_versions:
|
||||
model_type = "embedding"
|
||||
versions = embedding_versions
|
||||
versions = self._with_downloaded_flag(embedding_versions)
|
||||
downloaded_version_ids = await history_service.get_downloaded_version_ids(
|
||||
model_type,
|
||||
model_id,
|
||||
)
|
||||
else:
|
||||
for candidate_type in ("lora", "checkpoint", "embedding"):
|
||||
candidate_downloaded_version_ids = (
|
||||
await history_service.get_downloaded_version_ids(
|
||||
candidate_type,
|
||||
model_id,
|
||||
)
|
||||
)
|
||||
if candidate_downloaded_version_ids:
|
||||
model_type = candidate_type
|
||||
downloaded_version_ids = candidate_downloaded_version_ids
|
||||
break
|
||||
|
||||
return web.json_response(
|
||||
{"success": True, "modelType": model_type, "versions": versions}
|
||||
{
|
||||
"success": True,
|
||||
"modelType": model_type,
|
||||
"versions": versions,
|
||||
"downloadedVersionIds": downloaded_version_ids,
|
||||
}
|
||||
)
|
||||
except Exception as exc: # pragma: no cover - defensive logging
|
||||
logger.error("Failed to check model existence: %s", exc, exc_info=True)
|
||||
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
||||
|
||||
async def get_model_version_download_status(
|
||||
self, request: web.Request
|
||||
) -> web.Response:
|
||||
try:
|
||||
model_type, _ = await self._get_scanner_for_type(request.query.get("modelType"))
|
||||
if not model_type:
|
||||
return web.json_response(
|
||||
{"success": False, "error": "Parameter modelType is required"},
|
||||
status=400,
|
||||
)
|
||||
|
||||
model_version_id_str = request.query.get("modelVersionId")
|
||||
if not model_version_id_str:
|
||||
return web.json_response(
|
||||
{"success": False, "error": "Missing required parameter: modelVersionId"},
|
||||
status=400,
|
||||
)
|
||||
try:
|
||||
model_version_id = int(model_version_id_str)
|
||||
except ValueError:
|
||||
return web.json_response(
|
||||
{"success": False, "error": "Parameter modelVersionId must be an integer"},
|
||||
status=400,
|
||||
)
|
||||
|
||||
history_service = await self._get_download_history_service()
|
||||
return web.json_response(
|
||||
{
|
||||
"success": True,
|
||||
"modelType": model_type,
|
||||
"modelVersionId": model_version_id,
|
||||
"hasBeenDownloaded": await history_service.has_been_downloaded(
|
||||
model_type,
|
||||
model_version_id,
|
||||
),
|
||||
}
|
||||
)
|
||||
except Exception as exc: # pragma: no cover - defensive logging
|
||||
logger.error(
|
||||
"Failed to get model version download status: %s",
|
||||
exc,
|
||||
exc_info=True,
|
||||
)
|
||||
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
||||
|
||||
async def set_model_version_download_status(
|
||||
self, request: web.Request
|
||||
) -> web.Response:
|
||||
try:
|
||||
if request.method == "GET":
|
||||
data = request.query
|
||||
else:
|
||||
data = await request.json()
|
||||
model_type, _ = await self._get_scanner_for_type(data.get("modelType"))
|
||||
if not model_type:
|
||||
return web.json_response(
|
||||
{"success": False, "error": "Parameter modelType is required"},
|
||||
status=400,
|
||||
)
|
||||
|
||||
try:
|
||||
model_version_id = int(data.get("modelVersionId"))
|
||||
except (TypeError, ValueError):
|
||||
return web.json_response(
|
||||
{"success": False, "error": "Parameter modelVersionId must be an integer"},
|
||||
status=400,
|
||||
)
|
||||
|
||||
downloaded = data.get("downloaded")
|
||||
if isinstance(downloaded, str):
|
||||
normalized_downloaded = downloaded.strip().lower()
|
||||
if normalized_downloaded in {"true", "1"}:
|
||||
downloaded = True
|
||||
elif normalized_downloaded in {"false", "0"}:
|
||||
downloaded = False
|
||||
|
||||
if not isinstance(downloaded, bool):
|
||||
return web.json_response(
|
||||
{"success": False, "error": "Parameter downloaded must be a boolean"},
|
||||
status=400,
|
||||
)
|
||||
|
||||
history_service = await self._get_download_history_service()
|
||||
if downloaded:
|
||||
model_id = data.get("modelId")
|
||||
file_path = data.get("filePath")
|
||||
await history_service.mark_downloaded(
|
||||
model_type,
|
||||
model_version_id,
|
||||
model_id=model_id,
|
||||
source="manual",
|
||||
file_path=file_path if isinstance(file_path, str) else None,
|
||||
)
|
||||
else:
|
||||
await history_service.mark_not_downloaded(model_type, model_version_id)
|
||||
|
||||
return web.json_response(
|
||||
{
|
||||
"success": True,
|
||||
"modelType": model_type,
|
||||
"modelVersionId": model_version_id,
|
||||
"hasBeenDownloaded": downloaded,
|
||||
}
|
||||
)
|
||||
except Exception as exc: # pragma: no cover - defensive logging
|
||||
logger.error(
|
||||
"Failed to set model version download status: %s",
|
||||
exc,
|
||||
exc_info=True,
|
||||
)
|
||||
return web.json_response({"success": False, "error": str(exc)}, status=500)
|
||||
|
||||
async def get_model_versions_status(self, request: web.Request) -> web.Response:
|
||||
try:
|
||||
model_id_str = request.query.get("modelId")
|
||||
@@ -896,18 +1094,8 @@ class ModelLibraryHandler:
|
||||
model_name = response.get("name", "")
|
||||
model_type = response.get("type", "").lower()
|
||||
|
||||
scanner = None
|
||||
normalized_type = None
|
||||
if model_type in {"lora", "locon", "dora"}:
|
||||
scanner = await self._service_registry.get_lora_scanner()
|
||||
normalized_type = "lora"
|
||||
elif model_type == "checkpoint":
|
||||
scanner = await self._service_registry.get_checkpoint_scanner()
|
||||
normalized_type = "checkpoint"
|
||||
elif model_type == "textualinversion":
|
||||
scanner = await self._service_registry.get_embedding_scanner()
|
||||
normalized_type = "embedding"
|
||||
else:
|
||||
normalized_type, scanner = await self._get_scanner_for_type(model_type)
|
||||
if not normalized_type:
|
||||
return web.json_response(
|
||||
{
|
||||
"success": False,
|
||||
@@ -925,8 +1113,14 @@ class ModelLibraryHandler:
|
||||
status=503,
|
||||
)
|
||||
|
||||
history_service = await self._get_download_history_service()
|
||||
local_versions = await scanner.get_model_versions_by_id(model_id)
|
||||
local_version_ids = {version["versionId"] for version in local_versions}
|
||||
downloaded_version_ids = await history_service.get_downloaded_version_ids(
|
||||
normalized_type,
|
||||
model_id,
|
||||
)
|
||||
downloaded_version_id_set = set(downloaded_version_ids)
|
||||
|
||||
enriched_versions = []
|
||||
for version in versions:
|
||||
@@ -939,6 +1133,7 @@ class ModelLibraryHandler:
|
||||
if version.get("images")
|
||||
else None,
|
||||
"inLibrary": version_id in local_version_ids,
|
||||
"hasBeenDownloaded": version_id in downloaded_version_id_set,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1007,6 +1202,33 @@ class ModelLibraryHandler:
|
||||
}
|
||||
|
||||
versions: list[dict] = []
|
||||
history_service = await self._get_download_history_service()
|
||||
model_ids: list[int] = []
|
||||
for model in models:
|
||||
try:
|
||||
model_ids.append(int(model.get("id")))
|
||||
except (TypeError, ValueError):
|
||||
continue
|
||||
|
||||
lora_downloaded = await history_service.get_downloaded_version_ids_bulk(
|
||||
"lora",
|
||||
model_ids,
|
||||
)
|
||||
checkpoint_downloaded = await history_service.get_downloaded_version_ids_bulk(
|
||||
"checkpoint",
|
||||
model_ids,
|
||||
)
|
||||
embedding_downloaded = await history_service.get_downloaded_version_ids_bulk(
|
||||
"embedding",
|
||||
model_ids,
|
||||
)
|
||||
downloaded_version_map: Dict[str, Dict[int, set[int]]] = {
|
||||
"lora": lora_downloaded,
|
||||
"locon": lora_downloaded,
|
||||
"dora": lora_downloaded,
|
||||
"checkpoint": checkpoint_downloaded,
|
||||
"textualinversion": embedding_downloaded,
|
||||
}
|
||||
for model in models:
|
||||
if not isinstance(model, dict):
|
||||
continue
|
||||
@@ -1061,6 +1283,8 @@ class ModelLibraryHandler:
|
||||
in_library = await scanner.check_model_version_exists(
|
||||
version_id_int
|
||||
)
|
||||
downloaded_versions = downloaded_version_map.get(model_type, {})
|
||||
downloaded_version_ids = downloaded_versions.get(model_id_int, set())
|
||||
|
||||
versions.append(
|
||||
{
|
||||
@@ -1073,6 +1297,7 @@ class ModelLibraryHandler:
|
||||
"baseModel": version.get("baseModel"),
|
||||
"thumbnailUrl": thumbnail_url,
|
||||
"inLibrary": in_library,
|
||||
"hasBeenDownloaded": version_id_int in downloaded_version_ids,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1655,6 +1880,8 @@ class MiscHandlerSet:
|
||||
"update_node_widget": self.node_registry.update_node_widget,
|
||||
"get_registry": self.node_registry.get_registry,
|
||||
"check_model_exists": self.model_library.check_model_exists,
|
||||
"get_model_version_download_status": self.model_library.get_model_version_download_status,
|
||||
"set_model_version_download_status": self.model_library.set_model_version_download_status,
|
||||
"get_civitai_user_models": self.model_library.get_civitai_user_models,
|
||||
"download_metadata_archive": self.metadata_archive.download_metadata_archive,
|
||||
"remove_metadata_archive": self.metadata_archive.remove_metadata_archive,
|
||||
@@ -1679,4 +1906,5 @@ def build_service_registry_adapter() -> ServiceRegistryAdapter:
|
||||
get_lora_scanner=ServiceRegistry.get_lora_scanner,
|
||||
get_checkpoint_scanner=ServiceRegistry.get_checkpoint_scanner,
|
||||
get_embedding_scanner=ServiceRegistry.get_embedding_scanner,
|
||||
get_downloaded_version_history_service=ServiceRegistry.get_downloaded_version_history_service,
|
||||
)
|
||||
|
||||
@@ -37,6 +37,21 @@ MISC_ROUTE_DEFINITIONS: tuple[RouteDefinition, ...] = (
|
||||
RouteDefinition("POST", "/api/lm/update-node-widget", "update_node_widget"),
|
||||
RouteDefinition("GET", "/api/lm/get-registry", "get_registry"),
|
||||
RouteDefinition("GET", "/api/lm/check-model-exists", "check_model_exists"),
|
||||
RouteDefinition(
|
||||
"GET",
|
||||
"/api/lm/model-version-download-status",
|
||||
"get_model_version_download_status",
|
||||
),
|
||||
RouteDefinition(
|
||||
"POST",
|
||||
"/api/lm/model-version-download-status",
|
||||
"set_model_version_download_status",
|
||||
),
|
||||
RouteDefinition(
|
||||
"GET",
|
||||
"/api/lm/set-model-version-download-status",
|
||||
"set_model_version_download_status",
|
||||
),
|
||||
RouteDefinition("GET", "/api/lm/civitai/user-models", "get_civitai_user_models"),
|
||||
RouteDefinition(
|
||||
"POST", "/api/lm/download-metadata-archive", "download_metadata_archive"
|
||||
|
||||
@@ -64,6 +64,19 @@ class DownloadManager:
|
||||
"""Get the checkpoint scanner from registry"""
|
||||
return await ServiceRegistry.get_checkpoint_scanner()
|
||||
|
||||
async def _has_been_downloaded(self, model_type: str, model_version_id: int) -> bool:
|
||||
try:
|
||||
history_service = await ServiceRegistry.get_downloaded_version_history_service()
|
||||
return await history_service.has_been_downloaded(model_type, model_version_id)
|
||||
except Exception as exc:
|
||||
logger.debug(
|
||||
"Failed to read download history for %s version %s: %s",
|
||||
model_type,
|
||||
model_version_id,
|
||||
exc,
|
||||
)
|
||||
return False
|
||||
|
||||
async def download_from_civitai(
|
||||
self,
|
||||
model_id: int = None,
|
||||
@@ -355,6 +368,57 @@ class DownloadManager:
|
||||
"error": f'Model type "{model_type_from_info}" is not supported for download',
|
||||
}
|
||||
|
||||
resolved_version_id = model_version_id
|
||||
raw_version_id = version_info.get("id")
|
||||
if resolved_version_id is None and raw_version_id is not None:
|
||||
try:
|
||||
resolved_version_id = int(raw_version_id)
|
||||
except (TypeError, ValueError):
|
||||
resolved_version_id = None
|
||||
|
||||
if (
|
||||
get_settings_manager().get_skip_previously_downloaded_model_versions()
|
||||
and resolved_version_id is not None
|
||||
and await self._has_been_downloaded(model_type, resolved_version_id)
|
||||
):
|
||||
file_name = ""
|
||||
files = version_info.get("files")
|
||||
if isinstance(files, list):
|
||||
primary_file = next(
|
||||
(
|
||||
file_info
|
||||
for file_info in files
|
||||
if isinstance(file_info, dict) and file_info.get("primary")
|
||||
),
|
||||
None,
|
||||
)
|
||||
selected_file = primary_file
|
||||
if selected_file is None:
|
||||
selected_file = next(
|
||||
(file_info for file_info in files if isinstance(file_info, dict)),
|
||||
None,
|
||||
)
|
||||
if isinstance(selected_file, dict):
|
||||
raw_file_name = selected_file.get("name", "")
|
||||
if isinstance(raw_file_name, str):
|
||||
file_name = raw_file_name.strip()
|
||||
|
||||
message = (
|
||||
f"Skipped download for '{file_name or version_info.get('name') or f'model_version:{resolved_version_id}'}' "
|
||||
f"because version {resolved_version_id} was already downloaded before"
|
||||
)
|
||||
logger.info(message)
|
||||
return {
|
||||
"success": True,
|
||||
"skipped": True,
|
||||
"status": "skipped",
|
||||
"reason": "previously_downloaded_version",
|
||||
"message": message,
|
||||
"model_version_id": resolved_version_id,
|
||||
"file_name": file_name,
|
||||
"download_id": download_id,
|
||||
}
|
||||
|
||||
excluded_base_models = get_settings_manager().get_download_skip_base_models()
|
||||
base_model_value = version_info.get("baseModel", "")
|
||||
if (
|
||||
@@ -640,6 +704,13 @@ class DownloadManager:
|
||||
or version_info.get("modelId")
|
||||
or (version_info.get("model") or {}).get("id")
|
||||
)
|
||||
await self._record_downloaded_version_history(
|
||||
model_type,
|
||||
resolved_model_id,
|
||||
version_info,
|
||||
model_version_id,
|
||||
save_path,
|
||||
)
|
||||
await self._sync_downloaded_version(
|
||||
model_type,
|
||||
resolved_model_id,
|
||||
@@ -669,6 +740,55 @@ class DownloadManager:
|
||||
}
|
||||
return {"success": False, "error": str(e)}
|
||||
|
||||
async def _record_downloaded_version_history(
|
||||
self,
|
||||
model_type: str,
|
||||
model_id_value,
|
||||
version_info: Dict,
|
||||
fallback_version_id=None,
|
||||
file_path: str | None = None,
|
||||
) -> None:
|
||||
try:
|
||||
history_service = await ServiceRegistry.get_downloaded_version_history_service()
|
||||
except Exception as exc:
|
||||
logger.debug(
|
||||
"Skipping download history sync; failed to acquire history service: %s",
|
||||
exc,
|
||||
)
|
||||
return
|
||||
|
||||
if history_service is None:
|
||||
return
|
||||
|
||||
resolved_model_id = model_id_value
|
||||
if resolved_model_id is None:
|
||||
resolved_model_id = version_info.get("modelId")
|
||||
if resolved_model_id is None:
|
||||
model_info = version_info.get("model")
|
||||
if isinstance(model_info, dict):
|
||||
resolved_model_id = model_info.get("id")
|
||||
|
||||
version_id = version_info.get("id")
|
||||
if version_id is None:
|
||||
version_id = fallback_version_id
|
||||
|
||||
try:
|
||||
await history_service.mark_downloaded(
|
||||
model_type,
|
||||
int(version_id),
|
||||
model_id=int(resolved_model_id) if resolved_model_id is not None else None,
|
||||
source="download",
|
||||
file_path=file_path,
|
||||
)
|
||||
except (TypeError, ValueError):
|
||||
logger.debug(
|
||||
"Skipping download history sync; invalid identifiers model=%s version=%s",
|
||||
resolved_model_id,
|
||||
version_id,
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.debug("Failed to sync download history for %s: %s", model_type, exc)
|
||||
|
||||
async def _sync_downloaded_version(
|
||||
self,
|
||||
model_type: str,
|
||||
|
||||
313
py/services/downloaded_version_history_service.py
Normal file
313
py/services/downloaded_version_history_service.py
Normal file
@@ -0,0 +1,313 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import sqlite3
|
||||
import time
|
||||
from typing import Iterable, Mapping, Optional, Sequence
|
||||
|
||||
from ..utils.cache_paths import get_cache_base_dir
|
||||
from .settings_manager import get_settings_manager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _normalize_model_type(model_type: str | None) -> Optional[str]:
|
||||
if not isinstance(model_type, str):
|
||||
return None
|
||||
normalized = model_type.strip().lower()
|
||||
if normalized in {"lora", "locon", "dora"}:
|
||||
return "lora"
|
||||
if normalized == "checkpoint":
|
||||
return "checkpoint"
|
||||
if normalized in {"embedding", "textualinversion"}:
|
||||
return "embedding"
|
||||
return None
|
||||
|
||||
|
||||
def _normalize_int(value) -> Optional[int]:
|
||||
try:
|
||||
if value is None:
|
||||
return None
|
||||
return int(value)
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def _resolve_database_path() -> str:
|
||||
base_dir = get_cache_base_dir(create=True)
|
||||
history_dir = os.path.join(base_dir, "download_history")
|
||||
os.makedirs(history_dir, exist_ok=True)
|
||||
return os.path.join(history_dir, "downloaded_versions.sqlite")
|
||||
|
||||
|
||||
class DownloadedVersionHistoryService:
|
||||
_SCHEMA = """
|
||||
CREATE TABLE IF NOT EXISTS downloaded_model_versions (
|
||||
model_type TEXT NOT NULL,
|
||||
version_id INTEGER NOT NULL,
|
||||
model_id INTEGER,
|
||||
first_seen_at REAL NOT NULL,
|
||||
last_seen_at REAL NOT NULL,
|
||||
source TEXT NOT NULL,
|
||||
last_file_path TEXT,
|
||||
last_library_name TEXT,
|
||||
is_deleted_override INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (model_type, version_id)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_downloaded_model_versions_model
|
||||
ON downloaded_model_versions(model_type, model_id);
|
||||
"""
|
||||
|
||||
def __init__(self, db_path: str | None = None, *, settings_manager=None) -> None:
|
||||
self._db_path = db_path or _resolve_database_path()
|
||||
self._settings = settings_manager or get_settings_manager()
|
||||
self._lock = asyncio.Lock()
|
||||
self._schema_initialized = False
|
||||
self._ensure_directory()
|
||||
self._initialize_schema()
|
||||
|
||||
def _ensure_directory(self) -> None:
|
||||
directory = os.path.dirname(self._db_path)
|
||||
if directory:
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
|
||||
def _connect(self) -> sqlite3.Connection:
|
||||
conn = sqlite3.connect(self._db_path, check_same_thread=False)
|
||||
conn.row_factory = sqlite3.Row
|
||||
return conn
|
||||
|
||||
def _initialize_schema(self) -> None:
|
||||
if self._schema_initialized:
|
||||
return
|
||||
with self._connect() as conn:
|
||||
conn.executescript(self._SCHEMA)
|
||||
conn.commit()
|
||||
self._schema_initialized = True
|
||||
|
||||
def get_database_path(self) -> str:
|
||||
return self._db_path
|
||||
|
||||
def _get_active_library_name(self) -> str | None:
|
||||
try:
|
||||
value = self._settings.get_active_library_name()
|
||||
except Exception:
|
||||
return None
|
||||
return value or None
|
||||
|
||||
async def mark_downloaded(
|
||||
self,
|
||||
model_type: str,
|
||||
version_id: int,
|
||||
*,
|
||||
model_id: int | None = None,
|
||||
source: str = "manual",
|
||||
file_path: str | None = None,
|
||||
library_name: str | None = None,
|
||||
) -> None:
|
||||
normalized_type = _normalize_model_type(model_type)
|
||||
normalized_version_id = _normalize_int(version_id)
|
||||
normalized_model_id = _normalize_int(model_id)
|
||||
if normalized_type is None or normalized_version_id is None:
|
||||
return
|
||||
|
||||
active_library_name = library_name or self._get_active_library_name()
|
||||
timestamp = time.time()
|
||||
|
||||
async with self._lock:
|
||||
with self._connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO downloaded_model_versions (
|
||||
model_type, version_id, model_id, first_seen_at, last_seen_at,
|
||||
source, last_file_path, last_library_name, is_deleted_override
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0)
|
||||
ON CONFLICT(model_type, version_id) DO UPDATE SET
|
||||
model_id = COALESCE(excluded.model_id, downloaded_model_versions.model_id),
|
||||
last_seen_at = excluded.last_seen_at,
|
||||
source = excluded.source,
|
||||
last_file_path = COALESCE(excluded.last_file_path, downloaded_model_versions.last_file_path),
|
||||
last_library_name = COALESCE(excluded.last_library_name, downloaded_model_versions.last_library_name),
|
||||
is_deleted_override = 0
|
||||
""",
|
||||
(
|
||||
normalized_type,
|
||||
normalized_version_id,
|
||||
normalized_model_id,
|
||||
timestamp,
|
||||
timestamp,
|
||||
source,
|
||||
file_path,
|
||||
active_library_name,
|
||||
),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
async def mark_downloaded_bulk(
|
||||
self,
|
||||
model_type: str,
|
||||
records: Sequence[Mapping[str, object]],
|
||||
*,
|
||||
source: str = "scan",
|
||||
library_name: str | None = None,
|
||||
) -> None:
|
||||
normalized_type = _normalize_model_type(model_type)
|
||||
if normalized_type is None or not records:
|
||||
return
|
||||
|
||||
timestamp = time.time()
|
||||
active_library_name = library_name or self._get_active_library_name()
|
||||
payload: list[tuple[object, ...]] = []
|
||||
for record in records:
|
||||
version_id = _normalize_int(record.get("version_id"))
|
||||
if version_id is None:
|
||||
continue
|
||||
payload.append(
|
||||
(
|
||||
normalized_type,
|
||||
version_id,
|
||||
_normalize_int(record.get("model_id")),
|
||||
timestamp,
|
||||
timestamp,
|
||||
source,
|
||||
record.get("file_path"),
|
||||
active_library_name,
|
||||
)
|
||||
)
|
||||
|
||||
if not payload:
|
||||
return
|
||||
|
||||
async with self._lock:
|
||||
with self._connect() as conn:
|
||||
conn.executemany(
|
||||
"""
|
||||
INSERT INTO downloaded_model_versions (
|
||||
model_type, version_id, model_id, first_seen_at, last_seen_at,
|
||||
source, last_file_path, last_library_name, is_deleted_override
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0)
|
||||
ON CONFLICT(model_type, version_id) DO UPDATE SET
|
||||
model_id = COALESCE(excluded.model_id, downloaded_model_versions.model_id),
|
||||
last_seen_at = excluded.last_seen_at,
|
||||
source = excluded.source,
|
||||
last_file_path = COALESCE(excluded.last_file_path, downloaded_model_versions.last_file_path),
|
||||
last_library_name = COALESCE(excluded.last_library_name, downloaded_model_versions.last_library_name),
|
||||
is_deleted_override = 0
|
||||
""",
|
||||
payload,
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
async def mark_not_downloaded(self, model_type: str, version_id: int) -> None:
|
||||
normalized_type = _normalize_model_type(model_type)
|
||||
normalized_version_id = _normalize_int(version_id)
|
||||
if normalized_type is None or normalized_version_id is None:
|
||||
return
|
||||
|
||||
timestamp = time.time()
|
||||
|
||||
async with self._lock:
|
||||
with self._connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO downloaded_model_versions (
|
||||
model_type, version_id, model_id, first_seen_at, last_seen_at,
|
||||
source, last_file_path, last_library_name, is_deleted_override
|
||||
) VALUES (?, ?, NULL, ?, ?, 'manual', NULL, ?, 1)
|
||||
ON CONFLICT(model_type, version_id) DO UPDATE SET
|
||||
last_seen_at = excluded.last_seen_at,
|
||||
source = excluded.source,
|
||||
last_library_name = COALESCE(excluded.last_library_name, downloaded_model_versions.last_library_name),
|
||||
is_deleted_override = 1
|
||||
""",
|
||||
(
|
||||
normalized_type,
|
||||
normalized_version_id,
|
||||
timestamp,
|
||||
timestamp,
|
||||
self._get_active_library_name(),
|
||||
),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
async def has_been_downloaded(self, model_type: str, version_id: int) -> bool:
|
||||
normalized_type = _normalize_model_type(model_type)
|
||||
normalized_version_id = _normalize_int(version_id)
|
||||
if normalized_type is None or normalized_version_id is None:
|
||||
return False
|
||||
|
||||
async with self._lock:
|
||||
with self._connect() as conn:
|
||||
row = conn.execute(
|
||||
"""
|
||||
SELECT is_deleted_override
|
||||
FROM downloaded_model_versions
|
||||
WHERE model_type = ? AND version_id = ?
|
||||
""",
|
||||
(normalized_type, normalized_version_id),
|
||||
).fetchone()
|
||||
return bool(row) and not bool(row["is_deleted_override"])
|
||||
|
||||
async def get_downloaded_version_ids(
|
||||
self, model_type: str, model_id: int
|
||||
) -> list[int]:
|
||||
normalized_type = _normalize_model_type(model_type)
|
||||
normalized_model_id = _normalize_int(model_id)
|
||||
if normalized_type is None or normalized_model_id is None:
|
||||
return []
|
||||
|
||||
async with self._lock:
|
||||
with self._connect() as conn:
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT version_id
|
||||
FROM downloaded_model_versions
|
||||
WHERE model_type = ? AND model_id = ? AND is_deleted_override = 0
|
||||
ORDER BY version_id ASC
|
||||
""",
|
||||
(normalized_type, normalized_model_id),
|
||||
).fetchall()
|
||||
return [int(row["version_id"]) for row in rows]
|
||||
|
||||
async def get_downloaded_version_ids_bulk(
|
||||
self, model_type: str, model_ids: Iterable[int]
|
||||
) -> dict[int, set[int]]:
|
||||
normalized_type = _normalize_model_type(model_type)
|
||||
if normalized_type is None:
|
||||
return {}
|
||||
|
||||
normalized_model_ids = sorted(
|
||||
{
|
||||
value
|
||||
for value in (_normalize_int(model_id) for model_id in model_ids)
|
||||
if value is not None
|
||||
}
|
||||
)
|
||||
if not normalized_model_ids:
|
||||
return {}
|
||||
|
||||
placeholders = ", ".join(["?"] * len(normalized_model_ids))
|
||||
params: list[object] = [normalized_type, *normalized_model_ids]
|
||||
|
||||
async with self._lock:
|
||||
with self._connect() as conn:
|
||||
rows = conn.execute(
|
||||
f"""
|
||||
SELECT model_id, version_id
|
||||
FROM downloaded_model_versions
|
||||
WHERE model_type = ?
|
||||
AND model_id IN ({placeholders})
|
||||
AND is_deleted_override = 0
|
||||
""",
|
||||
params,
|
||||
).fetchall()
|
||||
|
||||
result: dict[int, set[int]] = {}
|
||||
for row in rows:
|
||||
model_id = _normalize_int(row["model_id"])
|
||||
version_id = _normalize_int(row["version_id"])
|
||||
if model_id is None or version_id is None:
|
||||
continue
|
||||
result.setdefault(model_id, set()).add(version_id)
|
||||
return result
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import logging
|
||||
import json
|
||||
import os
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from .base_model_service import BaseModelService
|
||||
@@ -278,6 +279,42 @@ class LoraService(BaseModelService):
|
||||
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_recommended_strength_from_lora_data(lora_data: Dict) -> Optional[float]:
|
||||
"""Parse usage_tips JSON and extract recommended model strength."""
|
||||
try:
|
||||
usage_tips = lora_data.get("usage_tips", "")
|
||||
if not usage_tips:
|
||||
return None
|
||||
tips_data = json.loads(usage_tips)
|
||||
return tips_data.get("strength")
|
||||
except (json.JSONDecodeError, TypeError, AttributeError):
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def get_recommended_clip_strength_from_lora_data(
|
||||
lora_data: Dict,
|
||||
) -> Optional[float]:
|
||||
"""Parse usage_tips JSON and extract recommended clip strength."""
|
||||
try:
|
||||
usage_tips = lora_data.get("usage_tips", "")
|
||||
if not usage_tips:
|
||||
return None
|
||||
tips_data = json.loads(usage_tips)
|
||||
return tips_data.get("clipStrength")
|
||||
except (json.JSONDecodeError, TypeError, AttributeError):
|
||||
return None
|
||||
|
||||
async def get_lora_metadata_by_filename(self, filename: str) -> Optional[Dict]:
|
||||
"""Return cached raw metadata for a LoRA matching the given filename."""
|
||||
cache = await self.scanner.get_cached_data(force_refresh=False)
|
||||
|
||||
for lora in cache.raw_data if cache else []:
|
||||
if lora.get("file_name") == filename:
|
||||
return lora
|
||||
|
||||
return None
|
||||
|
||||
def find_duplicate_hashes(self) -> Dict:
|
||||
"""Find LoRAs with duplicate SHA256 hashes"""
|
||||
return self.scanner._hash_index.get_duplicate_hashes()
|
||||
@@ -328,34 +365,10 @@ class LoraService(BaseModelService):
|
||||
List of LoRA dicts with randomized strengths
|
||||
"""
|
||||
import random
|
||||
import json
|
||||
|
||||
# Use a local Random instance to avoid affecting global random state
|
||||
# This ensures each execution with a different seed produces different results
|
||||
rng = random.Random(seed)
|
||||
|
||||
def get_recommended_strength(lora_data: Dict) -> Optional[float]:
|
||||
"""Parse usage_tips JSON and extract recommended strength"""
|
||||
try:
|
||||
usage_tips = lora_data.get("usage_tips", "")
|
||||
if not usage_tips:
|
||||
return None
|
||||
tips_data = json.loads(usage_tips)
|
||||
return tips_data.get("strength")
|
||||
except (json.JSONDecodeError, TypeError, AttributeError):
|
||||
return None
|
||||
|
||||
def get_recommended_clip_strength(lora_data: Dict) -> Optional[float]:
|
||||
"""Parse usage_tips JSON and extract recommended clip strength"""
|
||||
try:
|
||||
usage_tips = lora_data.get("usage_tips", "")
|
||||
if not usage_tips:
|
||||
return None
|
||||
tips_data = json.loads(usage_tips)
|
||||
return tips_data.get("clipStrength")
|
||||
except (json.JSONDecodeError, TypeError, AttributeError):
|
||||
return None
|
||||
|
||||
if locked_loras is None:
|
||||
locked_loras = []
|
||||
|
||||
@@ -403,7 +416,9 @@ class LoraService(BaseModelService):
|
||||
result_loras = []
|
||||
for lora in selected:
|
||||
if use_recommended_strength:
|
||||
recommended_strength = get_recommended_strength(lora)
|
||||
recommended_strength = self.get_recommended_strength_from_lora_data(
|
||||
lora
|
||||
)
|
||||
if recommended_strength is not None:
|
||||
scale = rng.uniform(
|
||||
recommended_strength_scale_min, recommended_strength_scale_max
|
||||
@@ -421,7 +436,9 @@ class LoraService(BaseModelService):
|
||||
if use_same_clip_strength:
|
||||
clip_str = model_str
|
||||
elif use_recommended_strength:
|
||||
recommended_clip_strength = get_recommended_clip_strength(lora)
|
||||
recommended_clip_strength = (
|
||||
self.get_recommended_clip_strength_from_lora_data(lora)
|
||||
)
|
||||
if recommended_clip_strength is not None:
|
||||
scale = rng.uniform(
|
||||
recommended_strength_scale_min, recommended_strength_scale_max
|
||||
|
||||
@@ -411,6 +411,7 @@ class ModelScanner:
|
||||
if scan_result:
|
||||
await self._apply_scan_result(scan_result)
|
||||
await self._save_persistent_cache(scan_result)
|
||||
await self._sync_download_history(scan_result.raw_data, source='scan')
|
||||
|
||||
# Send final progress update
|
||||
await ws_manager.broadcast_init_progress({
|
||||
@@ -516,6 +517,7 @@ class ModelScanner:
|
||||
)
|
||||
|
||||
await self._apply_scan_result(scan_result)
|
||||
await self._sync_download_history(adjusted_raw_data, source='scan')
|
||||
|
||||
await ws_manager.broadcast_init_progress({
|
||||
'stage': 'loading_cache',
|
||||
@@ -576,6 +578,7 @@ class ModelScanner:
|
||||
excluded_models=list(self._excluded_models)
|
||||
)
|
||||
await self._save_persistent_cache(snapshot)
|
||||
await self._sync_download_history(snapshot.raw_data, source='scan')
|
||||
def _count_model_files(self) -> int:
|
||||
"""Count all model files with supported extensions in all roots
|
||||
|
||||
@@ -704,6 +707,7 @@ class ModelScanner:
|
||||
scan_result = await self._gather_model_data()
|
||||
await self._apply_scan_result(scan_result)
|
||||
await self._save_persistent_cache(scan_result)
|
||||
await self._sync_download_history(scan_result.raw_data, source='scan')
|
||||
|
||||
logger.info(
|
||||
f"{self.model_type.capitalize()} Scanner: Cache initialization completed in {time.time() - start_time:.2f} seconds, "
|
||||
@@ -1101,6 +1105,49 @@ class ModelScanner:
|
||||
|
||||
await self._cache.resort()
|
||||
|
||||
async def _sync_download_history(
|
||||
self,
|
||||
raw_data: List[Mapping[str, Any]],
|
||||
*,
|
||||
source: str,
|
||||
) -> None:
|
||||
records: List[Dict[str, Any]] = []
|
||||
for item in raw_data or []:
|
||||
if not isinstance(item, Mapping):
|
||||
continue
|
||||
civitai = item.get('civitai')
|
||||
if not isinstance(civitai, Mapping):
|
||||
continue
|
||||
|
||||
version_id = civitai.get('id')
|
||||
if version_id in (None, ''):
|
||||
continue
|
||||
|
||||
records.append(
|
||||
{
|
||||
'version_id': version_id,
|
||||
'model_id': civitai.get('modelId'),
|
||||
'file_path': item.get('file_path'),
|
||||
}
|
||||
)
|
||||
|
||||
if not records:
|
||||
return
|
||||
|
||||
try:
|
||||
history_service = await ServiceRegistry.get_downloaded_version_history_service()
|
||||
await history_service.mark_downloaded_bulk(
|
||||
self.model_type,
|
||||
records,
|
||||
source=source,
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.debug(
|
||||
"%s Scanner: Failed to sync download history: %s",
|
||||
self.model_type.capitalize(),
|
||||
exc,
|
||||
)
|
||||
|
||||
async def _gather_model_data(
|
||||
self,
|
||||
*,
|
||||
|
||||
@@ -167,6 +167,28 @@ class ServiceRegistry:
|
||||
logger.debug(f"Created and registered {service_name}")
|
||||
return service
|
||||
|
||||
@classmethod
|
||||
async def get_downloaded_version_history_service(cls):
|
||||
"""Get or create the downloaded-version history service."""
|
||||
|
||||
service_name = "downloaded_version_history_service"
|
||||
|
||||
if service_name in cls._services:
|
||||
return cls._services[service_name]
|
||||
|
||||
async with cls._get_lock(service_name):
|
||||
if service_name in cls._services:
|
||||
return cls._services[service_name]
|
||||
|
||||
from .downloaded_version_history_service import (
|
||||
DownloadedVersionHistoryService,
|
||||
)
|
||||
|
||||
service = DownloadedVersionHistoryService()
|
||||
cls._services[service_name] = service
|
||||
logger.debug(f"Created and registered {service_name}")
|
||||
return service
|
||||
|
||||
@classmethod
|
||||
async def get_civarchive_client(cls):
|
||||
"""Get or create CivArchive client instance"""
|
||||
@@ -255,4 +277,4 @@ class ServiceRegistry:
|
||||
"""Clear all registered services - mainly for testing"""
|
||||
cls._services.clear()
|
||||
cls._locks.clear()
|
||||
logger.info("Cleared all registered services")
|
||||
logger.info("Cleared all registered services")
|
||||
|
||||
@@ -7,7 +7,17 @@ import logging
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timezone
|
||||
from threading import Lock
|
||||
from typing import Any, Awaitable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple
|
||||
from typing import (
|
||||
Any,
|
||||
Awaitable,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
)
|
||||
|
||||
from platformdirs import user_config_dir
|
||||
|
||||
@@ -17,7 +27,11 @@ from ..utils.constants import (
|
||||
SUPPORTED_DOWNLOAD_SKIP_BASE_MODELS,
|
||||
)
|
||||
from ..utils.preview_selection import VALID_MATURE_BLUR_LEVELS
|
||||
from ..utils.settings_paths import APP_NAME, ensure_settings_file, get_legacy_settings_path
|
||||
from ..utils.settings_paths import (
|
||||
APP_NAME,
|
||||
ensure_settings_file,
|
||||
get_legacy_settings_path,
|
||||
)
|
||||
from ..utils.tag_priorities import (
|
||||
PriorityTagEntry,
|
||||
collect_canonical_tags,
|
||||
@@ -77,6 +91,7 @@ DEFAULT_SETTINGS: Dict[str, Any] = {
|
||||
"update_flag_strategy": "same_base",
|
||||
"auto_organize_exclusions": [],
|
||||
"metadata_refresh_skip_paths": [],
|
||||
"skip_previously_downloaded_model_versions": False,
|
||||
"download_skip_base_models": [],
|
||||
}
|
||||
|
||||
@@ -94,7 +109,9 @@ class SettingsManager:
|
||||
self._template_payload_cache_loaded = False
|
||||
self._original_disk_payload: Optional[Dict[str, Any]] = None
|
||||
self._preserve_disk_template = False
|
||||
self._template_path = Path(__file__).resolve().parents[2] / "settings.json.example"
|
||||
self._template_path = (
|
||||
Path(__file__).resolve().parents[2] / "settings.json.example"
|
||||
)
|
||||
self.settings = self._load_settings()
|
||||
self._migrate_setting_keys()
|
||||
self._ensure_default_settings()
|
||||
@@ -120,7 +137,7 @@ class SettingsManager:
|
||||
"""Load settings from file"""
|
||||
if os.path.exists(self.settings_file):
|
||||
try:
|
||||
with open(self.settings_file, 'r', encoding='utf-8') as f:
|
||||
with open(self.settings_file, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
if isinstance(data, dict):
|
||||
self._original_disk_payload = copy.deepcopy(data)
|
||||
@@ -198,7 +215,9 @@ class SettingsManager:
|
||||
return None
|
||||
|
||||
if not isinstance(data, dict):
|
||||
logger.debug("settings.json.example is not a JSON object; ignoring template")
|
||||
logger.debug(
|
||||
"settings.json.example is not a JSON object; ignoring template"
|
||||
)
|
||||
return None
|
||||
|
||||
self._template_payload_cache = copy.deepcopy(data)
|
||||
@@ -274,7 +293,9 @@ class SettingsManager:
|
||||
normalized_skip_paths = self.normalize_metadata_refresh_skip_paths(
|
||||
self.settings.get("metadata_refresh_skip_paths")
|
||||
)
|
||||
if normalized_skip_paths != self.settings.get("metadata_refresh_skip_paths"):
|
||||
if normalized_skip_paths != self.settings.get(
|
||||
"metadata_refresh_skip_paths"
|
||||
):
|
||||
self.settings["metadata_refresh_skip_paths"] = normalized_skip_paths
|
||||
updated_existing = True
|
||||
else:
|
||||
@@ -288,14 +309,16 @@ class SettingsManager:
|
||||
if normalized_skip_base_models != self.settings.get(
|
||||
"download_skip_base_models"
|
||||
):
|
||||
self.settings["download_skip_base_models"] = (
|
||||
normalized_skip_base_models
|
||||
)
|
||||
self.settings["download_skip_base_models"] = normalized_skip_base_models
|
||||
updated_existing = True
|
||||
else:
|
||||
self.settings["download_skip_base_models"] = []
|
||||
inserted_defaults = True
|
||||
|
||||
if "skip_previously_downloaded_model_versions" not in self.settings:
|
||||
self.settings["skip_previously_downloaded_model_versions"] = False
|
||||
inserted_defaults = True
|
||||
|
||||
had_mature_level = "mature_blur_level" in self.settings
|
||||
raw_mature_level = self.settings.get("mature_blur_level")
|
||||
normalized_mature_level = self.normalize_mature_blur_level(raw_mature_level)
|
||||
@@ -330,19 +353,19 @@ class SettingsManager:
|
||||
raw_top_level_paths = self.settings.get("folder_paths", {})
|
||||
normalized_top_level_paths: Dict[str, List[str]] = {}
|
||||
if isinstance(raw_top_level_paths, Mapping):
|
||||
normalized_top_level_paths = self._normalize_folder_paths(raw_top_level_paths)
|
||||
normalized_top_level_paths = self._normalize_folder_paths(
|
||||
raw_top_level_paths
|
||||
)
|
||||
if normalized_top_level_paths != raw_top_level_paths:
|
||||
self.settings["folder_paths"] = copy.deepcopy(normalized_top_level_paths)
|
||||
self.settings["folder_paths"] = copy.deepcopy(
|
||||
normalized_top_level_paths
|
||||
)
|
||||
|
||||
top_level_has_paths = self._has_configured_paths(normalized_top_level_paths)
|
||||
|
||||
needs_library_bootstrap = not isinstance(libraries, dict) or not libraries
|
||||
|
||||
if (
|
||||
not needs_library_bootstrap
|
||||
and top_level_has_paths
|
||||
and len(libraries) == 1
|
||||
):
|
||||
if not needs_library_bootstrap and top_level_has_paths and len(libraries) == 1:
|
||||
only_library_payload = next(iter(libraries.values()))
|
||||
if isinstance(only_library_payload, Mapping):
|
||||
folder_payload = only_library_payload.get("folder_paths")
|
||||
@@ -354,7 +377,9 @@ class SettingsManager:
|
||||
library_payload = self._build_library_payload(
|
||||
folder_paths=normalized_top_level_paths,
|
||||
default_lora_root=self.settings.get("default_lora_root", ""),
|
||||
default_checkpoint_root=self.settings.get("default_checkpoint_root", ""),
|
||||
default_checkpoint_root=self.settings.get(
|
||||
"default_checkpoint_root", ""
|
||||
),
|
||||
default_unet_root=self.settings.get("default_unet_root", ""),
|
||||
default_embedding_root=self.settings.get("default_embedding_root", ""),
|
||||
)
|
||||
@@ -376,7 +401,11 @@ class SettingsManager:
|
||||
|
||||
if target_name:
|
||||
candidate_payload = libraries.get(target_name)
|
||||
if isinstance(candidate_payload, Mapping) and not self._has_configured_paths(candidate_payload.get("folder_paths")):
|
||||
if isinstance(
|
||||
candidate_payload, Mapping
|
||||
) and not self._has_configured_paths(
|
||||
candidate_payload.get("folder_paths")
|
||||
):
|
||||
seed_library_name = target_name
|
||||
|
||||
sanitized_libraries: Dict[str, Dict[str, Any]] = {}
|
||||
@@ -435,11 +464,17 @@ class SettingsManager:
|
||||
active_library = libraries.get(active_name, {})
|
||||
folder_paths = copy.deepcopy(active_library.get("folder_paths", {}))
|
||||
self.settings["folder_paths"] = folder_paths
|
||||
self.settings["extra_folder_paths"] = copy.deepcopy(active_library.get("extra_folder_paths", {}))
|
||||
self.settings["extra_folder_paths"] = copy.deepcopy(
|
||||
active_library.get("extra_folder_paths", {})
|
||||
)
|
||||
self.settings["default_lora_root"] = active_library.get("default_lora_root", "")
|
||||
self.settings["default_checkpoint_root"] = active_library.get("default_checkpoint_root", "")
|
||||
self.settings["default_checkpoint_root"] = active_library.get(
|
||||
"default_checkpoint_root", ""
|
||||
)
|
||||
self.settings["default_unet_root"] = active_library.get("default_unet_root", "")
|
||||
self.settings["default_embedding_root"] = active_library.get("default_embedding_root", "")
|
||||
self.settings["default_embedding_root"] = active_library.get(
|
||||
"default_embedding_root", ""
|
||||
)
|
||||
|
||||
if save:
|
||||
self._save_settings()
|
||||
@@ -468,7 +503,9 @@ class SettingsManager:
|
||||
payload.setdefault("folder_paths", {})
|
||||
|
||||
if extra_folder_paths is not None:
|
||||
payload["extra_folder_paths"] = self._normalize_folder_paths(extra_folder_paths)
|
||||
payload["extra_folder_paths"] = self._normalize_folder_paths(
|
||||
extra_folder_paths
|
||||
)
|
||||
else:
|
||||
payload.setdefault("extra_folder_paths", {})
|
||||
|
||||
@@ -577,7 +614,9 @@ class SettingsManager:
|
||||
}
|
||||
overlap = existing.intersection(new_paths.keys())
|
||||
if overlap:
|
||||
collisions = ", ".join(sorted(new_paths[value] for value in overlap))
|
||||
collisions = ", ".join(
|
||||
sorted(new_paths[value] for value in overlap)
|
||||
)
|
||||
raise ValueError(
|
||||
f"Folder path(s) {collisions} already assigned to library '{other_name}'"
|
||||
)
|
||||
@@ -612,19 +651,31 @@ class SettingsManager:
|
||||
library["extra_folder_paths"] = normalized_extra_paths
|
||||
changed = True
|
||||
|
||||
if default_lora_root is not None and library.get("default_lora_root") != default_lora_root:
|
||||
if (
|
||||
default_lora_root is not None
|
||||
and library.get("default_lora_root") != default_lora_root
|
||||
):
|
||||
library["default_lora_root"] = default_lora_root
|
||||
changed = True
|
||||
|
||||
if default_checkpoint_root is not None and library.get("default_checkpoint_root") != default_checkpoint_root:
|
||||
if (
|
||||
default_checkpoint_root is not None
|
||||
and library.get("default_checkpoint_root") != default_checkpoint_root
|
||||
):
|
||||
library["default_checkpoint_root"] = default_checkpoint_root
|
||||
changed = True
|
||||
|
||||
if default_unet_root is not None and library.get("default_unet_root") != default_unet_root:
|
||||
if (
|
||||
default_unet_root is not None
|
||||
and library.get("default_unet_root") != default_unet_root
|
||||
):
|
||||
library["default_unet_root"] = default_unet_root
|
||||
changed = True
|
||||
|
||||
if default_embedding_root is not None and library.get("default_embedding_root") != default_embedding_root:
|
||||
if (
|
||||
default_embedding_root is not None
|
||||
and library.get("default_embedding_root") != default_embedding_root
|
||||
):
|
||||
library["default_embedding_root"] = default_embedding_root
|
||||
changed = True
|
||||
|
||||
@@ -637,16 +688,16 @@ class SettingsManager:
|
||||
def _migrate_setting_keys(self) -> None:
|
||||
"""Migrate legacy camelCase setting keys to snake_case"""
|
||||
key_migrations = {
|
||||
'optimizeExampleImages': 'optimize_example_images',
|
||||
'autoDownloadExampleImages': 'auto_download_example_images',
|
||||
'blurMatureContent': 'blur_mature_content',
|
||||
'matureBlurLevel': 'mature_blur_level',
|
||||
'autoplayOnHover': 'autoplay_on_hover',
|
||||
'displayDensity': 'display_density',
|
||||
'cardInfoDisplay': 'card_info_display',
|
||||
'includeTriggerWords': 'include_trigger_words',
|
||||
'compactMode': 'compact_mode',
|
||||
'modelCardFooterAction': 'model_card_footer_action',
|
||||
"optimizeExampleImages": "optimize_example_images",
|
||||
"autoDownloadExampleImages": "auto_download_example_images",
|
||||
"blurMatureContent": "blur_mature_content",
|
||||
"matureBlurLevel": "mature_blur_level",
|
||||
"autoplayOnHover": "autoplay_on_hover",
|
||||
"displayDensity": "display_density",
|
||||
"cardInfoDisplay": "card_info_display",
|
||||
"includeTriggerWords": "include_trigger_words",
|
||||
"compactMode": "compact_mode",
|
||||
"modelCardFooterAction": "model_card_footer_action",
|
||||
}
|
||||
|
||||
updated = False
|
||||
@@ -663,65 +714,77 @@ class SettingsManager:
|
||||
|
||||
def _migrate_download_path_template(self):
|
||||
"""Migrate old download_path_template to new download_path_templates"""
|
||||
old_template = self.settings.get('download_path_template')
|
||||
templates = self.settings.get('download_path_templates')
|
||||
old_template = self.settings.get("download_path_template")
|
||||
templates = self.settings.get("download_path_templates")
|
||||
|
||||
# If old template exists and new templates don't exist, migrate
|
||||
if old_template is not None and not templates:
|
||||
logger.info("Migrating download_path_template to download_path_templates")
|
||||
self.settings['download_path_templates'] = {
|
||||
'lora': old_template,
|
||||
'checkpoint': old_template,
|
||||
'embedding': old_template
|
||||
self.settings["download_path_templates"] = {
|
||||
"lora": old_template,
|
||||
"checkpoint": old_template,
|
||||
"embedding": old_template,
|
||||
}
|
||||
# Remove old setting
|
||||
del self.settings['download_path_template']
|
||||
del self.settings["download_path_template"]
|
||||
self._save_settings()
|
||||
logger.info("Migration completed")
|
||||
|
||||
def _auto_set_default_roots(self):
|
||||
"""Auto set default root paths when the current default is unset or not among the options.
|
||||
"""Ensure default root paths always point at a current valid root.
|
||||
|
||||
For single-path cases, always use that path.
|
||||
For multi-path cases, only set if current default is empty or invalid.
|
||||
Empty or stale defaults are repaired to the first configured root.
|
||||
Skips auto-setting when the settings file matches the template
|
||||
(user hasn't customized yet).
|
||||
"""
|
||||
folder_paths = self.settings.get('folder_paths', {})
|
||||
# Skip auto-setting if the user hasn't customized settings yet (template preserved)
|
||||
if self._preserve_disk_template:
|
||||
return
|
||||
|
||||
folder_paths = self.settings.get("folder_paths", {})
|
||||
updated = False
|
||||
# loras
|
||||
loras = folder_paths.get('loras', [])
|
||||
if isinstance(loras, list) and len(loras) == 1:
|
||||
current_lora_root = self.settings.get('default_lora_root')
|
||||
if current_lora_root not in loras:
|
||||
self.settings['default_lora_root'] = loras[0]
|
||||
updated = True
|
||||
# checkpoints
|
||||
checkpoints = folder_paths.get('checkpoints', [])
|
||||
if isinstance(checkpoints, list) and len(checkpoints) == 1:
|
||||
current_checkpoint_root = self.settings.get('default_checkpoint_root')
|
||||
if current_checkpoint_root not in checkpoints:
|
||||
self.settings['default_checkpoint_root'] = checkpoints[0]
|
||||
updated = True
|
||||
# unet (diffusion models) - auto-set if empty or invalid
|
||||
unet_paths = folder_paths.get('unet', [])
|
||||
if isinstance(unet_paths, list) and len(unet_paths) >= 1:
|
||||
current_unet_root = self.settings.get('default_unet_root')
|
||||
# Set to first path if current is empty or not in the valid paths
|
||||
if not current_unet_root or current_unet_root not in unet_paths:
|
||||
self.settings['default_unet_root'] = unet_paths[0]
|
||||
updated = True
|
||||
# embeddings
|
||||
embeddings = folder_paths.get('embeddings', [])
|
||||
if isinstance(embeddings, list) and len(embeddings) == 1:
|
||||
current_embedding_root = self.settings.get('default_embedding_root')
|
||||
if current_embedding_root not in embeddings:
|
||||
self.settings['default_embedding_root'] = embeddings[0]
|
||||
updated = True
|
||||
|
||||
def _check_and_auto_set(key: str, setting_key: str) -> bool:
|
||||
"""Repair default roots when empty or no longer present."""
|
||||
current = self.settings.get(setting_key, "")
|
||||
candidates = folder_paths.get(key, [])
|
||||
if not isinstance(candidates, list) or not candidates:
|
||||
return False
|
||||
|
||||
# Filter valid path strings
|
||||
valid_paths = [p for p in candidates if isinstance(p, str) and p.strip()]
|
||||
if not valid_paths:
|
||||
return False
|
||||
|
||||
if current in valid_paths:
|
||||
return False
|
||||
|
||||
self.settings[setting_key] = valid_paths[0]
|
||||
if current:
|
||||
logger.info(
|
||||
"Repaired stale %s from '%s' to '%s'",
|
||||
setting_key,
|
||||
current,
|
||||
valid_paths[0],
|
||||
)
|
||||
else:
|
||||
logger.info("Auto-set %s to '%s'", setting_key, valid_paths[0])
|
||||
return True
|
||||
|
||||
# Process all model types
|
||||
updated = _check_and_auto_set("loras", "default_lora_root") or updated
|
||||
updated = (
|
||||
_check_and_auto_set("checkpoints", "default_checkpoint_root") or updated
|
||||
)
|
||||
updated = _check_and_auto_set("unet", "default_unet_root") or updated
|
||||
updated = _check_and_auto_set("embeddings", "default_embedding_root") or updated
|
||||
|
||||
if updated:
|
||||
self._update_active_library_entry(
|
||||
default_lora_root=self.settings.get('default_lora_root'),
|
||||
default_checkpoint_root=self.settings.get('default_checkpoint_root'),
|
||||
default_unet_root=self.settings.get('default_unet_root'),
|
||||
default_embedding_root=self.settings.get('default_embedding_root'),
|
||||
default_lora_root=self.settings.get("default_lora_root"),
|
||||
default_checkpoint_root=self.settings.get("default_checkpoint_root"),
|
||||
default_unet_root=self.settings.get("default_unet_root"),
|
||||
default_embedding_root=self.settings.get("default_embedding_root"),
|
||||
)
|
||||
if self._bootstrap_reason == "missing":
|
||||
self._needs_initial_save = True
|
||||
@@ -730,11 +793,11 @@ class SettingsManager:
|
||||
|
||||
def _check_environment_variables(self) -> None:
|
||||
"""Check for environment variables and update settings if needed"""
|
||||
env_api_key = os.environ.get('CIVITAI_API_KEY')
|
||||
env_api_key = os.environ.get("CIVITAI_API_KEY")
|
||||
if env_api_key: # Check if the environment variable exists and is not empty
|
||||
logger.info("Found CIVITAI_API_KEY environment variable")
|
||||
# Always use the environment variable if it exists
|
||||
self.settings['civitai_api_key'] = env_api_key
|
||||
self.settings["civitai_api_key"] = env_api_key
|
||||
self._save_settings()
|
||||
|
||||
def _default_settings_actions(self) -> List[Dict[str, Any]]:
|
||||
@@ -799,7 +862,9 @@ class SettingsManager:
|
||||
disk_value = self._original_disk_payload.get(key)
|
||||
default_value = defaults.get(key)
|
||||
# Compare using JSON serialization for complex objects
|
||||
if json.dumps(disk_value, sort_keys=True, default=str) == json.dumps(default_value, sort_keys=True, default=str):
|
||||
if json.dumps(disk_value, sort_keys=True, default=str) == json.dumps(
|
||||
default_value, sort_keys=True, default=str
|
||||
):
|
||||
default_value_keys.add(key)
|
||||
|
||||
# Only cleanup if there are "many" default keys (indicating a bloated file)
|
||||
@@ -807,7 +872,7 @@ class SettingsManager:
|
||||
if len(default_value_keys) >= DEFAULT_KEYS_CLEANUP_THRESHOLD:
|
||||
logger.info(
|
||||
"Cleaning up %d default value(s) from settings.json to keep it minimal",
|
||||
len(default_value_keys)
|
||||
len(default_value_keys),
|
||||
)
|
||||
self._save_settings()
|
||||
# Update original payload to match what we just saved
|
||||
@@ -817,8 +882,8 @@ class SettingsManager:
|
||||
if not self._standalone_mode:
|
||||
return
|
||||
|
||||
folder_paths = self.settings.get('folder_paths', {}) or {}
|
||||
monitored_keys = ('loras', 'checkpoints', 'embeddings')
|
||||
folder_paths = self.settings.get("folder_paths", {}) or {}
|
||||
monitored_keys = ("loras", "checkpoints", "embeddings")
|
||||
|
||||
has_valid_paths = False
|
||||
for key in monitored_keys:
|
||||
@@ -829,7 +894,10 @@ class SettingsManager:
|
||||
iterator = list(raw_paths)
|
||||
except TypeError:
|
||||
continue
|
||||
if any(isinstance(path, str) and path and os.path.exists(path) for path in iterator):
|
||||
if any(
|
||||
isinstance(path, str) and path and os.path.exists(path)
|
||||
for path in iterator
|
||||
):
|
||||
has_valid_paths = True
|
||||
break
|
||||
|
||||
@@ -860,13 +928,13 @@ class SettingsManager:
|
||||
def _get_default_settings(self) -> Dict[str, Any]:
|
||||
"""Return default settings"""
|
||||
defaults = copy.deepcopy(DEFAULT_SETTINGS)
|
||||
defaults['base_model_path_mappings'] = {}
|
||||
defaults['download_path_templates'] = {}
|
||||
defaults['priority_tags'] = DEFAULT_PRIORITY_TAG_CONFIG.copy()
|
||||
defaults.setdefault('folder_paths', {})
|
||||
defaults.setdefault('extra_folder_paths', {})
|
||||
defaults['auto_organize_exclusions'] = []
|
||||
defaults['metadata_refresh_skip_paths'] = []
|
||||
defaults["base_model_path_mappings"] = {}
|
||||
defaults["download_path_templates"] = {}
|
||||
defaults["priority_tags"] = DEFAULT_PRIORITY_TAG_CONFIG.copy()
|
||||
defaults.setdefault("folder_paths", {})
|
||||
defaults.setdefault("extra_folder_paths", {})
|
||||
defaults["auto_organize_exclusions"] = []
|
||||
defaults["metadata_refresh_skip_paths"] = []
|
||||
|
||||
library_name = defaults.get("active_library") or "default"
|
||||
default_library = self._build_library_payload(
|
||||
@@ -876,8 +944,8 @@ class SettingsManager:
|
||||
default_checkpoint_root=defaults.get("default_checkpoint_root"),
|
||||
default_embedding_root=defaults.get("default_embedding_root"),
|
||||
)
|
||||
defaults['libraries'] = {library_name: default_library}
|
||||
defaults['active_library'] = library_name
|
||||
defaults["libraries"] = {library_name: default_library}
|
||||
defaults["active_library"] = library_name
|
||||
return defaults
|
||||
|
||||
def _normalize_priority_tag_config(self, value: Any) -> Dict[str, str]:
|
||||
@@ -908,7 +976,9 @@ class SettingsManager:
|
||||
candidates: Iterable[str] = (
|
||||
value.replace("\n", ",").replace(";", ",").split(",")
|
||||
)
|
||||
elif isinstance(value, Sequence) and not isinstance(value, (bytes, bytearray, str)):
|
||||
elif isinstance(value, Sequence) and not isinstance(
|
||||
value, (bytes, bytearray, str)
|
||||
):
|
||||
candidates = value
|
||||
else:
|
||||
return []
|
||||
@@ -954,7 +1024,9 @@ class SettingsManager:
|
||||
candidates: Iterable[str] = (
|
||||
value.replace("\n", ",").replace(";", ",").split(",")
|
||||
)
|
||||
elif isinstance(value, Sequence) and not isinstance(value, (bytes, bytearray, str)):
|
||||
elif isinstance(value, Sequence) and not isinstance(
|
||||
value, (bytes, bytearray, str)
|
||||
):
|
||||
candidates = value
|
||||
else:
|
||||
return []
|
||||
@@ -1023,6 +1095,17 @@ class SettingsManager:
|
||||
self._save_settings()
|
||||
return base_models
|
||||
|
||||
def get_skip_previously_downloaded_model_versions(self) -> bool:
|
||||
value = self.settings.get("skip_previously_downloaded_model_versions", False)
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
normalized = False
|
||||
if isinstance(value, str):
|
||||
normalized = value.strip().lower() in {"1", "true", "yes", "on"}
|
||||
self.settings["skip_previously_downloaded_model_versions"] = normalized
|
||||
self._save_settings()
|
||||
return normalized
|
||||
|
||||
def get_extra_folder_paths(self) -> Dict[str, List[str]]:
|
||||
"""Get extra folder paths for the active library.
|
||||
|
||||
@@ -1060,7 +1143,9 @@ class SettingsManager:
|
||||
continue
|
||||
normalized = os.path.normcase(os.path.normpath(stripped))
|
||||
if os.path.exists(stripped):
|
||||
normalized = os.path.normcase(os.path.normpath(os.path.realpath(stripped)))
|
||||
normalized = os.path.normcase(
|
||||
os.path.normpath(os.path.realpath(stripped))
|
||||
)
|
||||
primary_real_paths.add(normalized)
|
||||
|
||||
primary_symlink_targets = set()
|
||||
@@ -1096,8 +1181,13 @@ class SettingsManager:
|
||||
continue
|
||||
normalized = os.path.normcase(os.path.normpath(stripped))
|
||||
if os.path.exists(stripped):
|
||||
normalized = os.path.normcase(os.path.normpath(os.path.realpath(stripped)))
|
||||
if normalized in primary_real_paths or normalized in primary_symlink_targets:
|
||||
normalized = os.path.normcase(
|
||||
os.path.normpath(os.path.realpath(stripped))
|
||||
)
|
||||
if (
|
||||
normalized in primary_real_paths
|
||||
or normalized in primary_symlink_targets
|
||||
):
|
||||
overlapping_paths.append(stripped)
|
||||
|
||||
if overlapping_paths:
|
||||
@@ -1161,19 +1251,19 @@ class SettingsManager:
|
||||
if key == "use_portable_settings" and isinstance(value, bool):
|
||||
portable_switch_pending = True
|
||||
self._prepare_portable_switch(value)
|
||||
if key == 'folder_paths' and isinstance(value, Mapping):
|
||||
if key == "folder_paths" and isinstance(value, Mapping):
|
||||
self._update_active_library_entry(folder_paths=value) # type: ignore[arg-type]
|
||||
elif key == 'extra_folder_paths' and isinstance(value, Mapping):
|
||||
elif key == "extra_folder_paths" and isinstance(value, Mapping):
|
||||
self._update_active_library_entry(extra_folder_paths=value) # type: ignore[arg-type]
|
||||
elif key == 'default_lora_root':
|
||||
elif key == "default_lora_root":
|
||||
self._update_active_library_entry(default_lora_root=str(value))
|
||||
elif key == 'default_checkpoint_root':
|
||||
elif key == "default_checkpoint_root":
|
||||
self._update_active_library_entry(default_checkpoint_root=str(value))
|
||||
elif key == 'default_unet_root':
|
||||
elif key == "default_unet_root":
|
||||
self._update_active_library_entry(default_unet_root=str(value))
|
||||
elif key == 'default_embedding_root':
|
||||
elif key == "default_embedding_root":
|
||||
self._update_active_library_entry(default_embedding_root=str(value))
|
||||
elif key == 'model_name_display':
|
||||
elif key == "model_name_display":
|
||||
self._notify_model_name_display_change(value)
|
||||
self._save_settings()
|
||||
if portable_switch_pending:
|
||||
@@ -1249,10 +1339,9 @@ class SettingsManager:
|
||||
|
||||
source_cache_dir = os.path.join(source_dir, "model_cache")
|
||||
target_cache_dir = os.path.join(target_dir, "model_cache")
|
||||
if (
|
||||
os.path.isdir(source_cache_dir)
|
||||
and os.path.abspath(source_cache_dir) != os.path.abspath(target_cache_dir)
|
||||
):
|
||||
if os.path.isdir(source_cache_dir) and os.path.abspath(
|
||||
source_cache_dir
|
||||
) != os.path.abspath(target_cache_dir):
|
||||
try:
|
||||
shutil.copytree(
|
||||
source_cache_dir,
|
||||
@@ -1270,10 +1359,9 @@ class SettingsManager:
|
||||
|
||||
source_cache_file = os.path.join(source_dir, "model_cache.sqlite")
|
||||
target_cache_file = os.path.join(target_dir, "model_cache.sqlite")
|
||||
if (
|
||||
os.path.isfile(source_cache_file)
|
||||
and os.path.abspath(source_cache_file) != os.path.abspath(target_cache_file)
|
||||
):
|
||||
if os.path.isfile(source_cache_file) and os.path.abspath(
|
||||
source_cache_file
|
||||
) != os.path.abspath(target_cache_file):
|
||||
try:
|
||||
shutil.copy2(source_cache_file, target_cache_file)
|
||||
except Exception as exc:
|
||||
@@ -1299,7 +1387,9 @@ class SettingsManager:
|
||||
try:
|
||||
os.makedirs(config_dir, exist_ok=True)
|
||||
except Exception as exc:
|
||||
logger.warning("Failed to create user config directory %s: %s", config_dir, exc)
|
||||
logger.warning(
|
||||
"Failed to create user config directory %s: %s", config_dir, exc
|
||||
)
|
||||
|
||||
return config_dir
|
||||
|
||||
@@ -1359,7 +1449,9 @@ class SettingsManager:
|
||||
try:
|
||||
asyncio.run(coroutine)
|
||||
except RuntimeError:
|
||||
logger.debug("Skipping name display update due to missing event loop")
|
||||
logger.debug(
|
||||
"Skipping name display update due to missing event loop"
|
||||
)
|
||||
continue
|
||||
|
||||
if loop is not None and target_loop is loop:
|
||||
@@ -1382,7 +1474,7 @@ class SettingsManager:
|
||||
"""Save settings to file"""
|
||||
try:
|
||||
payload = self._serialize_settings_for_disk()
|
||||
with open(self.settings_file, 'w', encoding='utf-8') as f:
|
||||
with open(self.settings_file, "w", encoding="utf-8") as f:
|
||||
json.dump(payload, f, indent=2)
|
||||
except Exception as e:
|
||||
logger.error(f"Error saving settings: {e}")
|
||||
@@ -1423,7 +1515,9 @@ class SettingsManager:
|
||||
minimal[key] = copy.deepcopy(value)
|
||||
# Complex objects need deep comparison
|
||||
elif isinstance(value, (dict, list)) and default_value is not None:
|
||||
if json.dumps(value, sort_keys=True, default=str) != json.dumps(default_value, sort_keys=True, default=str):
|
||||
if json.dumps(value, sort_keys=True, default=str) != json.dumps(
|
||||
default_value, sort_keys=True, default=str
|
||||
):
|
||||
minimal[key] = copy.deepcopy(value)
|
||||
# Simple values use direct comparison
|
||||
elif value != default_value:
|
||||
@@ -1500,9 +1594,15 @@ class SettingsManager:
|
||||
existing = libraries.get(name, {})
|
||||
|
||||
payload = self._build_library_payload(
|
||||
folder_paths=folder_paths if folder_paths is not None else existing.get("folder_paths"),
|
||||
extra_folder_paths=extra_folder_paths if extra_folder_paths is not None else existing.get("extra_folder_paths"),
|
||||
default_lora_root=default_lora_root if default_lora_root is not None else existing.get("default_lora_root"),
|
||||
folder_paths=folder_paths
|
||||
if folder_paths is not None
|
||||
else existing.get("folder_paths"),
|
||||
extra_folder_paths=extra_folder_paths
|
||||
if extra_folder_paths is not None
|
||||
else existing.get("extra_folder_paths"),
|
||||
default_lora_root=default_lora_root
|
||||
if default_lora_root is not None
|
||||
else existing.get("default_lora_root"),
|
||||
default_checkpoint_root=(
|
||||
default_checkpoint_root
|
||||
if default_checkpoint_root is not None
|
||||
@@ -1662,7 +1762,9 @@ class SettingsManager:
|
||||
if service and hasattr(service, "on_library_changed"):
|
||||
try:
|
||||
service.on_library_changed()
|
||||
except Exception as service_exc: # pragma: no cover - defensive logging
|
||||
except (
|
||||
Exception
|
||||
) as service_exc: # pragma: no cover - defensive logging
|
||||
logger.debug(
|
||||
"Service %s failed to handle library change: %s",
|
||||
service_name,
|
||||
@@ -1673,15 +1775,15 @@ class SettingsManager:
|
||||
|
||||
def get_download_path_template(self, model_type: str) -> str:
|
||||
"""Get download path template for specific model type
|
||||
|
||||
|
||||
Args:
|
||||
model_type: The type of model ('lora', 'checkpoint', 'embedding')
|
||||
|
||||
|
||||
Returns:
|
||||
Template string for the model type, defaults to '{base_model}/{first_tag}'
|
||||
"""
|
||||
templates = self.settings.get('download_path_templates', {})
|
||||
|
||||
templates = self.settings.get("download_path_templates", {})
|
||||
|
||||
# Handle edge case where templates might be stored as JSON string
|
||||
if isinstance(templates, str):
|
||||
try:
|
||||
@@ -1689,36 +1791,40 @@ class SettingsManager:
|
||||
parsed_templates = json.loads(templates)
|
||||
if isinstance(parsed_templates, dict):
|
||||
# Update settings with parsed dictionary
|
||||
self.settings['download_path_templates'] = parsed_templates
|
||||
self.settings["download_path_templates"] = parsed_templates
|
||||
self._save_settings()
|
||||
templates = parsed_templates
|
||||
logger.info("Successfully parsed download_path_templates from JSON string")
|
||||
logger.info(
|
||||
"Successfully parsed download_path_templates from JSON string"
|
||||
)
|
||||
else:
|
||||
raise ValueError("Parsed JSON is not a dictionary")
|
||||
except (json.JSONDecodeError, ValueError) as e:
|
||||
# If parsing fails, set default values
|
||||
logger.warning(f"Failed to parse download_path_templates JSON string: {e}. Setting default values.")
|
||||
default_template = '{base_model}/{first_tag}'
|
||||
logger.warning(
|
||||
f"Failed to parse download_path_templates JSON string: {e}. Setting default values."
|
||||
)
|
||||
default_template = "{base_model}/{first_tag}"
|
||||
templates = {
|
||||
'lora': default_template,
|
||||
'checkpoint': default_template,
|
||||
'embedding': default_template
|
||||
"lora": default_template,
|
||||
"checkpoint": default_template,
|
||||
"embedding": default_template,
|
||||
}
|
||||
self.settings['download_path_templates'] = templates
|
||||
self.settings["download_path_templates"] = templates
|
||||
self._save_settings()
|
||||
|
||||
|
||||
# Ensure templates is a dictionary
|
||||
if not isinstance(templates, dict):
|
||||
default_template = '{base_model}/{first_tag}'
|
||||
default_template = "{base_model}/{first_tag}"
|
||||
templates = {
|
||||
'lora': default_template,
|
||||
'checkpoint': default_template,
|
||||
'embedding': default_template
|
||||
"lora": default_template,
|
||||
"checkpoint": default_template,
|
||||
"embedding": default_template,
|
||||
}
|
||||
self.settings['download_path_templates'] = templates
|
||||
self.settings["download_path_templates"] = templates
|
||||
self._save_settings()
|
||||
|
||||
return templates.get(model_type, '{base_model}/{first_tag}')
|
||||
|
||||
return templates.get(model_type, "{base_model}/{first_tag}")
|
||||
|
||||
|
||||
_SETTINGS_MANAGER: Optional["SettingsManager"] = None
|
||||
|
||||
@@ -22,7 +22,9 @@ def _normalize_commercial_values(value: Any) -> Sequence[str]:
|
||||
|
||||
def _split_aggregate(value_str: str) -> list[str]:
|
||||
stripped = value_str.strip()
|
||||
looks_aggregate = "," in stripped or (stripped.startswith("{") and stripped.endswith("}"))
|
||||
looks_aggregate = "," in stripped or (
|
||||
stripped.startswith("{") and stripped.endswith("}")
|
||||
)
|
||||
if not looks_aggregate:
|
||||
return [value_str]
|
||||
|
||||
@@ -141,14 +143,18 @@ def build_license_flags(payload: Mapping[str, Any] | None) -> int:
|
||||
return flags
|
||||
|
||||
|
||||
def resolve_license_info(model_data: Mapping[str, Any] | None) -> tuple[Dict[str, Any], int]:
|
||||
def resolve_license_info(
|
||||
model_data: Mapping[str, Any] | None,
|
||||
) -> tuple[Dict[str, Any], int]:
|
||||
"""Return normalized license payload and its encoded bitset."""
|
||||
|
||||
payload = resolve_license_payload(model_data)
|
||||
return payload, build_license_flags(payload)
|
||||
|
||||
|
||||
def rewrite_preview_url(source_url: str | None, media_type: str | None = None) -> tuple[str | None, bool]:
|
||||
def rewrite_preview_url(
|
||||
source_url: str | None, media_type: str | None = None
|
||||
) -> tuple[str | None, bool]:
|
||||
"""Rewrite Civitai preview URLs to use optimized renditions.
|
||||
|
||||
Args:
|
||||
@@ -168,7 +174,12 @@ def rewrite_preview_url(source_url: str | None, media_type: str | None = None) -
|
||||
except ValueError:
|
||||
return source_url, False
|
||||
|
||||
if parsed.netloc.lower() != "image.civitai.com":
|
||||
hostname = parsed.hostname
|
||||
if hostname is None:
|
||||
return source_url, False
|
||||
|
||||
hostname = hostname.lower()
|
||||
if hostname == "civitai.com" or not hostname.endswith(".civitai.com"):
|
||||
return source_url, False
|
||||
|
||||
replacement = "/width=450,optimized=true"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-lora-manager"
|
||||
description = "Revolutionize your workflow with the ultimate LoRA companion for ComfyUI!"
|
||||
version = "1.0.0"
|
||||
version = "1.0.2"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = [
|
||||
"aiohttp",
|
||||
|
||||
@@ -146,6 +146,10 @@ export class SettingsManager {
|
||||
backendSettings?.metadata_refresh_skip_paths ?? defaults.metadata_refresh_skip_paths
|
||||
);
|
||||
|
||||
merged.skip_previously_downloaded_model_versions =
|
||||
backendSettings?.skip_previously_downloaded_model_versions
|
||||
?? defaults.skip_previously_downloaded_model_versions;
|
||||
|
||||
merged.download_skip_base_models = this.normalizeDownloadSkipBaseModels(
|
||||
backendSettings?.download_skip_base_models ?? defaults.download_skip_base_models
|
||||
);
|
||||
@@ -836,6 +840,12 @@ export class SettingsManager {
|
||||
hideEarlyAccessUpdatesCheckbox.checked = state.global.settings.hide_early_access_updates || false;
|
||||
}
|
||||
|
||||
const skipPreviouslyDownloadedModelVersionsCheckbox = document.getElementById('skipPreviouslyDownloadedModelVersions');
|
||||
if (skipPreviouslyDownloadedModelVersionsCheckbox) {
|
||||
skipPreviouslyDownloadedModelVersionsCheckbox.checked =
|
||||
state.global.settings.skip_previously_downloaded_model_versions || false;
|
||||
}
|
||||
|
||||
// Set optimize example images setting
|
||||
const optimizeExampleImagesCheckbox = document.getElementById('optimizeExampleImages');
|
||||
if (optimizeExampleImagesCheckbox) {
|
||||
@@ -1246,10 +1256,7 @@ export class SettingsManager {
|
||||
throw new Error('No LoRA roots found');
|
||||
}
|
||||
|
||||
// Clear existing options except the first one (No Default)
|
||||
const noDefaultOption = defaultLoraRootSelect.querySelector('option[value=""]');
|
||||
defaultLoraRootSelect.innerHTML = '';
|
||||
defaultLoraRootSelect.appendChild(noDefaultOption);
|
||||
|
||||
// Add options for each root
|
||||
data.roots.forEach(root => {
|
||||
@@ -1259,9 +1266,8 @@ export class SettingsManager {
|
||||
defaultLoraRootSelect.appendChild(option);
|
||||
});
|
||||
|
||||
// Set selected value from settings
|
||||
const defaultRoot = state.global.settings.default_lora_root || '';
|
||||
defaultLoraRootSelect.value = defaultRoot;
|
||||
defaultLoraRootSelect.value = data.roots.includes(defaultRoot) ? defaultRoot : data.roots[0];
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading LoRA roots:', error);
|
||||
@@ -1285,10 +1291,7 @@ export class SettingsManager {
|
||||
throw new Error('No checkpoint roots found');
|
||||
}
|
||||
|
||||
// Clear existing options except first one (No Default)
|
||||
const noDefaultOption = defaultCheckpointRootSelect.querySelector('option[value=""]');
|
||||
defaultCheckpointRootSelect.innerHTML = '';
|
||||
defaultCheckpointRootSelect.appendChild(noDefaultOption);
|
||||
|
||||
// Add options for each root
|
||||
data.roots.forEach(root => {
|
||||
@@ -1298,9 +1301,8 @@ export class SettingsManager {
|
||||
defaultCheckpointRootSelect.appendChild(option);
|
||||
});
|
||||
|
||||
// Set selected value from settings
|
||||
const defaultRoot = state.global.settings.default_checkpoint_root || '';
|
||||
defaultCheckpointRootSelect.value = defaultRoot;
|
||||
defaultCheckpointRootSelect.value = data.roots.includes(defaultRoot) ? defaultRoot : data.roots[0];
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading checkpoint roots:', error);
|
||||
@@ -1324,10 +1326,7 @@ export class SettingsManager {
|
||||
throw new Error('No diffusion model roots found');
|
||||
}
|
||||
|
||||
// Clear existing options except first one (No Default)
|
||||
const noDefaultOption = defaultUnetRootSelect.querySelector('option[value=""]');
|
||||
defaultUnetRootSelect.innerHTML = '';
|
||||
defaultUnetRootSelect.appendChild(noDefaultOption);
|
||||
|
||||
// Add options for each root
|
||||
data.roots.forEach(root => {
|
||||
@@ -1337,9 +1336,8 @@ export class SettingsManager {
|
||||
defaultUnetRootSelect.appendChild(option);
|
||||
});
|
||||
|
||||
// Set selected value from settings
|
||||
const defaultRoot = state.global.settings.default_unet_root || '';
|
||||
defaultUnetRootSelect.value = defaultRoot;
|
||||
defaultUnetRootSelect.value = data.roots.includes(defaultRoot) ? defaultRoot : data.roots[0];
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading diffusion model roots:', error);
|
||||
@@ -1363,10 +1361,7 @@ export class SettingsManager {
|
||||
throw new Error('No embedding roots found');
|
||||
}
|
||||
|
||||
// Clear existing options except first one (No Default)
|
||||
const noDefaultOption = defaultEmbeddingRootSelect.querySelector('option[value=""]');
|
||||
defaultEmbeddingRootSelect.innerHTML = '';
|
||||
defaultEmbeddingRootSelect.appendChild(noDefaultOption);
|
||||
|
||||
// Add options for each root
|
||||
data.roots.forEach(root => {
|
||||
@@ -1376,9 +1371,8 @@ export class SettingsManager {
|
||||
defaultEmbeddingRootSelect.appendChild(option);
|
||||
});
|
||||
|
||||
// Set selected value from settings
|
||||
const defaultRoot = state.global.settings.default_embedding_root || '';
|
||||
defaultEmbeddingRootSelect.value = defaultRoot;
|
||||
defaultEmbeddingRootSelect.value = data.roots.includes(defaultRoot) ? defaultRoot : data.roots[0];
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading embedding roots:', error);
|
||||
@@ -1477,7 +1471,7 @@ export class SettingsManager {
|
||||
try {
|
||||
// Save to backend - this triggers path validation
|
||||
await this.saveSetting('extra_folder_paths', extraFolderPaths);
|
||||
showToast('toast.settings.settingsUpdated', { setting: 'Extra Folder Paths' }, 'success');
|
||||
showToast('settings.extraFolderPaths.saveSuccess', {}, 'success');
|
||||
|
||||
// Add empty row if no valid paths exist for the changed type
|
||||
const container = document.getElementById(`extraFolderPaths-${changedModelType}`);
|
||||
|
||||
@@ -38,6 +38,7 @@ const DEFAULT_SETTINGS_BASE = Object.freeze({
|
||||
hide_early_access_updates: false,
|
||||
auto_organize_exclusions: [],
|
||||
metadata_refresh_skip_paths: [],
|
||||
skip_previously_downloaded_model_versions: false,
|
||||
download_skip_base_models: [],
|
||||
});
|
||||
|
||||
|
||||
@@ -30,8 +30,9 @@ export function rewriteCivitaiUrl(sourceUrl, mediaType = null, mode = Optimizati
|
||||
try {
|
||||
const url = new URL(sourceUrl);
|
||||
|
||||
// Check if it's a CivitAI image domain
|
||||
if (url.hostname.toLowerCase() !== 'image.civitai.com') {
|
||||
// Check if it's a CivitAI CDN domain (supports all subdomains like image-b2.civitai.com)
|
||||
const hostname = url.hostname.toLowerCase();
|
||||
if (hostname === 'civitai.com' || !hostname.endsWith('.civitai.com')) {
|
||||
return [sourceUrl, false];
|
||||
}
|
||||
|
||||
@@ -112,7 +113,8 @@ export function isCivitaiUrl(url) {
|
||||
if (!url) return false;
|
||||
try {
|
||||
const parsed = new URL(url);
|
||||
return parsed.hostname.toLowerCase() === 'image.civitai.com';
|
||||
const hostname = parsed.hostname.toLowerCase();
|
||||
return hostname.endsWith('.civitai.com') && hostname !== 'civitai.com';
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -484,9 +484,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="setting-control select-control">
|
||||
<select id="defaultLoraRoot" onchange="settingsManager.saveSelectSetting('defaultLoraRoot', 'default_lora_root')">
|
||||
<option value="">{{ t('settings.folderSettings.noDefault') }}</option>
|
||||
</select>
|
||||
<select id="defaultLoraRoot" onchange="settingsManager.saveSelectSetting('defaultLoraRoot', 'default_lora_root')"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -500,9 +498,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="setting-control select-control">
|
||||
<select id="defaultCheckpointRoot" onchange="settingsManager.saveSelectSetting('defaultCheckpointRoot', 'default_checkpoint_root')">
|
||||
<option value="">{{ t('settings.folderSettings.noDefault') }}</option>
|
||||
</select>
|
||||
<select id="defaultCheckpointRoot" onchange="settingsManager.saveSelectSetting('defaultCheckpointRoot', 'default_checkpoint_root')"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -516,9 +512,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="setting-control select-control">
|
||||
<select id="defaultUnetRoot" onchange="settingsManager.saveSelectSetting('defaultUnetRoot', 'default_unet_root')">
|
||||
<option value="">{{ t('settings.folderSettings.noDefault') }}</option>
|
||||
</select>
|
||||
<select id="defaultUnetRoot" onchange="settingsManager.saveSelectSetting('defaultUnetRoot', 'default_unet_root')"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -532,9 +526,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="setting-control select-control">
|
||||
<select id="defaultEmbeddingRoot" onchange="settingsManager.saveSelectSetting('defaultEmbeddingRoot', 'default_embedding_root')">
|
||||
<option value="">{{ t('settings.folderSettings.noDefault') }}</option>
|
||||
</select>
|
||||
<select id="defaultEmbeddingRoot" onchange="settingsManager.saveSelectSetting('defaultEmbeddingRoot', 'default_embedding_root')"></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -545,7 +537,7 @@
|
||||
<div class="settings-subsection-header">
|
||||
<h4>
|
||||
{{ t('settings.extraFolderPaths.title') }}
|
||||
<i class="fas fa-info-circle info-icon" data-tooltip="{{ t('settings.extraFolderPaths.help') }}"></i>
|
||||
<i class="fas fa-sync-alt restart-required-icon" title="{{ t('settings.extraFolderPaths.restartRequired') }}"></i>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
@@ -743,6 +735,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label for="skipPreviouslyDownloadedModelVersions">
|
||||
{{ t('settings.skipPreviouslyDownloadedModelVersions.label') }}
|
||||
<i class="fas fa-info-circle info-icon" data-tooltip="{{ t('settings.skipPreviouslyDownloadedModelVersions.help') }}"></i>
|
||||
</label>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<label class="toggle-switch">
|
||||
<input type="checkbox" id="skipPreviouslyDownloadedModelVersions"
|
||||
onchange="settingsManager.saveToggleSetting('skipPreviouslyDownloadedModelVersions', 'skip_previously_downloaded_model_versions')">
|
||||
<span class="toggle-slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
|
||||
@@ -131,6 +131,102 @@ def test_save_paths_logs_warning_when_upsert_fails(
|
||||
assert "Failed to save folder paths: boom" in caplog.text
|
||||
|
||||
|
||||
def test_save_paths_repairs_empty_default_roots(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
folder_paths = _setup_config_environment(monkeypatch, tmp_path)
|
||||
|
||||
class FakeSettingsService:
|
||||
def get_libraries(self):
|
||||
return {
|
||||
"comfyui": {
|
||||
"folder_paths": {key: list(value) for key, value in folder_paths.items()},
|
||||
"default_lora_root": "",
|
||||
"default_checkpoint_root": "",
|
||||
"default_embedding_root": "",
|
||||
}
|
||||
}
|
||||
|
||||
def rename_library(self, *_):
|
||||
raise AssertionError("rename_library should not be invoked")
|
||||
|
||||
def upsert_library(self, name: str, **payload):
|
||||
self.name = name
|
||||
self.payload = payload
|
||||
|
||||
fake_settings = FakeSettingsService()
|
||||
monkeypatch.setattr(settings_manager_module, "settings", fake_settings)
|
||||
|
||||
config_module.Config()
|
||||
|
||||
assert fake_settings.name == "comfyui"
|
||||
assert fake_settings.payload["default_lora_root"] == folder_paths["loras"][0].replace("\\", "/")
|
||||
assert fake_settings.payload["default_checkpoint_root"] == folder_paths["checkpoints"][0].replace("\\", "/")
|
||||
assert fake_settings.payload["default_embedding_root"] == folder_paths["embeddings"][0].replace("\\", "/")
|
||||
|
||||
|
||||
def test_save_paths_repairs_stale_default_roots(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
folder_paths = _setup_config_environment(monkeypatch, tmp_path)
|
||||
|
||||
class FakeSettingsService:
|
||||
def get_libraries(self):
|
||||
return {
|
||||
"comfyui": {
|
||||
"folder_paths": {key: list(value) for key, value in folder_paths.items()},
|
||||
"default_lora_root": "/stale/loras",
|
||||
"default_checkpoint_root": "/stale/checkpoints",
|
||||
"default_embedding_root": "/stale/embeddings",
|
||||
}
|
||||
}
|
||||
|
||||
def rename_library(self, *_):
|
||||
raise AssertionError("rename_library should not be invoked")
|
||||
|
||||
def upsert_library(self, name: str, **payload):
|
||||
self.name = name
|
||||
self.payload = payload
|
||||
|
||||
fake_settings = FakeSettingsService()
|
||||
monkeypatch.setattr(settings_manager_module, "settings", fake_settings)
|
||||
|
||||
config_module.Config()
|
||||
|
||||
assert fake_settings.name == "comfyui"
|
||||
assert fake_settings.payload["default_lora_root"] == folder_paths["loras"][0].replace("\\", "/")
|
||||
assert fake_settings.payload["default_checkpoint_root"] == folder_paths["checkpoints"][0].replace("\\", "/")
|
||||
assert fake_settings.payload["default_embedding_root"] == folder_paths["embeddings"][0].replace("\\", "/")
|
||||
|
||||
|
||||
def test_save_paths_keeps_valid_default_roots(monkeypatch: pytest.MonkeyPatch, tmp_path):
|
||||
folder_paths = _setup_config_environment(monkeypatch, tmp_path)
|
||||
|
||||
class FakeSettingsService:
|
||||
def get_libraries(self):
|
||||
return {
|
||||
"comfyui": {
|
||||
"folder_paths": {key: list(value) for key, value in folder_paths.items()},
|
||||
"default_lora_root": folder_paths["loras"][0],
|
||||
"default_checkpoint_root": folder_paths["checkpoints"][0],
|
||||
"default_embedding_root": folder_paths["embeddings"][0],
|
||||
}
|
||||
}
|
||||
|
||||
def rename_library(self, *_):
|
||||
raise AssertionError("rename_library should not be invoked")
|
||||
|
||||
def upsert_library(self, name: str, **payload):
|
||||
self.name = name
|
||||
self.payload = payload
|
||||
|
||||
fake_settings = FakeSettingsService()
|
||||
monkeypatch.setattr(settings_manager_module, "settings", fake_settings)
|
||||
|
||||
config_module.Config()
|
||||
|
||||
assert fake_settings.name == "comfyui"
|
||||
assert fake_settings.payload["default_lora_root"] == folder_paths["loras"][0].replace("\\", "/")
|
||||
assert fake_settings.payload["default_checkpoint_root"] == folder_paths["checkpoints"][0].replace("\\", "/")
|
||||
assert fake_settings.payload["default_embedding_root"] == folder_paths["embeddings"][0].replace("\\", "/")
|
||||
|
||||
|
||||
def test_save_paths_removes_template_default_library(monkeypatch, tmp_path):
|
||||
folder_paths = _setup_config_environment(monkeypatch, tmp_path)
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ vi.mock('../../../static/js/state/index.js', () => {
|
||||
},
|
||||
createDefaultSettings: () => ({
|
||||
language: 'en',
|
||||
skip_previously_downloaded_model_versions: false,
|
||||
download_skip_base_models: [],
|
||||
}),
|
||||
};
|
||||
@@ -117,6 +118,7 @@ describe('SettingsManager download skip base models UI', () => {
|
||||
document.body.innerHTML = '';
|
||||
vi.clearAllMocks();
|
||||
state.global.settings = {
|
||||
skip_previously_downloaded_model_versions: false,
|
||||
download_skip_base_models: [],
|
||||
};
|
||||
});
|
||||
@@ -150,4 +152,31 @@ describe('SettingsManager download skip base models UI', () => {
|
||||
expect(document.querySelectorAll('#downloadSkipBaseModelsContainer input')).toHaveLength(0);
|
||||
expect(document.getElementById('downloadSkipBaseModelsEmpty').hidden).toBe(false);
|
||||
});
|
||||
|
||||
it('initializes the previously-downloaded-version toggle from settings', () => {
|
||||
document.body.innerHTML = '<input id="skipPreviouslyDownloadedModelVersions" type="checkbox" />';
|
||||
state.global.settings.skip_previously_downloaded_model_versions = true;
|
||||
const manager = createManager();
|
||||
|
||||
manager.loadSettingsToUI();
|
||||
|
||||
expect(document.getElementById('skipPreviouslyDownloadedModelVersions').checked).toBe(true);
|
||||
});
|
||||
|
||||
it('saves the previously-downloaded-version toggle with the expected setting key', async () => {
|
||||
document.body.innerHTML = '<input id="skipPreviouslyDownloadedModelVersions" type="checkbox" checked />';
|
||||
const manager = createManager();
|
||||
manager.saveSetting = vi.fn().mockResolvedValue();
|
||||
manager.applyFrontendSettings = vi.fn();
|
||||
|
||||
await manager.saveToggleSetting(
|
||||
'skipPreviouslyDownloadedModelVersions',
|
||||
'skip_previously_downloaded_model_versions',
|
||||
);
|
||||
|
||||
expect(manager.saveSetting).toHaveBeenCalledWith(
|
||||
'skip_previously_downloaded_model_versions',
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -94,6 +94,37 @@ describe('civitaiUtils', () => {
|
||||
expect(wasRewritten).toBe(false);
|
||||
expect(rewritten).toBe('not-a-valid-url');
|
||||
});
|
||||
|
||||
it('should rewrite URLs from CivitAI CDN subdomains', () => {
|
||||
const originalUrl = 'https://image-b2.civitai.com/file/civitai-media-cache/original=true/sample.png';
|
||||
const [rewritten, wasRewritten] = rewriteCivitaiUrl(originalUrl, 'image', OptimizationMode.THUMBNAIL);
|
||||
|
||||
expect(wasRewritten).toBe(true);
|
||||
expect(rewritten).toBe('https://image-b2.civitai.com/file/civitai-media-cache/width=450,optimized=true/sample.png');
|
||||
});
|
||||
|
||||
it('should handle URLs with explicit port numbers', () => {
|
||||
const originalUrl = 'https://image.civitai.com:443/checkpoints/original=true/test.png';
|
||||
const [rewritten, wasRewritten] = rewriteCivitaiUrl(originalUrl, 'image', OptimizationMode.THUMBNAIL);
|
||||
|
||||
expect(wasRewritten).toBe(true);
|
||||
// JavaScript URL.toString() removes default HTTPS port (443)
|
||||
expect(rewritten).toBe('https://image.civitai.com/checkpoints/width=450,optimized=true/test.png');
|
||||
});
|
||||
|
||||
it('should handle case-insensitive hostnames', () => {
|
||||
const testCases = [
|
||||
'https://IMAGE.CIVITAI.COM/original=true/test.png',
|
||||
'https://Image.Civitai.Com/original=true/test.png',
|
||||
'https://image-b2.CIVITAI.com/original=true/test.png',
|
||||
];
|
||||
|
||||
for (const url of testCases) {
|
||||
const [rewritten, wasRewritten] = rewriteCivitaiUrl(url, 'image', OptimizationMode.THUMBNAIL);
|
||||
expect(wasRewritten).toBe(true);
|
||||
expect(rewritten).toContain('width=450,optimized=true');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('getOptimizedUrl', () => {
|
||||
@@ -157,6 +188,23 @@ describe('civitaiUtils', () => {
|
||||
expect(isCivitaiUrl('https://image.civitai.com/')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for CivitAI CDN subdomains', () => {
|
||||
expect(isCivitaiUrl('https://image-b2.civitai.com/file/test.png')).toBe(true);
|
||||
expect(isCivitaiUrl('https://image-b3.civitai.com/test.jpg')).toBe(true);
|
||||
expect(isCivitaiUrl('https://cdn.civitai.com/test.png')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for CivitAI URLs with explicit ports', () => {
|
||||
expect(isCivitaiUrl('https://image.civitai.com:443/test.png')).toBe(true);
|
||||
expect(isCivitaiUrl('https://image-b2.civitai.com:443/file/test.jpg')).toBe(true);
|
||||
});
|
||||
|
||||
it('should handle case-insensitive hostnames', () => {
|
||||
expect(isCivitaiUrl('https://IMAGE.CIVITAI.COM/test.png')).toBe(true);
|
||||
expect(isCivitaiUrl('https://Image.Civitai.Com/test.png')).toBe(true);
|
||||
expect(isCivitaiUrl('https://image-b2.CIVITAI.com/test.png')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for non-CivitAI URLs', () => {
|
||||
expect(isCivitaiUrl('https://example.com/image.jpg')).toBe(false);
|
||||
expect(isCivitaiUrl('https://civitai.com/image.jpg')).toBe(false);
|
||||
|
||||
151
tests/frontend/utils/loraChainTraversal.test.js
Normal file
151
tests/frontend/utils/loraChainTraversal.test.js
Normal file
@@ -0,0 +1,151 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { APP_MODULE, UTILS_MODULE } = vi.hoisted(() => ({
|
||||
APP_MODULE: new URL("../../../scripts/app.js", import.meta.url).pathname,
|
||||
UTILS_MODULE: new URL("../../../web/comfyui/utils.js", import.meta.url).pathname,
|
||||
}));
|
||||
|
||||
vi.mock(APP_MODULE, () => ({
|
||||
app: {
|
||||
graph: null,
|
||||
registerExtension: vi.fn(),
|
||||
ui: {
|
||||
settings: {
|
||||
getSettingValue: vi.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
describe("LoRA chain traversal", () => {
|
||||
let collectActiveLorasFromChain;
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
({ collectActiveLorasFromChain } = await import(UTILS_MODULE));
|
||||
});
|
||||
|
||||
function createGraph(nodes, links) {
|
||||
const graph = {
|
||||
_nodes: nodes,
|
||||
links,
|
||||
getNodeById(id) {
|
||||
return nodes.find((node) => node.id === id) ?? null;
|
||||
},
|
||||
};
|
||||
|
||||
nodes.forEach((node) => {
|
||||
node.graph = graph;
|
||||
});
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
it("aggregates active LoRAs through a combiner with multiple LORA_STACK inputs", () => {
|
||||
const randomizerA = {
|
||||
id: 1,
|
||||
comfyClass: "Lora Randomizer (LoraManager)",
|
||||
mode: 0,
|
||||
widgets: [
|
||||
{
|
||||
name: "loras",
|
||||
value: [
|
||||
{ name: "Alpha", active: true },
|
||||
{ name: "Ignored", active: false },
|
||||
],
|
||||
},
|
||||
],
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
};
|
||||
const randomizerB = {
|
||||
id: 2,
|
||||
comfyClass: "Lora Randomizer (LoraManager)",
|
||||
mode: 0,
|
||||
widgets: [
|
||||
{
|
||||
name: "loras",
|
||||
value: [{ name: "Beta", active: true }],
|
||||
},
|
||||
],
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
};
|
||||
const combiner = {
|
||||
id: 3,
|
||||
comfyClass: "Lora Stack Combiner (LoraManager)",
|
||||
mode: 0,
|
||||
widgets: [],
|
||||
inputs: [
|
||||
{ name: "lora_stack_a", type: "LORA_STACK", link: 11 },
|
||||
{ name: "lora_stack_b", type: "LORA_STACK", link: 12 },
|
||||
],
|
||||
outputs: [],
|
||||
};
|
||||
const loader = {
|
||||
id: 4,
|
||||
comfyClass: "Lora Loader (LoraManager)",
|
||||
mode: 0,
|
||||
widgets: [],
|
||||
inputs: [{ name: "lora_stack", type: "LORA_STACK", link: 13 }],
|
||||
outputs: [],
|
||||
};
|
||||
|
||||
createGraph(
|
||||
[randomizerA, randomizerB, combiner, loader],
|
||||
{
|
||||
11: { origin_id: 1, target_id: 3 },
|
||||
12: { origin_id: 2, target_id: 3 },
|
||||
13: { origin_id: 3, target_id: 4 },
|
||||
}
|
||||
);
|
||||
|
||||
const result = collectActiveLorasFromChain(loader);
|
||||
|
||||
expect([...result]).toEqual(["Alpha", "Beta"]);
|
||||
});
|
||||
|
||||
it("stops propagation when the combiner is inactive", () => {
|
||||
const randomizer = {
|
||||
id: 1,
|
||||
comfyClass: "Lora Randomizer (LoraManager)",
|
||||
mode: 0,
|
||||
widgets: [
|
||||
{
|
||||
name: "loras",
|
||||
value: [{ name: "Alpha", active: true }],
|
||||
},
|
||||
],
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
};
|
||||
const combiner = {
|
||||
id: 2,
|
||||
comfyClass: "Lora Stack Combiner (LoraManager)",
|
||||
mode: 2,
|
||||
widgets: [],
|
||||
inputs: [{ name: "lora_stack_a", type: "LORA_STACK", link: 21 }],
|
||||
outputs: [],
|
||||
};
|
||||
const loader = {
|
||||
id: 3,
|
||||
comfyClass: "Lora Loader (LoraManager)",
|
||||
mode: 0,
|
||||
widgets: [],
|
||||
inputs: [{ name: "lora_stack", type: "LORA_STACK", link: 22 }],
|
||||
outputs: [],
|
||||
};
|
||||
|
||||
createGraph(
|
||||
[randomizer, combiner, loader],
|
||||
{
|
||||
21: { origin_id: 1, target_id: 2 },
|
||||
22: { origin_id: 2, target_id: 3 },
|
||||
}
|
||||
);
|
||||
|
||||
const result = collectActiveLorasFromChain(loader);
|
||||
|
||||
expect(result.size).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,10 @@ import pytest
|
||||
from aiohttp import web
|
||||
from aiohttp.test_utils import make_mocked_request
|
||||
|
||||
from py.middleware.csp_middleware import REMOTE_MEDIA_SOURCES, relax_csp_for_remote_media
|
||||
from py.middleware.csp_middleware import (
|
||||
REMOTE_MEDIA_SOURCES,
|
||||
relax_csp_for_remote_media,
|
||||
)
|
||||
|
||||
DEFAULT_CSP = (
|
||||
"default-src 'self'; "
|
||||
@@ -40,7 +43,9 @@ async def _invoke_middleware(
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_relax_csp_appends_remote_sources_and_preserves_existing_directives() -> None:
|
||||
async def test_relax_csp_appends_remote_sources_and_preserves_existing_directives() -> (
|
||||
None
|
||||
):
|
||||
response = await _invoke_middleware("/some-path", web.Response())
|
||||
header_value = response.headers.get("Content-Security-Policy")
|
||||
assert header_value is not None
|
||||
@@ -48,16 +53,17 @@ async def test_relax_csp_appends_remote_sources_and_preserves_existing_directive
|
||||
directives = _parse_directives(header_value)
|
||||
|
||||
# Existing directives remain intact
|
||||
assert directives["script-src"] == ["'self'", "'unsafe-inline'", "'unsafe-eval'", "blob:"]
|
||||
assert directives["script-src"] == [
|
||||
"'self'",
|
||||
"'unsafe-inline'",
|
||||
"'unsafe-eval'",
|
||||
"blob:",
|
||||
]
|
||||
assert directives["img-src"][:3] == ["'self'", "data:", "blob:"]
|
||||
|
||||
# Remote media hosts are added once to the relevant directives
|
||||
for source in REMOTE_MEDIA_SOURCES:
|
||||
assert source in directives["img-src"]
|
||||
|
||||
assert "media-src" in directives
|
||||
assert directives["media-src"][0] == "'self'"
|
||||
for source in REMOTE_MEDIA_SOURCES:
|
||||
assert source in directives["media-src"]
|
||||
|
||||
|
||||
|
||||
109
tests/nodes/test_lora_cycler.py
Normal file
109
tests/nodes/test_lora_cycler.py
Normal file
@@ -0,0 +1,109 @@
|
||||
"""Tests for preset strength behavior in LoraCyclerLM."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
import pytest
|
||||
|
||||
from py.nodes.lora_cycler import LoraCyclerLM
|
||||
from py.services import service_registry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cycler_node():
|
||||
return LoraCyclerLM()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cycler_config():
|
||||
return {
|
||||
"current_index": 1,
|
||||
"model_strength": 0.8,
|
||||
"clip_strength": 0.6,
|
||||
"use_same_clip_strength": False,
|
||||
"use_preset_strength": True,
|
||||
"preset_strength_scale": 1.5,
|
||||
"include_no_lora": False,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cycler_uses_scaled_preset_strength_when_available(
|
||||
cycler_node, cycler_config, mock_scanner, monkeypatch
|
||||
):
|
||||
monkeypatch.setattr(
|
||||
service_registry.ServiceRegistry,
|
||||
"get_lora_scanner",
|
||||
AsyncMock(return_value=mock_scanner),
|
||||
)
|
||||
|
||||
mock_scanner._cache.raw_data = [
|
||||
{
|
||||
"file_name": "preset_lora.safetensors",
|
||||
"file_path": "/models/loras/preset_lora.safetensors",
|
||||
"folder": "",
|
||||
"usage_tips": '{"strength": 0.7, "clipStrength": 0.5}',
|
||||
}
|
||||
]
|
||||
|
||||
result = await cycler_node.cycle(cycler_config)
|
||||
|
||||
assert result["result"][0] == [
|
||||
("/models/loras/preset_lora.safetensors", 1.05, 0.75)
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cycler_falls_back_to_manual_strength_when_preset_missing(
|
||||
cycler_node, cycler_config, mock_scanner, monkeypatch
|
||||
):
|
||||
monkeypatch.setattr(
|
||||
service_registry.ServiceRegistry,
|
||||
"get_lora_scanner",
|
||||
AsyncMock(return_value=mock_scanner),
|
||||
)
|
||||
|
||||
mock_scanner._cache.raw_data = [
|
||||
{
|
||||
"file_name": "manual_lora.safetensors",
|
||||
"file_path": "/models/loras/manual_lora.safetensors",
|
||||
"folder": "",
|
||||
"usage_tips": "",
|
||||
}
|
||||
]
|
||||
|
||||
result = await cycler_node.cycle(cycler_config)
|
||||
|
||||
assert result["result"][0] == [
|
||||
("/models/loras/manual_lora.safetensors", 0.8, 0.6)
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cycler_syncs_clip_to_model_when_same_clip_strength_enabled(
|
||||
cycler_node, cycler_config, mock_scanner, monkeypatch
|
||||
):
|
||||
monkeypatch.setattr(
|
||||
service_registry.ServiceRegistry,
|
||||
"get_lora_scanner",
|
||||
AsyncMock(return_value=mock_scanner),
|
||||
)
|
||||
|
||||
mock_scanner._cache.raw_data = [
|
||||
{
|
||||
"file_name": "preset_lora.safetensors",
|
||||
"file_path": "/models/loras/preset_lora.safetensors",
|
||||
"folder": "",
|
||||
"usage_tips": '{"strength": 0.7, "clipStrength": 0.3}',
|
||||
}
|
||||
]
|
||||
|
||||
result = await cycler_node.cycle(
|
||||
{
|
||||
**cycler_config,
|
||||
"use_same_clip_strength": True,
|
||||
}
|
||||
)
|
||||
|
||||
assert result["result"][0] == [
|
||||
("/models/loras/preset_lora.safetensors", 1.05, 1.05)
|
||||
]
|
||||
@@ -1,6 +1,8 @@
|
||||
# serializer version: 1
|
||||
# name: TestModelLibraryHandlerSnapshots.test_check_model_exists_empty_response
|
||||
dict({
|
||||
'downloadedVersionIds': list([
|
||||
]),
|
||||
'modelType': None,
|
||||
'success': True,
|
||||
'versions': list([
|
||||
|
||||
@@ -66,6 +66,27 @@ class FakePromptServer:
|
||||
instance = Instance()
|
||||
|
||||
|
||||
class FakeDownloadHistoryService:
|
||||
async def has_been_downloaded(self, _model_type, _version_id):
|
||||
return False
|
||||
|
||||
async def get_downloaded_version_ids(self, _model_type, _model_id):
|
||||
return []
|
||||
|
||||
async def get_downloaded_version_ids_bulk(self, _model_type, _model_ids):
|
||||
return {}
|
||||
|
||||
async def mark_downloaded(self, *_args, **_kwargs):
|
||||
return None
|
||||
|
||||
async def mark_not_downloaded(self, *_args, **_kwargs):
|
||||
return None
|
||||
|
||||
|
||||
async def fake_download_history_service_factory():
|
||||
return FakeDownloadHistoryService()
|
||||
|
||||
|
||||
class TestSettingsHandlerSnapshots:
|
||||
"""Snapshot tests for SettingsHandler responses."""
|
||||
|
||||
@@ -223,6 +244,7 @@ class TestModelLibraryHandlerSnapshots:
|
||||
get_lora_scanner=scanner_factory,
|
||||
get_checkpoint_scanner=scanner_factory,
|
||||
get_embedding_scanner=scanner_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
),
|
||||
metadata_provider_factory=lambda: None,
|
||||
)
|
||||
|
||||
@@ -23,9 +23,10 @@ from py.routes.misc_routes import MiscRoutes
|
||||
|
||||
|
||||
class FakeRequest:
|
||||
def __init__(self, *, json_data=None, query=None):
|
||||
def __init__(self, *, json_data=None, query=None, method="POST"):
|
||||
self._json_data = json_data or {}
|
||||
self.query = query or {}
|
||||
self.method = method
|
||||
|
||||
async def json(self):
|
||||
return self._json_data
|
||||
@@ -438,6 +439,46 @@ async def fake_metadata_archive_manager_factory():
|
||||
return FakeMetadataArchiveManager()
|
||||
|
||||
|
||||
class FakeDownloadHistoryService:
|
||||
def __init__(self, downloaded_by_type=None):
|
||||
self.downloaded_by_type = downloaded_by_type or {}
|
||||
self.marked_downloaded: list[tuple] = []
|
||||
self.marked_not_downloaded: list[tuple] = []
|
||||
|
||||
async def has_been_downloaded(self, model_type, version_id):
|
||||
return version_id in self.downloaded_by_type.get(model_type, set())
|
||||
|
||||
async def get_downloaded_version_ids(self, model_type, model_id):
|
||||
entries = self.downloaded_by_type.get(model_type, {})
|
||||
if isinstance(entries, dict):
|
||||
return sorted(entries.get(model_id, set()))
|
||||
return []
|
||||
|
||||
async def get_downloaded_version_ids_bulk(self, model_type, model_ids):
|
||||
entries = self.downloaded_by_type.get(model_type, {})
|
||||
if not isinstance(entries, dict):
|
||||
return {}
|
||||
return {
|
||||
model_id: set(entries.get(model_id, set()))
|
||||
for model_id in model_ids
|
||||
if model_id in entries
|
||||
}
|
||||
|
||||
async def mark_downloaded(
|
||||
self, model_type, version_id, *, model_id=None, source="manual", file_path=None
|
||||
):
|
||||
self.marked_downloaded.append(
|
||||
(model_type, version_id, model_id, source, file_path)
|
||||
)
|
||||
|
||||
async def mark_not_downloaded(self, model_type, version_id):
|
||||
self.marked_not_downloaded.append((model_type, version_id))
|
||||
|
||||
|
||||
async def fake_download_history_service_factory():
|
||||
return FakeDownloadHistoryService()
|
||||
|
||||
|
||||
class RecordingRegistrar:
|
||||
def __init__(self, _app):
|
||||
self.registered_mapping = None
|
||||
@@ -452,6 +493,7 @@ async def test_misc_routes_bind_produces_expected_handlers():
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
)
|
||||
|
||||
recorded_registrars = []
|
||||
@@ -578,6 +620,7 @@ async def test_get_civitai_user_models_marks_library_versions():
|
||||
get_lora_scanner=lora_factory,
|
||||
get_checkpoint_scanner=checkpoint_factory,
|
||||
get_embedding_scanner=embedding_factory,
|
||||
get_downloaded_version_history_service=lambda: fake_download_history_service_factory(),
|
||||
),
|
||||
metadata_provider_factory=provider_factory,
|
||||
)
|
||||
@@ -600,6 +643,7 @@ async def test_get_civitai_user_models_marks_library_versions():
|
||||
"baseModel": "Flux.1",
|
||||
"thumbnailUrl": "http://example.com/a1.jpg",
|
||||
"inLibrary": False,
|
||||
"hasBeenDownloaded": False,
|
||||
},
|
||||
{
|
||||
"modelId": 1,
|
||||
@@ -611,6 +655,7 @@ async def test_get_civitai_user_models_marks_library_versions():
|
||||
"baseModel": "Flux.1",
|
||||
"thumbnailUrl": "http://example.com/a2.jpg",
|
||||
"inLibrary": True,
|
||||
"hasBeenDownloaded": False,
|
||||
},
|
||||
{
|
||||
"modelId": 2,
|
||||
@@ -622,6 +667,7 @@ async def test_get_civitai_user_models_marks_library_versions():
|
||||
"baseModel": None,
|
||||
"thumbnailUrl": "http://example.com/e1.jpg",
|
||||
"inLibrary": False,
|
||||
"hasBeenDownloaded": False,
|
||||
},
|
||||
{
|
||||
"modelId": 2,
|
||||
@@ -633,6 +679,7 @@ async def test_get_civitai_user_models_marks_library_versions():
|
||||
"baseModel": None,
|
||||
"thumbnailUrl": None,
|
||||
"inLibrary": True,
|
||||
"hasBeenDownloaded": False,
|
||||
},
|
||||
{
|
||||
"modelId": 3,
|
||||
@@ -644,6 +691,7 @@ async def test_get_civitai_user_models_marks_library_versions():
|
||||
"baseModel": "SDXL",
|
||||
"thumbnailUrl": None,
|
||||
"inLibrary": False,
|
||||
"hasBeenDownloaded": False,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -692,6 +740,7 @@ async def test_get_civitai_user_models_rewrites_civitai_previews():
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
),
|
||||
metadata_provider_factory=provider_factory,
|
||||
)
|
||||
@@ -727,6 +776,7 @@ async def test_get_civitai_user_models_requires_username():
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
),
|
||||
metadata_provider_factory=provider_factory,
|
||||
)
|
||||
@@ -760,6 +810,7 @@ def test_ensure_handler_mapping_caches_result():
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
),
|
||||
metadata_provider_factory=fake_metadata_provider_factory,
|
||||
metadata_archive_manager_factory=fake_metadata_archive_manager_factory,
|
||||
@@ -802,6 +853,7 @@ async def test_check_model_exists_returns_local_versions():
|
||||
get_lora_scanner=lora_factory,
|
||||
get_checkpoint_scanner=checkpoint_factory,
|
||||
get_embedding_scanner=embedding_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
),
|
||||
metadata_provider_factory=fake_metadata_provider_factory,
|
||||
)
|
||||
@@ -811,10 +863,139 @@ async def test_check_model_exists_returns_local_versions():
|
||||
|
||||
assert payload["success"] is True
|
||||
assert payload["modelType"] == "lora"
|
||||
assert payload["versions"] == versions
|
||||
assert payload["versions"] == [
|
||||
{"versionId": 11, "name": "v1", "fileName": "model-one", "hasBeenDownloaded": True},
|
||||
{"versionId": 12, "name": "v2", "fileName": "model-two", "hasBeenDownloaded": True},
|
||||
]
|
||||
assert lora_scanner.version_calls == [5]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_model_exists_model_id_only_does_not_call_metadata_provider():
|
||||
async def metadata_provider_factory():
|
||||
raise AssertionError("metadata provider should not be called for modelId-only checks")
|
||||
|
||||
handler = ModelLibraryHandler(
|
||||
ServiceRegistryAdapter(
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
),
|
||||
metadata_provider_factory=metadata_provider_factory,
|
||||
)
|
||||
|
||||
response = await handler.check_model_exists(FakeRequest(query={"modelId": "5"}))
|
||||
payload = json.loads(response.text)
|
||||
|
||||
assert payload == {
|
||||
"success": True,
|
||||
"modelType": None,
|
||||
"versions": [],
|
||||
"downloadedVersionIds": [],
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_check_model_exists_returns_download_history_when_file_missing():
|
||||
history_service = FakeDownloadHistoryService({"checkpoint": {999}})
|
||||
|
||||
async def history_factory():
|
||||
return history_service
|
||||
|
||||
handler = ModelLibraryHandler(
|
||||
ServiceRegistryAdapter(
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=history_factory,
|
||||
),
|
||||
metadata_provider_factory=fake_metadata_provider_factory,
|
||||
)
|
||||
|
||||
response = await handler.check_model_exists(
|
||||
FakeRequest(query={"modelId": "5", "modelVersionId": "999"})
|
||||
)
|
||||
payload = json.loads(response.text)
|
||||
|
||||
assert payload == {
|
||||
"success": True,
|
||||
"exists": False,
|
||||
"modelType": "checkpoint",
|
||||
"hasBeenDownloaded": True,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_model_version_download_status_endpoints():
|
||||
history_service = FakeDownloadHistoryService({"lora": {123}})
|
||||
|
||||
async def history_factory():
|
||||
return history_service
|
||||
|
||||
handler = ModelLibraryHandler(
|
||||
ServiceRegistryAdapter(
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=history_factory,
|
||||
),
|
||||
metadata_provider_factory=fake_metadata_provider_factory,
|
||||
)
|
||||
|
||||
get_response = await handler.get_model_version_download_status(
|
||||
FakeRequest(query={"modelType": "lora", "modelVersionId": "123"})
|
||||
)
|
||||
get_payload = json.loads(get_response.text)
|
||||
assert get_payload == {
|
||||
"success": True,
|
||||
"modelType": "lora",
|
||||
"modelVersionId": 123,
|
||||
"hasBeenDownloaded": True,
|
||||
}
|
||||
|
||||
set_response = await handler.set_model_version_download_status(
|
||||
FakeRequest(
|
||||
json_data={
|
||||
"modelType": "checkpoint",
|
||||
"modelVersionId": 456,
|
||||
"modelId": 78,
|
||||
"downloaded": True,
|
||||
"filePath": "/tmp/model.safetensors",
|
||||
}
|
||||
)
|
||||
)
|
||||
set_payload = json.loads(set_response.text)
|
||||
assert set_payload == {
|
||||
"success": True,
|
||||
"modelType": "checkpoint",
|
||||
"modelVersionId": 456,
|
||||
"hasBeenDownloaded": True,
|
||||
}
|
||||
assert history_service.marked_downloaded == [
|
||||
("checkpoint", 456, 78, "manual", "/tmp/model.safetensors")
|
||||
]
|
||||
|
||||
set_get_response = await handler.set_model_version_download_status(
|
||||
FakeRequest(
|
||||
method="GET",
|
||||
query={
|
||||
"modelType": "embedding",
|
||||
"modelVersionId": "789",
|
||||
"modelId": "12",
|
||||
"downloaded": "false",
|
||||
},
|
||||
)
|
||||
)
|
||||
set_get_payload = json.loads(set_get_response.text)
|
||||
assert set_get_payload == {
|
||||
"success": True,
|
||||
"modelType": "embedding",
|
||||
"modelVersionId": 789,
|
||||
"hasBeenDownloaded": False,
|
||||
}
|
||||
|
||||
|
||||
def test_create_handler_set_uses_provided_dependencies():
|
||||
recorded_handlers: list[dict] = []
|
||||
|
||||
@@ -845,6 +1026,7 @@ def test_create_handler_set_uses_provided_dependencies():
|
||||
get_lora_scanner=fake_scanner_factory,
|
||||
get_checkpoint_scanner=fake_scanner_factory,
|
||||
get_embedding_scanner=fake_scanner_factory,
|
||||
get_downloaded_version_history_service=fake_download_history_service_factory,
|
||||
),
|
||||
metadata_provider_factory=fake_metadata_provider_factory,
|
||||
metadata_archive_manager_factory=fake_metadata_archive_manager_factory,
|
||||
|
||||
@@ -38,6 +38,7 @@ def isolate_settings(monkeypatch, tmp_path):
|
||||
"embedding": "{base_model}/{first_tag}",
|
||||
},
|
||||
"base_model_path_mappings": {"BaseModel": "MappedModel"},
|
||||
"skip_previously_downloaded_model_versions": False,
|
||||
"download_skip_base_models": [],
|
||||
}
|
||||
)
|
||||
@@ -454,7 +455,7 @@ async def test_download_skips_excluded_base_model(monkeypatch, scanners, metadat
|
||||
|
||||
metadata_provider.get_model_version = AsyncMock(
|
||||
return_value={
|
||||
"id": 42,
|
||||
"id": 99,
|
||||
"model": {"type": "LoRA", "tags": ["fantasy"]},
|
||||
"baseModel": "SDXL 1.0",
|
||||
"creator": {"username": "Author"},
|
||||
@@ -490,3 +491,104 @@ async def test_download_skips_excluded_base_model(monkeypatch, scanners, metadat
|
||||
assert "file.safetensors" in result["message"]
|
||||
execute_download.assert_not_called()
|
||||
assert manager._active_downloads[result["download_id"]]["status"] == "skipped"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download_skips_previously_downloaded_version(monkeypatch, scanners, metadata_provider):
|
||||
manager = DownloadManager()
|
||||
get_settings_manager().settings["skip_previously_downloaded_model_versions"] = True
|
||||
|
||||
metadata_provider.get_model_version = AsyncMock(
|
||||
return_value={
|
||||
"id": 42,
|
||||
"model": {"type": "LoRA", "tags": ["fantasy"]},
|
||||
"baseModel": "SDXL 1.0",
|
||||
"creator": {"username": "Author"},
|
||||
"files": [
|
||||
{
|
||||
"type": "Model",
|
||||
"primary": True,
|
||||
"downloadUrl": "https://example.invalid/file.safetensors",
|
||||
"name": "file.safetensors",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
history_service = AsyncMock()
|
||||
history_service.has_been_downloaded = AsyncMock(return_value=True)
|
||||
monkeypatch.setattr(
|
||||
ServiceRegistry,
|
||||
"get_downloaded_version_history_service",
|
||||
AsyncMock(return_value=history_service),
|
||||
)
|
||||
|
||||
execute_download = AsyncMock()
|
||||
monkeypatch.setattr(
|
||||
DownloadManager, "_execute_download", execute_download, raising=False
|
||||
)
|
||||
|
||||
result = await manager.download_from_civitai(
|
||||
model_version_id=99,
|
||||
use_default_paths=True,
|
||||
progress_callback=None,
|
||||
source=None,
|
||||
)
|
||||
|
||||
assert result["success"] is True
|
||||
assert result["skipped"] is True
|
||||
assert result["status"] == "skipped"
|
||||
assert result["reason"] == "previously_downloaded_version"
|
||||
assert result["model_version_id"] == 99
|
||||
assert result["file_name"] == "file.safetensors"
|
||||
history_service.has_been_downloaded.assert_awaited_once_with("lora", 99)
|
||||
execute_download.assert_not_called()
|
||||
assert manager._active_downloads[result["download_id"]]["status"] == "skipped"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download_proceeds_when_history_skip_disabled(monkeypatch, scanners, metadata_provider):
|
||||
manager = DownloadManager()
|
||||
get_settings_manager().settings["skip_previously_downloaded_model_versions"] = False
|
||||
|
||||
metadata_provider.get_model_version = AsyncMock(
|
||||
return_value={
|
||||
"id": 42,
|
||||
"model": {"type": "LoRA", "tags": ["fantasy"]},
|
||||
"baseModel": "SDXL 1.0",
|
||||
"creator": {"username": "Author"},
|
||||
"files": [
|
||||
{
|
||||
"type": "Model",
|
||||
"primary": True,
|
||||
"downloadUrl": "https://example.invalid/file.safetensors",
|
||||
"name": "file.safetensors",
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
history_service = AsyncMock()
|
||||
history_service.has_been_downloaded = AsyncMock(return_value=True)
|
||||
monkeypatch.setattr(
|
||||
ServiceRegistry,
|
||||
"get_downloaded_version_history_service",
|
||||
AsyncMock(return_value=history_service),
|
||||
)
|
||||
|
||||
execute_download = AsyncMock(return_value={"success": True, "download_id": "done"})
|
||||
monkeypatch.setattr(
|
||||
DownloadManager, "_execute_download", execute_download, raising=False
|
||||
)
|
||||
|
||||
result = await manager.download_from_civitai(
|
||||
model_version_id=99,
|
||||
use_default_paths=True,
|
||||
progress_callback=None,
|
||||
source=None,
|
||||
)
|
||||
|
||||
assert result["success"] is True
|
||||
assert result.get("skipped") is not True
|
||||
history_service.has_been_downloaded.assert_not_called()
|
||||
execute_download.assert_awaited_once()
|
||||
|
||||
70
tests/services/test_downloaded_version_history_service.py
Normal file
70
tests/services/test_downloaded_version_history_service.py
Normal file
@@ -0,0 +1,70 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from py.services.downloaded_version_history_service import (
|
||||
DownloadedVersionHistoryService,
|
||||
)
|
||||
|
||||
|
||||
class DummySettings:
|
||||
def get_active_library_name(self) -> str:
|
||||
return "alpha"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download_history_roundtrip_and_manual_override(tmp_path: Path) -> None:
|
||||
db_path = tmp_path / "download-history.sqlite"
|
||||
service = DownloadedVersionHistoryService(
|
||||
str(db_path),
|
||||
settings_manager=DummySettings(),
|
||||
)
|
||||
|
||||
await service.mark_downloaded(
|
||||
"lora",
|
||||
101,
|
||||
model_id=11,
|
||||
source="scan",
|
||||
file_path="/models/a.safetensors",
|
||||
)
|
||||
assert await service.has_been_downloaded("lora", 101) is True
|
||||
assert await service.get_downloaded_version_ids("lora", 11) == [101]
|
||||
|
||||
await service.mark_not_downloaded("lora", 101)
|
||||
assert await service.has_been_downloaded("lora", 101) is False
|
||||
assert await service.get_downloaded_version_ids("lora", 11) == []
|
||||
|
||||
await service.mark_downloaded(
|
||||
"lora",
|
||||
101,
|
||||
model_id=11,
|
||||
source="download",
|
||||
file_path="/models/a.safetensors",
|
||||
)
|
||||
assert await service.has_been_downloaded("lora", 101) is True
|
||||
assert await service.get_downloaded_version_ids("lora", 11) == [101]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_download_history_bulk_lookup(tmp_path: Path) -> None:
|
||||
db_path = tmp_path / "download-history.sqlite"
|
||||
service = DownloadedVersionHistoryService(
|
||||
str(db_path),
|
||||
settings_manager=DummySettings(),
|
||||
)
|
||||
|
||||
await service.mark_downloaded_bulk(
|
||||
"checkpoint",
|
||||
[
|
||||
{"model_id": 5, "version_id": 501, "file_path": "/m/one.safetensors"},
|
||||
{"model_id": 5, "version_id": 502, "file_path": "/m/two.safetensors"},
|
||||
{"model_id": 6, "version_id": 601, "file_path": "/m/three.safetensors"},
|
||||
],
|
||||
source="scan",
|
||||
)
|
||||
|
||||
assert await service.get_downloaded_version_ids("checkpoint", 5) == [501, 502]
|
||||
assert await service.get_downloaded_version_ids_bulk("checkpoint", [5, 6, 7]) == {
|
||||
5: {501, 502},
|
||||
6: {601},
|
||||
}
|
||||
@@ -17,7 +17,9 @@ def test_portable_settings_use_project_root(tmp_path, monkeypatch):
|
||||
from importlib import reload
|
||||
|
||||
settings_paths_module = reload(settings_paths)
|
||||
monkeypatch.setattr(settings_paths_module, "get_project_root", lambda: str(tmp_path))
|
||||
monkeypatch.setattr(
|
||||
settings_paths_module, "get_project_root", lambda: str(tmp_path)
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
settings_paths_module,
|
||||
"user_config_dir",
|
||||
@@ -25,7 +27,9 @@ def test_portable_settings_use_project_root(tmp_path, monkeypatch):
|
||||
)
|
||||
|
||||
portable_settings = {"use_portable_settings": True}
|
||||
(tmp_path / "settings.json").write_text(json.dumps(portable_settings), encoding="utf-8")
|
||||
(tmp_path / "settings.json").write_text(
|
||||
json.dumps(portable_settings), encoding="utf-8"
|
||||
)
|
||||
|
||||
config_dir = settings_paths_module.get_settings_dir(create=True)
|
||||
assert config_dir == str(tmp_path)
|
||||
@@ -74,7 +78,9 @@ def test_initial_save_persists_minimal_template(tmp_path, monkeypatch):
|
||||
self._seed_template = copy.deepcopy(template)
|
||||
return copy.deepcopy(template)
|
||||
|
||||
monkeypatch.setattr(SettingsManager, "_load_settings_template", fake_template_loader)
|
||||
monkeypatch.setattr(
|
||||
SettingsManager, "_load_settings_template", fake_template_loader
|
||||
)
|
||||
|
||||
manager = SettingsManager()
|
||||
|
||||
@@ -118,7 +124,10 @@ def test_existing_folder_paths_seed_default_library(tmp_path, monkeypatch):
|
||||
assert "default" in libraries
|
||||
assert libraries["default"]["folder_paths"]["loras"] == [str(lora_dir)]
|
||||
assert libraries["default"]["folder_paths"]["checkpoints"] == [str(checkpoint_dir)]
|
||||
assert libraries["default"]["folder_paths"]["unet"] == [str(diffusion_dir), str(unet_dir)]
|
||||
assert libraries["default"]["folder_paths"]["unet"] == [
|
||||
str(diffusion_dir),
|
||||
str(unet_dir),
|
||||
]
|
||||
assert libraries["default"]["folder_paths"]["embeddings"] == [str(embedding_dir)]
|
||||
|
||||
assert manager.get_startup_messages() == []
|
||||
@@ -138,7 +147,9 @@ def test_environment_variable_overrides_settings(tmp_path, monkeypatch):
|
||||
assert mgr.get("civitai_api_key") == "secret"
|
||||
|
||||
|
||||
def _create_manager_with_settings(tmp_path, monkeypatch, initial_settings, *, save_spy=None):
|
||||
def _create_manager_with_settings(
|
||||
tmp_path, monkeypatch, initial_settings, *, save_spy=None
|
||||
):
|
||||
"""Helper to instantiate SettingsManager with predefined settings."""
|
||||
|
||||
fake_settings_path = tmp_path / "settings.json"
|
||||
@@ -203,7 +214,9 @@ def test_switch_to_portable_mode_copies_cache(tmp_path, monkeypatch):
|
||||
assert manager.settings_file == str(project_root / "settings.json")
|
||||
marker_copy = project_root / "model_cache" / "user_marker.txt"
|
||||
assert marker_copy.read_text(encoding="utf-8") == "user_marker.txt"
|
||||
assert (project_root / "model_cache.sqlite").read_text(encoding="utf-8") == "user_db"
|
||||
assert (project_root / "model_cache.sqlite").read_text(
|
||||
encoding="utf-8"
|
||||
) == "user_db"
|
||||
assert user_settings.exists()
|
||||
|
||||
|
||||
@@ -216,13 +229,17 @@ def test_switching_back_to_user_config_moves_cache(tmp_path, monkeypatch):
|
||||
|
||||
project_cache_dir = project_root / "model_cache"
|
||||
project_cache_dir.mkdir(exist_ok=True)
|
||||
(project_cache_dir / "project_marker.txt").write_text("project_marker", encoding="utf-8")
|
||||
(project_cache_dir / "project_marker.txt").write_text(
|
||||
"project_marker", encoding="utf-8"
|
||||
)
|
||||
(project_root / "model_cache.sqlite").write_text("project_db", encoding="utf-8")
|
||||
|
||||
manager.set("use_portable_settings", False)
|
||||
|
||||
assert manager.settings_file == str(user_settings)
|
||||
assert (user_dir / "model_cache" / "project_marker.txt").read_text(encoding="utf-8") == "project_marker"
|
||||
assert (user_dir / "model_cache" / "project_marker.txt").read_text(
|
||||
encoding="utf-8"
|
||||
) == "project_marker"
|
||||
assert (user_dir / "model_cache.sqlite").read_text(encoding="utf-8") == "project_db"
|
||||
|
||||
|
||||
@@ -242,10 +259,19 @@ def test_download_path_template_invalid_json(manager):
|
||||
template = manager.get_download_path_template("checkpoint")
|
||||
|
||||
assert template == "{base_model}/{first_tag}"
|
||||
assert manager.settings["download_path_templates"]["lora"] == "{base_model}/{first_tag}"
|
||||
assert (
|
||||
manager.settings["download_path_templates"]["lora"]
|
||||
== "{base_model}/{first_tag}"
|
||||
)
|
||||
|
||||
|
||||
def test_auto_set_default_roots(manager):
|
||||
# Clear any previously auto-set values to test fresh behavior
|
||||
manager.settings["default_lora_root"] = ""
|
||||
manager.settings["default_checkpoint_root"] = ""
|
||||
manager.settings["default_embedding_root"] = ""
|
||||
manager.settings["default_unet_root"] = ""
|
||||
|
||||
manager.settings["folder_paths"] = {
|
||||
"loras": ["/loras"],
|
||||
"checkpoints": ["/checkpoints"],
|
||||
@@ -259,6 +285,48 @@ def test_auto_set_default_roots(manager):
|
||||
assert manager.get("default_embedding_root") == "/embeddings"
|
||||
|
||||
|
||||
def test_auto_set_default_roots_repairs_stale_values(manager):
|
||||
manager.settings["default_lora_root"] = "/stale-lora"
|
||||
manager.settings["default_checkpoint_root"] = "/stale-checkpoint"
|
||||
manager.settings["default_embedding_root"] = "/stale-embedding"
|
||||
manager.settings["default_unet_root"] = "/stale-unet"
|
||||
|
||||
manager.settings["folder_paths"] = {
|
||||
"loras": ["/loras"],
|
||||
"checkpoints": ["/checkpoints"],
|
||||
"unet": ["/unet"],
|
||||
"embeddings": ["/embeddings"],
|
||||
}
|
||||
|
||||
manager._auto_set_default_roots()
|
||||
|
||||
assert manager.get("default_lora_root") == "/loras"
|
||||
assert manager.get("default_checkpoint_root") == "/checkpoints"
|
||||
assert manager.get("default_unet_root") == "/unet"
|
||||
assert manager.get("default_embedding_root") == "/embeddings"
|
||||
|
||||
|
||||
def test_auto_set_default_roots_keeps_valid_values(manager):
|
||||
manager.settings["default_lora_root"] = "/loras"
|
||||
manager.settings["default_checkpoint_root"] = "/checkpoints"
|
||||
manager.settings["default_embedding_root"] = "/embeddings"
|
||||
manager.settings["default_unet_root"] = "/unet"
|
||||
|
||||
manager.settings["folder_paths"] = {
|
||||
"loras": ["/loras", "/other-loras"],
|
||||
"checkpoints": ["/checkpoints"],
|
||||
"unet": ["/unet", "/other-unet"],
|
||||
"embeddings": ["/embeddings"],
|
||||
}
|
||||
|
||||
manager._auto_set_default_roots()
|
||||
|
||||
assert manager.get("default_lora_root") == "/loras"
|
||||
assert manager.get("default_checkpoint_root") == "/checkpoints"
|
||||
assert manager.get("default_unet_root") == "/unet"
|
||||
assert manager.get("default_embedding_root") == "/embeddings"
|
||||
|
||||
|
||||
def test_delete_setting(manager):
|
||||
manager.set("example", 1)
|
||||
manager.delete("example")
|
||||
@@ -293,7 +361,14 @@ def test_invalid_mature_blur_level_is_normalized_to_r(tmp_path, monkeypatch):
|
||||
|
||||
def test_model_name_display_setting_notifies_scanners(tmp_path, monkeypatch):
|
||||
initial = {
|
||||
"libraries": {"default": {"folder_paths": {}, "default_lora_root": "", "default_checkpoint_root": "", "default_embedding_root": ""}},
|
||||
"libraries": {
|
||||
"default": {
|
||||
"folder_paths": {},
|
||||
"default_lora_root": "",
|
||||
"default_checkpoint_root": "",
|
||||
"default_embedding_root": "",
|
||||
}
|
||||
},
|
||||
"active_library": "default",
|
||||
"model_name_display": "model_name",
|
||||
}
|
||||
@@ -315,6 +390,7 @@ def test_model_name_display_setting_notifies_scanners(tmp_path, monkeypatch):
|
||||
|
||||
dispatched_loops = []
|
||||
futures = []
|
||||
|
||||
def tracking_run_coroutine_threadsafe(coro, target_loop):
|
||||
dispatched_loops.append(target_loop)
|
||||
future = Future()
|
||||
@@ -335,7 +411,9 @@ def test_model_name_display_setting_notifies_scanners(tmp_path, monkeypatch):
|
||||
"get_service_sync",
|
||||
classmethod(fake_get_service_sync),
|
||||
)
|
||||
monkeypatch.setattr(asyncio, "run_coroutine_threadsafe", tracking_run_coroutine_threadsafe)
|
||||
monkeypatch.setattr(
|
||||
asyncio, "run_coroutine_threadsafe", tracking_run_coroutine_threadsafe
|
||||
)
|
||||
|
||||
try:
|
||||
manager.set("model_name_display", "file_name")
|
||||
@@ -354,12 +432,14 @@ def test_migrates_legacy_settings_file(tmp_path, monkeypatch):
|
||||
legacy_root = tmp_path / "legacy"
|
||||
legacy_root.mkdir()
|
||||
legacy_file = legacy_root / "settings.json"
|
||||
legacy_file.write_text("{\"value\": 1}", encoding="utf-8")
|
||||
legacy_file.write_text('{"value": 1}', encoding="utf-8")
|
||||
|
||||
target_dir = tmp_path / "config"
|
||||
|
||||
monkeypatch.setattr(settings_paths, "get_project_root", lambda: str(legacy_root))
|
||||
monkeypatch.setattr(settings_paths, "user_config_dir", lambda *_, **__: str(target_dir))
|
||||
monkeypatch.setattr(
|
||||
settings_paths, "user_config_dir", lambda *_, **__: str(target_dir)
|
||||
)
|
||||
|
||||
migrated_path = settings_paths.ensure_settings_file()
|
||||
|
||||
@@ -380,7 +460,9 @@ def test_uses_portable_settings_file_when_enabled(tmp_path, monkeypatch):
|
||||
user_dir = tmp_path / "user"
|
||||
|
||||
monkeypatch.setattr(settings_paths, "get_project_root", lambda: str(repo_root))
|
||||
monkeypatch.setattr(settings_paths, "user_config_dir", lambda *_, **__: str(user_dir))
|
||||
monkeypatch.setattr(
|
||||
settings_paths, "user_config_dir", lambda *_, **__: str(user_dir)
|
||||
)
|
||||
|
||||
resolved = settings_paths.ensure_settings_file()
|
||||
|
||||
@@ -393,7 +475,9 @@ def test_migrate_creates_default_library(manager):
|
||||
libraries = manager.get_libraries()
|
||||
assert "default" in libraries
|
||||
assert manager.get_active_library_name() == "default"
|
||||
assert libraries["default"].get("folder_paths", {}) == manager.settings.get("folder_paths", {})
|
||||
assert libraries["default"].get("folder_paths", {}) == manager.settings.get(
|
||||
"folder_paths", {}
|
||||
)
|
||||
|
||||
|
||||
def test_migrate_sanitizes_legacy_libraries(tmp_path, monkeypatch):
|
||||
@@ -464,12 +548,21 @@ def test_refresh_environment_variables_updates_stored_value(tmp_path, monkeypatc
|
||||
|
||||
initial = {
|
||||
"civitai_api_key": "stale",
|
||||
"libraries": {"default": {"folder_paths": {}, "default_lora_root": "", "default_checkpoint_root": "", "default_embedding_root": ""}},
|
||||
"libraries": {
|
||||
"default": {
|
||||
"folder_paths": {},
|
||||
"default_lora_root": "",
|
||||
"default_checkpoint_root": "",
|
||||
"default_embedding_root": "",
|
||||
}
|
||||
},
|
||||
"active_library": "default",
|
||||
}
|
||||
|
||||
monkeypatch.setenv("CIVITAI_API_KEY", "from-init")
|
||||
manager = _create_manager_with_settings(tmp_path, monkeypatch, initial, save_spy=save_spy)
|
||||
manager = _create_manager_with_settings(
|
||||
tmp_path, monkeypatch, initial, save_spy=save_spy
|
||||
)
|
||||
|
||||
assert calls[-1] == "from-init"
|
||||
|
||||
@@ -590,7 +683,9 @@ def test_extra_paths_validation_no_overlap_with_other_libraries(manager, tmp_pat
|
||||
manager.update_extra_folder_paths({"loras": [str(lora_dir1)]})
|
||||
|
||||
|
||||
def test_extra_paths_validation_no_overlap_with_active_primary_lora_root(manager, tmp_path):
|
||||
def test_extra_paths_validation_no_overlap_with_active_primary_lora_root(
|
||||
manager, tmp_path
|
||||
):
|
||||
"""Test that extra LoRA paths cannot overlap the active library primary LoRA roots."""
|
||||
real_lora_dir = tmp_path / "loras_real"
|
||||
real_lora_dir.mkdir()
|
||||
@@ -603,7 +698,9 @@ def test_extra_paths_validation_no_overlap_with_active_primary_lora_root(manager
|
||||
activate=True,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="overlap with the active library's primary LoRA roots"):
|
||||
with pytest.raises(
|
||||
ValueError, match="overlap with the active library's primary LoRA roots"
|
||||
):
|
||||
manager.update_extra_folder_paths({"loras": [str(real_lora_dir)]})
|
||||
|
||||
|
||||
@@ -627,7 +724,10 @@ def test_extra_paths_validation_no_overlap_with_active_primary_lora_root_case_in
|
||||
original_normcase = settings_manager_module.os.path.normcase
|
||||
|
||||
def fake_exists(path):
|
||||
if isinstance(path, str) and path.lower() in {str(lora_link).lower(), str(real_lora_dir).lower()}:
|
||||
if isinstance(path, str) and path.lower() in {
|
||||
str(lora_link).lower(),
|
||||
str(real_lora_dir).lower(),
|
||||
}:
|
||||
return True
|
||||
return original_exists(path)
|
||||
|
||||
@@ -638,13 +738,21 @@ def test_extra_paths_validation_no_overlap_with_active_primary_lora_root_case_in
|
||||
|
||||
monkeypatch.setattr(settings_manager_module.os.path, "exists", fake_exists)
|
||||
monkeypatch.setattr(settings_manager_module.os.path, "realpath", fake_realpath)
|
||||
monkeypatch.setattr(settings_manager_module.os.path, "normcase", lambda value: original_normcase(value).lower())
|
||||
monkeypatch.setattr(
|
||||
settings_manager_module.os.path,
|
||||
"normcase",
|
||||
lambda value: original_normcase(value).lower(),
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="overlap with the active library's primary LoRA roots"):
|
||||
with pytest.raises(
|
||||
ValueError, match="overlap with the active library's primary LoRA roots"
|
||||
):
|
||||
manager.update_extra_folder_paths({"loras": [str(real_lora_dir).upper()]})
|
||||
|
||||
|
||||
def test_extra_paths_validation_allows_missing_non_overlapping_lora_root(manager, tmp_path):
|
||||
def test_extra_paths_validation_allows_missing_non_overlapping_lora_root(
|
||||
manager, tmp_path
|
||||
):
|
||||
"""Missing non-overlapping extra LoRA paths should not be rejected."""
|
||||
lora_dir = tmp_path / "loras"
|
||||
lora_dir.mkdir()
|
||||
@@ -662,7 +770,9 @@ def test_extra_paths_validation_allows_missing_non_overlapping_lora_root(manager
|
||||
assert extra_paths["loras"] == [str(missing_extra)]
|
||||
|
||||
|
||||
def test_extra_paths_validation_rejects_primary_root_first_level_symlink_target(manager, tmp_path):
|
||||
def test_extra_paths_validation_rejects_primary_root_first_level_symlink_target(
|
||||
manager, tmp_path
|
||||
):
|
||||
"""Extra LoRA paths should be rejected when already reachable via a first-level symlink under the primary root."""
|
||||
lora_dir = tmp_path / "loras"
|
||||
lora_dir.mkdir()
|
||||
@@ -677,7 +787,9 @@ def test_extra_paths_validation_rejects_primary_root_first_level_symlink_target(
|
||||
activate=True,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="overlap with the active library's primary LoRA roots"):
|
||||
with pytest.raises(
|
||||
ValueError, match="overlap with the active library's primary LoRA roots"
|
||||
):
|
||||
manager.update_extra_folder_paths({"loras": [str(external_dir)]})
|
||||
|
||||
|
||||
@@ -698,7 +810,6 @@ def test_delete_library_switches_active(manager, tmp_path):
|
||||
assert manager.get_active_library_name() == "default"
|
||||
|
||||
|
||||
|
||||
def test_download_skip_base_models_are_normalized(manager):
|
||||
manager.settings["download_skip_base_models"] = [
|
||||
"SDXL 1.0",
|
||||
@@ -715,9 +826,17 @@ def test_download_skip_base_models_are_normalized(manager):
|
||||
|
||||
|
||||
def test_setting_download_skip_base_models_normalizes_string_input(manager):
|
||||
manager.set(
|
||||
"download_skip_base_models",
|
||||
"SDXL 1.0, Pony; Invalid\nSDXL 1.0"
|
||||
)
|
||||
manager.set("download_skip_base_models", "SDXL 1.0, Pony; Invalid\nSDXL 1.0")
|
||||
|
||||
assert manager.get("download_skip_base_models") == ["SDXL 1.0", "Pony"]
|
||||
|
||||
|
||||
def test_skip_previously_downloaded_model_versions_defaults_false(manager):
|
||||
assert manager.get_skip_previously_downloaded_model_versions() is False
|
||||
|
||||
|
||||
def test_skip_previously_downloaded_model_versions_coerces_string_input(manager):
|
||||
manager.settings["skip_previously_downloaded_model_versions"] = "true"
|
||||
|
||||
assert manager.get_skip_previously_downloaded_model_versions() is True
|
||||
assert manager.settings["skip_previously_downloaded_model_versions"] is True
|
||||
|
||||
144
tests/utils/test_civitai_utils_rewrite.py
Normal file
144
tests/utils/test_civitai_utils_rewrite.py
Normal file
@@ -0,0 +1,144 @@
|
||||
"""Tests for CivitAI URL utilities."""
|
||||
|
||||
import pytest
|
||||
|
||||
from py.utils.civitai_utils import rewrite_preview_url
|
||||
|
||||
|
||||
class TestRewritePreviewUrl:
|
||||
"""Test cases for rewrite_preview_url function."""
|
||||
|
||||
def test_handles_none_input(self):
|
||||
"""Should return (None, False) for None input."""
|
||||
result, was_rewritten = rewrite_preview_url(None)
|
||||
assert result is None
|
||||
assert was_rewritten is False
|
||||
|
||||
def test_handles_empty_string(self):
|
||||
"""Should return (empty_string, False) for empty input."""
|
||||
result, was_rewritten = rewrite_preview_url("")
|
||||
assert result == ""
|
||||
assert was_rewritten is False
|
||||
|
||||
def test_handles_invalid_url(self):
|
||||
"""Should return original URL and False for invalid URLs."""
|
||||
invalid_url = "not-a-valid-url"
|
||||
result, was_rewritten = rewrite_preview_url(invalid_url)
|
||||
assert result == invalid_url
|
||||
assert was_rewritten is False
|
||||
|
||||
def test_handles_url_without_scheme(self):
|
||||
"""Should return original URL and False for URLs without scheme."""
|
||||
url = "image.civitai.com/something"
|
||||
result, was_rewritten = rewrite_preview_url(url)
|
||||
assert result == url
|
||||
assert was_rewritten is False
|
||||
|
||||
def test_returns_false_for_non_civitai_domains(self):
|
||||
"""Should not rewrite URLs from other domains."""
|
||||
url = "https://example.com/image.jpg"
|
||||
result, was_rewritten = rewrite_preview_url(url)
|
||||
assert result == url
|
||||
assert was_rewritten is False
|
||||
|
||||
def test_returns_false_for_main_civitai_domain(self):
|
||||
"""Should not rewrite URLs from main civitai.com domain."""
|
||||
url = "https://civitai.com/images/123"
|
||||
result, was_rewritten = rewrite_preview_url(url)
|
||||
assert result == url
|
||||
assert was_rewritten is False
|
||||
|
||||
def test_rewrites_image_civitai_com_urls(self):
|
||||
"""Should rewrite URLs from image.civitai.com."""
|
||||
url = "https://image.civitai.com/checkpoints/original=true"
|
||||
result, was_rewritten = rewrite_preview_url(url, "image")
|
||||
assert (
|
||||
result == "https://image.civitai.com/checkpoints/width=450,optimized=true"
|
||||
)
|
||||
assert was_rewritten is True
|
||||
|
||||
def test_rewrites_subdomain_civitai_urls(self):
|
||||
"""Should rewrite URLs from CivitAI CDN subdomains like image-b2.civitai.com."""
|
||||
url = "https://image-b2.civitai.com/file/civitai-media-cache/original=true/sample.png"
|
||||
result, was_rewritten = rewrite_preview_url(url, "image")
|
||||
assert (
|
||||
result
|
||||
== "https://image-b2.civitai.com/file/civitai-media-cache/width=450,optimized=true/sample.png"
|
||||
)
|
||||
assert was_rewritten is True
|
||||
|
||||
def test_rewrites_multiple_subdomains(self):
|
||||
"""Should rewrite URLs from various CivitAI subdomains."""
|
||||
test_cases = [
|
||||
"https://image-b3.civitai.com/original=true/test.jpg",
|
||||
"https://cdn.civitai.com/original=true/test.png",
|
||||
]
|
||||
for url in test_cases:
|
||||
result, was_rewritten = rewrite_preview_url(url, "image")
|
||||
assert was_rewritten is True
|
||||
assert "width=450,optimized=true" in result
|
||||
|
||||
def test_handles_urls_with_explicit_port(self):
|
||||
"""Should correctly handle URLs with explicit port numbers."""
|
||||
url = "https://image.civitai.com:443/checkpoints/original=true"
|
||||
result, was_rewritten = rewrite_preview_url(url, "image")
|
||||
assert was_rewritten is True
|
||||
assert "width=450,optimized=true" in result
|
||||
# Port is preserved in the URL (this is acceptable behavior)
|
||||
assert ":443" in result
|
||||
|
||||
def test_rewrites_video_urls_with_transcode(self):
|
||||
"""Should rewrite video URLs with transcode parameter."""
|
||||
url = "https://image.civitai.com/videos/original=true/sample.mp4"
|
||||
result, was_rewritten = rewrite_preview_url(url, "video")
|
||||
assert (
|
||||
result
|
||||
== "https://image.civitai.com/videos/transcode=true,width=450,optimized=true/sample.mp4"
|
||||
)
|
||||
assert was_rewritten is True
|
||||
|
||||
def test_video_rewrite_uses_case_insensitive_type(self):
|
||||
"""Should handle video type case-insensitively."""
|
||||
url = "https://image.civitai.com/original=true/test.mp4"
|
||||
result1, was1 = rewrite_preview_url(url, "VIDEO")
|
||||
result2, was2 = rewrite_preview_url(url, "Video")
|
||||
assert was1 is True
|
||||
assert was2 is True
|
||||
assert "transcode=true" in result1
|
||||
assert "transcode=true" in result2
|
||||
|
||||
def test_returns_original_when_no_original_true_in_path(self):
|
||||
"""Should not rewrite URLs that don't contain /original=true."""
|
||||
url = "https://image.civitai.com/checkpoints/optimized=true"
|
||||
result, was_rewritten = rewrite_preview_url(url)
|
||||
assert result == url
|
||||
assert was_rewritten is False
|
||||
|
||||
def test_preserves_path_structure_after_rewrite(self):
|
||||
"""Should maintain path structure after rewriting."""
|
||||
url = "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/abc123/original=true/12345.png"
|
||||
result, was_rewritten = rewrite_preview_url(url, "image")
|
||||
assert was_rewritten is True
|
||||
assert result.startswith(
|
||||
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/abc123/"
|
||||
)
|
||||
assert result.endswith("/12345.png")
|
||||
|
||||
def test_defaults_to_image_mode_when_media_type_is_none(self):
|
||||
"""Should use image optimization when media_type is None."""
|
||||
url = "https://image.civitai.com/original=true/test.png"
|
||||
result, was_rewritten = rewrite_preview_url(url, None)
|
||||
assert was_rewritten is True
|
||||
assert "transcode=true" not in result
|
||||
assert "width=450,optimized=true" in result
|
||||
|
||||
def test_case_insensitive_hostname_matching(self):
|
||||
"""Should handle case-insensitive hostname matching."""
|
||||
test_cases = [
|
||||
"https://IMAGE.CIVITAI.COM/original=true/test.png",
|
||||
"https://Image.Civitai.Com/original=true/test.png",
|
||||
"https://image-b2.CIVITAI.com/original=true/test.png",
|
||||
]
|
||||
for url in test_cases:
|
||||
result, was_rewritten = rewrite_preview_url(url, "image")
|
||||
assert was_rewritten is True, f"Failed for URL: {url}"
|
||||
@@ -8,6 +8,8 @@
|
||||
:model-strength="state.modelStrength.value"
|
||||
:clip-strength="state.clipStrength.value"
|
||||
:use-custom-clip-range="state.useCustomClipRange.value"
|
||||
:use-preset-strength="state.usePresetStrength.value"
|
||||
:preset-strength-scale="state.presetStrengthScale.value"
|
||||
:is-clip-strength-disabled="state.isClipStrengthDisabled.value"
|
||||
:is-loading="state.isLoading.value"
|
||||
:repeat-count="state.repeatCount.value"
|
||||
@@ -22,6 +24,8 @@
|
||||
@update:model-strength="state.modelStrength.value = $event"
|
||||
@update:clip-strength="state.clipStrength.value = $event"
|
||||
@update:use-custom-clip-range="handleUseCustomClipRangeChange"
|
||||
@update:use-preset-strength="state.usePresetStrength.value = $event"
|
||||
@update:preset-strength-scale="state.presetStrengthScale.value = $event"
|
||||
@update:repeat-count="handleRepeatCountChange"
|
||||
@update:include-no-lora="handleIncludeNoLoraChange"
|
||||
@toggle-pause="handleTogglePause"
|
||||
|
||||
@@ -51,6 +51,7 @@ type RandomizerWidget = ComponentWidget<RandomizerConfig>
|
||||
const props = defineProps<{
|
||||
widget: RandomizerWidget
|
||||
node: { id: number; inputs?: any[]; widgets?: any[]; graph?: any }
|
||||
api?: any
|
||||
}>()
|
||||
|
||||
// State management
|
||||
@@ -65,6 +66,13 @@ const currentLoras = ref<LoraEntry[]>([])
|
||||
// Track if component is mounted to avoid early watch triggers
|
||||
const isMounted = ref(false)
|
||||
|
||||
interface PendingExecution {
|
||||
loras?: LoraEntry[]
|
||||
lastUsed?: LoraEntry[] | null
|
||||
}
|
||||
|
||||
const pendingExecutions: PendingExecution[] = []
|
||||
|
||||
// Computed property to check if we can reuse last
|
||||
const canReuseLast = computed(() => {
|
||||
const lastUsed = state.lastUsed.value
|
||||
@@ -265,18 +273,20 @@ onMounted(async () => {
|
||||
;(props.node as any).onExecuted = function(output: any) {
|
||||
console.log("[LoraRandomizerWidget] Node executed with output:", output)
|
||||
|
||||
// Update last_used from backend
|
||||
const pendingUpdate: PendingExecution = {}
|
||||
|
||||
if (output?.last_used !== undefined) {
|
||||
state.lastUsed.value = output.last_used
|
||||
console.log(`[LoraRandomizerWidget] Updated last_used: ${output.last_used ? output.last_used.length : 0} LoRAs`)
|
||||
pendingUpdate.lastUsed = output.last_used
|
||||
console.log(`[LoraRandomizerWidget] Queued last_used update: ${output.last_used ? output.last_used.length : 0} LoRAs`)
|
||||
}
|
||||
|
||||
// Update loras widget if backend provided new loras
|
||||
const lorasWidget = props.node.widgets?.find((w: any) => w.name === 'loras')
|
||||
if (lorasWidget && output?.loras && Array.isArray(output.loras)) {
|
||||
console.log("[LoraRandomizerWidget] Received loras data from backend:", output.loras)
|
||||
lorasWidget.value = output.loras
|
||||
currentLoras.value = output.loras
|
||||
if (output?.loras && Array.isArray(output.loras)) {
|
||||
pendingUpdate.loras = output.loras
|
||||
console.log("[LoraRandomizerWidget] Queued loras data from backend:", output.loras)
|
||||
}
|
||||
|
||||
if (pendingUpdate.lastUsed !== undefined || pendingUpdate.loras !== undefined) {
|
||||
pendingExecutions.push(pendingUpdate)
|
||||
}
|
||||
|
||||
// Call original onExecuted if it exists
|
||||
@@ -284,6 +294,44 @@ onMounted(async () => {
|
||||
return originalOnExecuted(output)
|
||||
}
|
||||
}
|
||||
|
||||
if (props.api) {
|
||||
const handleExecutionComplete = () => {
|
||||
if (pendingExecutions.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const pending = pendingExecutions.shift()!
|
||||
|
||||
if (pending.lastUsed !== undefined) {
|
||||
state.lastUsed.value = pending.lastUsed
|
||||
}
|
||||
|
||||
if (pending.loras !== undefined) {
|
||||
const lorasWidget = props.node.widgets?.find((w: any) => w.name === 'loras')
|
||||
if (lorasWidget) {
|
||||
lorasWidget.value = pending.loras
|
||||
}
|
||||
currentLoras.value = pending.loras
|
||||
}
|
||||
}
|
||||
|
||||
props.api.addEventListener('execution_success', handleExecutionComplete)
|
||||
props.api.addEventListener('execution_error', handleExecutionComplete)
|
||||
props.api.addEventListener('execution_interrupted', handleExecutionComplete)
|
||||
|
||||
const apiCleanup = () => {
|
||||
props.api.removeEventListener('execution_success', handleExecutionComplete)
|
||||
props.api.removeEventListener('execution_error', handleExecutionComplete)
|
||||
props.api.removeEventListener('execution_interrupted', handleExecutionComplete)
|
||||
}
|
||||
|
||||
const existingCleanup = (props.widget as any).onRemoveCleanup
|
||||
;(props.widget as any).onRemoveCleanup = () => {
|
||||
existingCleanup?.()
|
||||
apiCleanup()
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -131,6 +131,38 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Preset Strength Scale -->
|
||||
<div class="setting-section">
|
||||
<div class="section-header-with-toggle">
|
||||
<label class="setting-label">
|
||||
Preset Strength Scale
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="toggle-switch"
|
||||
:class="{ 'toggle-switch--active': usePresetStrength }"
|
||||
@click="$emit('update:usePresetStrength', !usePresetStrength)"
|
||||
role="switch"
|
||||
:aria-checked="usePresetStrength"
|
||||
title="Use scaled preset strength when enabled"
|
||||
>
|
||||
<span class="toggle-switch__track"></span>
|
||||
<span class="toggle-switch__thumb"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="slider-container" :class="{ 'slider-container--disabled': !usePresetStrength }">
|
||||
<SingleSlider
|
||||
:min="0"
|
||||
:max="2"
|
||||
:value="presetStrengthScale"
|
||||
:step="0.1"
|
||||
:default-range="{ min: 0.5, max: 1.0 }"
|
||||
:disabled="!usePresetStrength"
|
||||
@update:value="$emit('update:presetStrengthScale', $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Clip Strength -->
|
||||
<div class="setting-section">
|
||||
<div class="section-header-with-toggle">
|
||||
@@ -198,6 +230,8 @@ const props = defineProps<{
|
||||
modelStrength: number
|
||||
clipStrength: number
|
||||
useCustomClipRange: boolean
|
||||
usePresetStrength: boolean
|
||||
presetStrengthScale: number
|
||||
isClipStrengthDisabled: boolean
|
||||
repeatCount: number
|
||||
repeatUsed: number
|
||||
@@ -214,6 +248,8 @@ const emit = defineEmits<{
|
||||
'update:modelStrength': [value: number]
|
||||
'update:clipStrength': [value: number]
|
||||
'update:useCustomClipRange': [value: boolean]
|
||||
'update:usePresetStrength': [value: boolean]
|
||||
'update:presetStrengthScale': [value: number]
|
||||
'update:repeatCount': [value: number]
|
||||
'update:includeNoLora': [value: boolean]
|
||||
'toggle-pause': []
|
||||
|
||||
@@ -80,6 +80,8 @@ export interface CyclerConfig {
|
||||
model_strength: number
|
||||
clip_strength: number
|
||||
use_same_clip_strength: boolean
|
||||
use_preset_strength: boolean
|
||||
preset_strength_scale: number
|
||||
sort_by: 'filename' | 'model_name'
|
||||
current_lora_name: string // For display
|
||||
current_lora_filename: string
|
||||
|
||||
@@ -19,6 +19,8 @@ export function useLoraCyclerState(widget: ComponentWidget<CyclerConfig>) {
|
||||
const modelStrength = ref(1.0)
|
||||
const clipStrength = ref(1.0)
|
||||
const useCustomClipRange = ref(false)
|
||||
const usePresetStrength = ref(false)
|
||||
const presetStrengthScale = ref(1.0)
|
||||
const sortBy = ref<'filename' | 'model_name'>('filename')
|
||||
const currentLoraName = ref('')
|
||||
const currentLoraFilename = ref('')
|
||||
@@ -52,6 +54,8 @@ export function useLoraCyclerState(widget: ComponentWidget<CyclerConfig>) {
|
||||
model_strength: modelStrength.value,
|
||||
clip_strength: clipStrength.value,
|
||||
use_same_clip_strength: !useCustomClipRange.value,
|
||||
use_preset_strength: usePresetStrength.value,
|
||||
preset_strength_scale: presetStrengthScale.value,
|
||||
sort_by: sortBy.value,
|
||||
current_lora_name: currentLoraName.value,
|
||||
current_lora_filename: currentLoraFilename.value,
|
||||
@@ -70,6 +74,8 @@ export function useLoraCyclerState(widget: ComponentWidget<CyclerConfig>) {
|
||||
model_strength: modelStrength.value,
|
||||
clip_strength: clipStrength.value,
|
||||
use_same_clip_strength: !useCustomClipRange.value,
|
||||
use_preset_strength: usePresetStrength.value,
|
||||
preset_strength_scale: presetStrengthScale.value,
|
||||
sort_by: sortBy.value,
|
||||
current_lora_name: currentLoraName.value,
|
||||
current_lora_filename: currentLoraFilename.value,
|
||||
@@ -94,6 +100,8 @@ export function useLoraCyclerState(widget: ComponentWidget<CyclerConfig>) {
|
||||
modelStrength.value = config.model_strength ?? 1.0
|
||||
clipStrength.value = config.clip_strength ?? 1.0
|
||||
useCustomClipRange.value = !(config.use_same_clip_strength ?? true)
|
||||
usePresetStrength.value = config.use_preset_strength ?? false
|
||||
presetStrengthScale.value = config.preset_strength_scale ?? 1.0
|
||||
sortBy.value = config.sort_by || 'filename'
|
||||
currentLoraName.value = config.current_lora_name || ''
|
||||
currentLoraFilename.value = config.current_lora_filename || ''
|
||||
@@ -277,6 +285,8 @@ export function useLoraCyclerState(widget: ComponentWidget<CyclerConfig>) {
|
||||
modelStrength,
|
||||
clipStrength,
|
||||
useCustomClipRange,
|
||||
usePresetStrength,
|
||||
presetStrengthScale,
|
||||
sortBy,
|
||||
currentLoraName,
|
||||
currentLoraFilename,
|
||||
@@ -296,6 +306,8 @@ export function useLoraCyclerState(widget: ComponentWidget<CyclerConfig>) {
|
||||
modelStrength,
|
||||
clipStrength,
|
||||
useCustomClipRange,
|
||||
usePresetStrength,
|
||||
presetStrengthScale,
|
||||
sortBy,
|
||||
currentLoraName,
|
||||
currentLoraFilename,
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { LoraPoolConfig, RandomizerConfig, CyclerConfig } from './composabl
|
||||
import {
|
||||
setupModeChangeHandler,
|
||||
createModeChangeCallback,
|
||||
LORA_PROVIDER_NODE_TYPES
|
||||
LORA_CHAIN_NODE_TYPES
|
||||
} from './mode-change-handler'
|
||||
|
||||
const LORA_POOL_WIDGET_MIN_WIDTH = 500
|
||||
@@ -18,7 +18,7 @@ const LORA_RANDOMIZER_WIDGET_MIN_WIDTH = 500
|
||||
const LORA_RANDOMIZER_WIDGET_MIN_HEIGHT = 448
|
||||
const LORA_RANDOMIZER_WIDGET_MAX_HEIGHT = LORA_RANDOMIZER_WIDGET_MIN_HEIGHT
|
||||
const LORA_CYCLER_WIDGET_MIN_WIDTH = 380
|
||||
const LORA_CYCLER_WIDGET_MIN_HEIGHT = 344
|
||||
const LORA_CYCLER_WIDGET_MIN_HEIGHT = 408
|
||||
const LORA_CYCLER_WIDGET_MAX_HEIGHT = LORA_CYCLER_WIDGET_MIN_HEIGHT
|
||||
const JSON_DISPLAY_WIDGET_MIN_WIDTH = 300
|
||||
const JSON_DISPLAY_WIDGET_MIN_HEIGHT = 200
|
||||
@@ -201,7 +201,8 @@ function createLoraRandomizerWidget(node) {
|
||||
|
||||
const vueApp = createApp(LoraRandomizerWidget, {
|
||||
widget,
|
||||
node
|
||||
node,
|
||||
api
|
||||
})
|
||||
|
||||
vueApp.use(PrimeVue, {
|
||||
@@ -243,7 +244,24 @@ function createLoraCyclerWidget(node) {
|
||||
|
||||
forwardMiddleMouseToCanvas(container)
|
||||
|
||||
let internalValue: CyclerConfig | undefined
|
||||
const defaultConfig: CyclerConfig = {
|
||||
current_index: 1,
|
||||
total_count: 0,
|
||||
pool_config_hash: '',
|
||||
model_strength: 1.0,
|
||||
clip_strength: 1.0,
|
||||
use_same_clip_strength: true,
|
||||
use_preset_strength: false,
|
||||
preset_strength_scale: 1.0,
|
||||
sort_by: 'filename',
|
||||
current_lora_name: '',
|
||||
current_lora_filename: '',
|
||||
repeat_count: 1,
|
||||
repeat_used: 0,
|
||||
is_paused: false,
|
||||
include_no_lora: false,
|
||||
}
|
||||
let internalValue: CyclerConfig | undefined = defaultConfig
|
||||
|
||||
const widget = node.addDOMWidget(
|
||||
'cycler_config',
|
||||
@@ -737,8 +755,8 @@ app.registerExtension({
|
||||
}
|
||||
}
|
||||
|
||||
// Register mode change handlers for LoRA provider nodes
|
||||
if (LORA_PROVIDER_NODE_TYPES.includes(comfyClass)) {
|
||||
// Register mode change handlers for LORA_STACK chain nodes
|
||||
if (LORA_CHAIN_NODE_TYPES.includes(comfyClass)) {
|
||||
const originalOnNodeCreated = nodeType.prototype.onNodeCreated
|
||||
|
||||
nodeType.prototype.onNodeCreated = function () {
|
||||
|
||||
@@ -18,7 +18,22 @@ export const LORA_PROVIDER_NODE_TYPES = [
|
||||
"Lora Cycler (LoraManager)",
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Nodes that do not own LoRA state themselves, but merge or forward LORA_STACK
|
||||
* inputs so downstream trigger-word updates must traverse through them.
|
||||
*/
|
||||
export const LORA_STACK_AGGREGATOR_NODE_TYPES = [
|
||||
"Lora Stack Combiner (LoraManager)",
|
||||
] as const;
|
||||
|
||||
export const LORA_CHAIN_NODE_TYPES = [
|
||||
...LORA_PROVIDER_NODE_TYPES,
|
||||
...LORA_STACK_AGGREGATOR_NODE_TYPES,
|
||||
] as const;
|
||||
|
||||
export type LoraProviderNodeType = typeof LORA_PROVIDER_NODE_TYPES[number];
|
||||
export type LoraStackAggregatorNodeType = typeof LORA_STACK_AGGREGATOR_NODE_TYPES[number];
|
||||
export type LoraChainNodeType = typeof LORA_CHAIN_NODE_TYPES[number];
|
||||
|
||||
/**
|
||||
* Check if a node class is a LoRA provider node.
|
||||
@@ -27,6 +42,16 @@ export function isLoraProviderNode(comfyClass: string): comfyClass is LoraProvid
|
||||
return LORA_PROVIDER_NODE_TYPES.includes(comfyClass as LoraProviderNodeType);
|
||||
}
|
||||
|
||||
export function isLoraStackAggregatorNode(
|
||||
comfyClass: string
|
||||
): comfyClass is LoraStackAggregatorNodeType {
|
||||
return LORA_STACK_AGGREGATOR_NODE_TYPES.includes(comfyClass as LoraStackAggregatorNodeType);
|
||||
}
|
||||
|
||||
export function isLoraChainNode(comfyClass: string): comfyClass is LoraChainNodeType {
|
||||
return LORA_CHAIN_NODE_TYPES.includes(comfyClass as LoraChainNodeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract active LoRA filenames from a node based on its type.
|
||||
*
|
||||
@@ -40,6 +65,10 @@ export function getActiveLorasFromNodeByType(node: any): Set<string> {
|
||||
return extractFromCyclerConfig(node);
|
||||
}
|
||||
|
||||
if (isLoraStackAggregatorNode(comfyClass)) {
|
||||
return new Set<string>();
|
||||
}
|
||||
|
||||
// Default: use lorasWidget (works for Stacker and Randomizer)
|
||||
return extractFromLorasWidget(node);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@ describe('useLoraCyclerState', () => {
|
||||
model_strength: 1.0,
|
||||
clip_strength: 1.0,
|
||||
use_same_clip_strength: true,
|
||||
use_preset_strength: false,
|
||||
preset_strength_scale: 1.0,
|
||||
sort_by: 'filename',
|
||||
current_lora_name: '',
|
||||
current_lora_filename: '',
|
||||
@@ -340,7 +342,8 @@ describe('useLoraCyclerState', () => {
|
||||
baseModels: ['SD 1.5'],
|
||||
tags: { include: [], exclude: [] },
|
||||
folders: { include: [], exclude: [] },
|
||||
license: { noCreditRequired: false, allowSelling: false }
|
||||
license: { noCreditRequired: false, allowSelling: false },
|
||||
namePatterns: { include: [], exclude: [], useRegex: false }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -349,7 +352,8 @@ describe('useLoraCyclerState', () => {
|
||||
baseModels: ['SDXL'],
|
||||
tags: { include: [], exclude: [] },
|
||||
folders: { include: [], exclude: [] },
|
||||
license: { noCreditRequired: false, allowSelling: false }
|
||||
license: { noCreditRequired: false, allowSelling: false },
|
||||
namePatterns: { include: [], exclude: [], useRegex: false }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -540,7 +544,8 @@ describe('useLoraCyclerState', () => {
|
||||
baseModels: ['SDXL'],
|
||||
tags: { include: [], exclude: [] },
|
||||
folders: { include: [], exclude: [] },
|
||||
license: { noCreditRequired: false, allowSelling: false }
|
||||
license: { noCreditRequired: false, allowSelling: false },
|
||||
namePatterns: { include: [], exclude: [], useRegex: false }
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
16
vue-widgets/tests/fixtures/mockConfigs.ts
vendored
16
vue-widgets/tests/fixtures/mockConfigs.ts
vendored
@@ -16,6 +16,8 @@ export function createMockCyclerConfig(overrides: Partial<CyclerConfig> = {}): C
|
||||
model_strength: 1.0,
|
||||
clip_strength: 1.0,
|
||||
use_same_clip_strength: true,
|
||||
use_preset_strength: false,
|
||||
preset_strength_scale: 1.0,
|
||||
sort_by: 'filename',
|
||||
current_lora_name: 'lora1.safetensors',
|
||||
current_lora_filename: 'lora1.safetensors',
|
||||
@@ -26,7 +28,7 @@ export function createMockCyclerConfig(overrides: Partial<CyclerConfig> = {}): C
|
||||
is_paused: false,
|
||||
include_no_lora: false,
|
||||
...overrides
|
||||
}
|
||||
} as CyclerConfig
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +44,8 @@ export function createMockPoolConfig(overrides: Partial<LoraPoolConfig> = {}): L
|
||||
license: {
|
||||
noCreditRequired: false,
|
||||
allowSelling: false
|
||||
}
|
||||
},
|
||||
namePatterns: { include: [], exclude: [], useRegex: false }
|
||||
},
|
||||
preview: { matchCount: 10, lastUpdated: Date.now() },
|
||||
...overrides
|
||||
@@ -148,7 +151,8 @@ export const SAMPLE_POOL_CONFIGS = {
|
||||
baseModels: ['SD 1.5'],
|
||||
tags: { include: [], exclude: [] },
|
||||
folders: { include: [], exclude: [] },
|
||||
license: { noCreditRequired: false, allowSelling: false }
|
||||
license: { noCreditRequired: false, allowSelling: false },
|
||||
namePatterns: { include: [], exclude: [], useRegex: false }
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -158,7 +162,8 @@ export const SAMPLE_POOL_CONFIGS = {
|
||||
baseModels: ['SDXL'],
|
||||
tags: { include: [], exclude: [] },
|
||||
folders: { include: [], exclude: [] },
|
||||
license: { noCreditRequired: false, allowSelling: false }
|
||||
license: { noCreditRequired: false, allowSelling: false },
|
||||
namePatterns: { include: [], exclude: [], useRegex: false }
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -168,7 +173,8 @@ export const SAMPLE_POOL_CONFIGS = {
|
||||
baseModels: ['SD 1.5'],
|
||||
tags: { include: ['anime', 'style'], exclude: ['realistic'] },
|
||||
folders: { include: [], exclude: [] },
|
||||
license: { noCreditRequired: false, allowSelling: false }
|
||||
license: { noCreditRequired: false, allowSelling: false },
|
||||
namePatterns: { include: [], exclude: [], useRegex: false }
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
@@ -4,17 +4,13 @@
|
||||
* These tests simulate ComfyUI's execution modes to verify correct LoRA cycling behavior.
|
||||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||
import { describe, it, expect, beforeEach } from 'vitest'
|
||||
import { useLoraCyclerState } from '@/composables/useLoraCyclerState'
|
||||
import type { CyclerConfig } from '@/composables/types'
|
||||
import {
|
||||
createMockWidget,
|
||||
createMockCyclerConfig,
|
||||
createMockLoraList,
|
||||
createMockPoolConfig
|
||||
} from '../fixtures/mockConfigs'
|
||||
import { setupFetchMock, resetFetchMock } from '../setup'
|
||||
import { BatchQueueSimulator, IndexTracker } from '../utils/BatchQueueSimulator'
|
||||
import { resetFetchMock } from '../setup'
|
||||
import { BatchQueueSimulator } from '../utils/BatchQueueSimulator'
|
||||
|
||||
/**
|
||||
* Creates a test harness that mimics the LoraCyclerWidget's behavior
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import { nextTick } from 'vue'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import LoraRandomizerWidget from '@/components/LoraRandomizerWidget.vue'
|
||||
import type { LoraEntry, RandomizerConfig } from '@/composables/types'
|
||||
|
||||
function createApiMock() {
|
||||
const target = new EventTarget()
|
||||
return {
|
||||
addEventListener: target.addEventListener.bind(target),
|
||||
removeEventListener: target.removeEventListener.bind(target),
|
||||
dispatchEvent: target.dispatchEvent.bind(target)
|
||||
}
|
||||
}
|
||||
|
||||
function createDefaultConfig(): RandomizerConfig {
|
||||
return {
|
||||
count_mode: 'range',
|
||||
count_fixed: 3,
|
||||
count_min: 2,
|
||||
count_max: 5,
|
||||
model_strength_min: 0,
|
||||
model_strength_max: 1,
|
||||
use_same_clip_strength: true,
|
||||
clip_strength_min: 0,
|
||||
clip_strength_max: 1,
|
||||
roll_mode: 'always',
|
||||
use_recommended_strength: false,
|
||||
recommended_strength_scale_min: 0.5,
|
||||
recommended_strength_scale_max: 1
|
||||
}
|
||||
}
|
||||
|
||||
describe('LoraRandomizerWidget deferred execution updates', () => {
|
||||
it('applies backend loras and last_used only after workflow completion', async () => {
|
||||
const initialLoras: LoraEntry[] = [
|
||||
{
|
||||
name: 'initial.safetensors',
|
||||
strength: 0.8,
|
||||
clipStrength: 0.8,
|
||||
active: true,
|
||||
expanded: false,
|
||||
locked: false
|
||||
}
|
||||
]
|
||||
const deferredLoras: LoraEntry[] = [
|
||||
{
|
||||
name: 'deferred.safetensors',
|
||||
strength: 1,
|
||||
clipStrength: 1,
|
||||
active: true,
|
||||
expanded: false,
|
||||
locked: false
|
||||
}
|
||||
]
|
||||
const lorasWidget = { name: 'loras', value: initialLoras }
|
||||
const node = {
|
||||
id: 101,
|
||||
widgets: [lorasWidget],
|
||||
onExecuted: vi.fn()
|
||||
}
|
||||
const widget = {
|
||||
value: createDefaultConfig()
|
||||
}
|
||||
const api = createApiMock()
|
||||
|
||||
const wrapper = shallowMount(LoraRandomizerWidget, {
|
||||
props: {
|
||||
widget,
|
||||
node,
|
||||
api
|
||||
}
|
||||
})
|
||||
|
||||
await nextTick()
|
||||
|
||||
const settingsView = wrapper.findComponent({ name: 'LoraRandomizerSettingsView' })
|
||||
expect(settingsView.exists()).toBe(true)
|
||||
expect(settingsView.props('lastUsed')).toBeNull()
|
||||
|
||||
;(node as any).onExecuted({
|
||||
loras: deferredLoras,
|
||||
last_used: deferredLoras
|
||||
})
|
||||
await nextTick()
|
||||
|
||||
expect(lorasWidget.value).toEqual(initialLoras)
|
||||
expect(settingsView.props('lastUsed')).toBeNull()
|
||||
|
||||
api.dispatchEvent(new Event('execution_success'))
|
||||
await nextTick()
|
||||
|
||||
expect(lorasWidget.value).toEqual(deferredLoras)
|
||||
expect(settingsView.props('lastUsed')).toEqual(deferredLoras)
|
||||
})
|
||||
})
|
||||
@@ -27,7 +27,7 @@ export interface SimulatorOptions {
|
||||
/**
|
||||
* Creates execution output based on the current state
|
||||
*/
|
||||
function defaultGenerateOutput(executionIndex: number, config: CyclerConfig) {
|
||||
function defaultGenerateOutput(_executionIndex: number, config: CyclerConfig) {
|
||||
// Calculate what the next index would be after this execution
|
||||
let nextIdx = (config.execution_index ?? config.current_index) + 1
|
||||
if (nextIdx > config.total_count) {
|
||||
|
||||
@@ -10,10 +10,27 @@ export const LORA_PROVIDER_NODE_TYPES = [
|
||||
"Lora Cycler (LoraManager)",
|
||||
];
|
||||
|
||||
export const LORA_STACK_AGGREGATOR_NODE_TYPES = [
|
||||
"Lora Stack Combiner (LoraManager)",
|
||||
];
|
||||
|
||||
export const LORA_CHAIN_NODE_TYPES = [
|
||||
...LORA_PROVIDER_NODE_TYPES,
|
||||
...LORA_STACK_AGGREGATOR_NODE_TYPES,
|
||||
];
|
||||
|
||||
export function isLoraProviderNode(comfyClass) {
|
||||
return LORA_PROVIDER_NODE_TYPES.includes(comfyClass);
|
||||
}
|
||||
|
||||
export function isLoraStackAggregatorNode(comfyClass) {
|
||||
return LORA_STACK_AGGREGATOR_NODE_TYPES.includes(comfyClass);
|
||||
}
|
||||
|
||||
export function isLoraChainNode(comfyClass) {
|
||||
return LORA_CHAIN_NODE_TYPES.includes(comfyClass);
|
||||
}
|
||||
|
||||
function isMapLike(collection) {
|
||||
return collection && typeof collection.entries === "function" && typeof collection.values === "function";
|
||||
}
|
||||
@@ -245,16 +262,20 @@ export function hideWidgetForGood(node, widget, suffix = "") {
|
||||
// Update pattern to match both formats: <lora:name:model_strength> or <lora:name:model_strength:clip_strength>
|
||||
export const LORA_PATTERN = /<lora:([^:]+):([-\d\.]+)(?::([-\d\.]+))?>/g;
|
||||
|
||||
// Get connected Lora Stacker nodes that feed into the current node
|
||||
export function getConnectedInputStackers(node) {
|
||||
const connectedStackers = [];
|
||||
function isLoraStackInput(input) {
|
||||
return input?.type === "LORA_STACK";
|
||||
}
|
||||
|
||||
// Get connected LORA_STACK chain nodes that feed into the current node
|
||||
export function getConnectedInputLoraChainNodes(node) {
|
||||
const connectedNodes = [];
|
||||
|
||||
if (!node?.inputs) {
|
||||
return connectedStackers;
|
||||
return connectedNodes;
|
||||
}
|
||||
|
||||
for (const input of node.inputs) {
|
||||
if (input.name !== "lora_stack" || !input.link) {
|
||||
if (!isLoraStackInput(input) || !input.link) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -264,12 +285,12 @@ export function getConnectedInputStackers(node) {
|
||||
}
|
||||
|
||||
const sourceNode = node.graph?.getNodeById?.(link.origin_id);
|
||||
if (sourceNode && isLoraProviderNode(sourceNode.comfyClass)) {
|
||||
connectedStackers.push(sourceNode);
|
||||
if (sourceNode && isLoraChainNode(sourceNode.comfyClass)) {
|
||||
connectedNodes.push(sourceNode);
|
||||
}
|
||||
}
|
||||
|
||||
return connectedStackers;
|
||||
return connectedNodes;
|
||||
}
|
||||
|
||||
// Get connected TriggerWord Toggle nodes that receive output from the current node
|
||||
@@ -314,6 +335,11 @@ export function getActiveLorasFromNode(node) {
|
||||
return activeLoraNames;
|
||||
}
|
||||
|
||||
// Aggregator nodes do not own LoRA state directly; they only forward upstream stacks.
|
||||
if (isLoraStackAggregatorNode(node.comfyClass)) {
|
||||
return activeLoraNames;
|
||||
}
|
||||
|
||||
// Handle Lora Stacker and Lora Randomizer (lorasWidget)
|
||||
let lorasWidget = node.lorasWidget;
|
||||
if (!lorasWidget && node.widgets) {
|
||||
@@ -348,14 +374,18 @@ export function collectActiveLorasFromChain(node, visited = new Set()) {
|
||||
// Mode 2 is Never, Mode 4 is Bypass
|
||||
const isNodeActive = node.mode === undefined || node.mode === 0 || node.mode === 3;
|
||||
|
||||
if (!isNodeActive) {
|
||||
return new Set();
|
||||
}
|
||||
|
||||
// Get active loras from current node only if node is active
|
||||
const allActiveLoraNames = isNodeActive ? getActiveLorasFromNode(node) : new Set();
|
||||
const allActiveLoraNames = getActiveLorasFromNode(node);
|
||||
|
||||
// Get connected input stackers and collect their active loras
|
||||
const inputStackers = getConnectedInputStackers(node);
|
||||
for (const stacker of inputStackers) {
|
||||
const stackerLoras = collectActiveLorasFromChain(stacker, visited);
|
||||
stackerLoras.forEach(name => allActiveLoraNames.add(name));
|
||||
// Get connected input LORA_STACK chain nodes and collect their active loras
|
||||
const inputChainNodes = getConnectedInputLoraChainNodes(node);
|
||||
for (const chainNode of inputChainNodes) {
|
||||
const upstreamLoras = collectActiveLorasFromChain(chainNode, visited);
|
||||
upstreamLoras.forEach(name => allActiveLoraNames.add(name));
|
||||
}
|
||||
|
||||
return allActiveLoraNames;
|
||||
@@ -819,8 +849,8 @@ export function updateDownstreamLoaders(startNode, visited = new Set()) {
|
||||
collectActiveLorasFromChain(targetNode);
|
||||
updateConnectedTriggerWords(targetNode, allActiveLoraNames);
|
||||
}
|
||||
// If target is another LoRA provider node, recursively check its outputs
|
||||
else if (targetNode && isLoraProviderNode(targetNode.comfyClass)) {
|
||||
// If target is another LORA_STACK chain node, recursively check its outputs
|
||||
else if (targetNode && isLoraChainNode(targetNode.comfyClass)) {
|
||||
updateDownstreamLoaders(targetNode, visited);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1577,7 +1577,7 @@ to { transform: rotate(360deg);
|
||||
transform: translateY(4px);
|
||||
}
|
||||
|
||||
.lora-randomizer-widget[data-v-94d3fca2] {
|
||||
.lora-randomizer-widget[data-v-ca6e8cec] {
|
||||
padding: 6px;
|
||||
background: rgba(40, 44, 52, 0.6);
|
||||
border-radius: 6px;
|
||||
@@ -1588,16 +1588,16 @@ to { transform: rotate(360deg);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.cycler-settings[data-v-f65566fd] {
|
||||
.cycler-settings[data-v-f0663be4] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
color: #e4e4e7;
|
||||
}
|
||||
.settings-header[data-v-f65566fd] {
|
||||
.settings-header[data-v-f0663be4] {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.settings-title[data-v-f65566fd] {
|
||||
.settings-title[data-v-f0663be4] {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.05em;
|
||||
@@ -1606,10 +1606,10 @@ to { transform: rotate(360deg);
|
||||
margin: 0;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.setting-section[data-v-f65566fd] {
|
||||
.setting-section[data-v-f0663be4] {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.setting-label[data-v-f65566fd] {
|
||||
.setting-label[data-v-f0663be4] {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: rgba(226, 232, 240, 0.8);
|
||||
@@ -1618,10 +1618,10 @@ to { transform: rotate(360deg);
|
||||
}
|
||||
|
||||
/* Progress Display */
|
||||
.progress-section[data-v-f65566fd] {
|
||||
.progress-section[data-v-f0663be4] {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.progress-display[data-v-f65566fd] {
|
||||
.progress-display[data-v-f0663be4] {
|
||||
background: rgba(26, 32, 44, 0.9);
|
||||
border: 1px solid rgba(226, 232, 240, 0.2);
|
||||
border-radius: 6px;
|
||||
@@ -1631,31 +1631,31 @@ to { transform: rotate(360deg);
|
||||
align-items: center;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
.progress-display.executing[data-v-f65566fd] {
|
||||
.progress-display.executing[data-v-f0663be4] {
|
||||
border-color: rgba(66, 153, 225, 0.5);
|
||||
animation: pulse-f65566fd 2s ease-in-out infinite;
|
||||
animation: pulse-f0663be4 2s ease-in-out infinite;
|
||||
}
|
||||
@keyframes pulse-f65566fd {
|
||||
@keyframes pulse-f0663be4 {
|
||||
0%, 100% { border-color: rgba(66, 153, 225, 0.3);
|
||||
}
|
||||
50% { border-color: rgba(66, 153, 225, 0.7);
|
||||
}
|
||||
}
|
||||
.progress-info[data-v-f65566fd] {
|
||||
.progress-info[data-v-f0663be4] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
.progress-label[data-v-f65566fd] {
|
||||
.progress-label[data-v-f0663be4] {
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
color: rgba(226, 232, 240, 0.5);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
.progress-name[data-v-f65566fd] {
|
||||
.progress-name[data-v-f0663be4] {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: rgba(191, 219, 254, 1);
|
||||
@@ -1663,7 +1663,7 @@ to { transform: rotate(360deg);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.progress-name.clickable[data-v-f65566fd] {
|
||||
.progress-name.clickable[data-v-f0663be4] {
|
||||
cursor: pointer;
|
||||
padding: 2px 6px;
|
||||
margin: -2px -6px;
|
||||
@@ -1673,42 +1673,42 @@ to { transform: rotate(360deg);
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
.progress-name.clickable[data-v-f65566fd]:hover:not(.disabled) {
|
||||
.progress-name.clickable[data-v-f0663be4]:hover:not(.disabled) {
|
||||
background: rgba(66, 153, 225, 0.2);
|
||||
color: rgba(191, 219, 254, 1);
|
||||
}
|
||||
.progress-name.no-lora[data-v-f65566fd] {
|
||||
.progress-name.no-lora[data-v-f0663be4] {
|
||||
font-style: italic;
|
||||
color: rgba(226, 232, 240, 0.6);
|
||||
}
|
||||
.progress-name.clickable.no-lora[data-v-f65566fd]:hover:not(.disabled) {
|
||||
.progress-name.clickable.no-lora[data-v-f0663be4]:hover:not(.disabled) {
|
||||
background: rgba(160, 174, 192, 0.2);
|
||||
color: rgba(226, 232, 240, 0.8);
|
||||
}
|
||||
.progress-name.clickable.disabled[data-v-f65566fd] {
|
||||
.progress-name.clickable.disabled[data-v-f0663be4] {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
.progress-info.disabled[data-v-f65566fd] {
|
||||
.progress-info.disabled[data-v-f0663be4] {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.selector-icon[data-v-f65566fd] {
|
||||
.selector-icon[data-v-f0663be4] {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
opacity: 0.5;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.progress-name.clickable:hover .selector-icon[data-v-f65566fd] {
|
||||
.progress-name.clickable:hover .selector-icon[data-v-f0663be4] {
|
||||
opacity: 0.8;
|
||||
}
|
||||
.progress-counter[data-v-f65566fd] {
|
||||
.progress-counter[data-v-f0663be4] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding-left: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.progress-index[data-v-f65566fd] {
|
||||
.progress-index[data-v-f0663be4] {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: rgba(66, 153, 225, 1);
|
||||
@@ -1717,12 +1717,12 @@ to { transform: rotate(360deg);
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.progress-separator[data-v-f65566fd] {
|
||||
.progress-separator[data-v-f0663be4] {
|
||||
font-size: 14px;
|
||||
color: rgba(226, 232, 240, 0.4);
|
||||
margin: 0 2px;
|
||||
}
|
||||
.progress-total[data-v-f65566fd] {
|
||||
.progress-total[data-v-f0663be4] {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: rgba(226, 232, 240, 0.6);
|
||||
@@ -1733,7 +1733,7 @@ to { transform: rotate(360deg);
|
||||
}
|
||||
|
||||
/* Repeat Progress */
|
||||
.repeat-progress[data-v-f65566fd] {
|
||||
.repeat-progress[data-v-f0663be4] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
@@ -1743,23 +1743,23 @@ to { transform: rotate(360deg);
|
||||
border: 1px solid rgba(226, 232, 240, 0.1);
|
||||
border-radius: 4px;
|
||||
}
|
||||
.repeat-progress-track[data-v-f65566fd] {
|
||||
.repeat-progress-track[data-v-f0663be4] {
|
||||
width: 32px;
|
||||
height: 4px;
|
||||
background: rgba(226, 232, 240, 0.15);
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.repeat-progress-fill[data-v-f65566fd] {
|
||||
.repeat-progress-fill[data-v-f0663be4] {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #f59e0b, #fbbf24);
|
||||
border-radius: 2px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
.repeat-progress-fill.is-complete[data-v-f65566fd] {
|
||||
.repeat-progress-fill.is-complete[data-v-f0663be4] {
|
||||
background: linear-gradient(90deg, #10b981, #34d399);
|
||||
}
|
||||
.repeat-progress-text[data-v-f65566fd] {
|
||||
.repeat-progress-text[data-v-f0663be4] {
|
||||
font-size: 10px;
|
||||
font-family: 'SF Mono', 'Roboto Mono', monospace;
|
||||
color: rgba(253, 230, 138, 0.9);
|
||||
@@ -1768,19 +1768,19 @@ to { transform: rotate(360deg);
|
||||
}
|
||||
|
||||
/* Index Controls Row - Grouped Layout */
|
||||
.index-controls-row[data-v-f65566fd] {
|
||||
.index-controls-row[data-v-f0663be4] {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
/* Control Group */
|
||||
.control-group[data-v-f65566fd] {
|
||||
.control-group[data-v-f0663be4] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.control-group-label[data-v-f65566fd] {
|
||||
.control-group-label[data-v-f0663be4] {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: rgba(226, 232, 240, 0.5);
|
||||
@@ -1788,13 +1788,13 @@ to { transform: rotate(360deg);
|
||||
letter-spacing: 0.03em;
|
||||
line-height: 1;
|
||||
}
|
||||
.control-group-content[data-v-f65566fd] {
|
||||
.control-group-content[data-v-f0663be4] {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
height: 32px;
|
||||
}
|
||||
.index-input[data-v-f65566fd] {
|
||||
.index-input[data-v-f0663be4] {
|
||||
width: 50px;
|
||||
height: 32px;
|
||||
padding: 0 8px;
|
||||
@@ -1807,15 +1807,15 @@ to { transform: rotate(360deg);
|
||||
line-height: 32px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.index-input[data-v-f65566fd]:focus {
|
||||
.index-input[data-v-f0663be4]:focus {
|
||||
outline: none;
|
||||
border-color: rgba(66, 153, 225, 0.6);
|
||||
}
|
||||
.index-input[data-v-f65566fd]:disabled {
|
||||
.index-input[data-v-f0663be4]:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.index-hint[data-v-f65566fd] {
|
||||
.index-hint[data-v-f0663be4] {
|
||||
font-size: 12px;
|
||||
color: rgba(226, 232, 240, 0.4);
|
||||
font-variant-numeric: tabular-nums;
|
||||
@@ -1823,7 +1823,7 @@ to { transform: rotate(360deg);
|
||||
}
|
||||
|
||||
/* Repeat Controls */
|
||||
.repeat-input[data-v-f65566fd] {
|
||||
.repeat-input[data-v-f0663be4] {
|
||||
width: 50px;
|
||||
height: 32px;
|
||||
padding: 0 6px;
|
||||
@@ -1837,11 +1837,11 @@ to { transform: rotate(360deg);
|
||||
line-height: 32px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.repeat-input[data-v-f65566fd]:focus {
|
||||
.repeat-input[data-v-f0663be4]:focus {
|
||||
outline: none;
|
||||
border-color: rgba(66, 153, 225, 0.6);
|
||||
}
|
||||
.repeat-suffix[data-v-f65566fd] {
|
||||
.repeat-suffix[data-v-f0663be4] {
|
||||
font-size: 13px;
|
||||
color: rgba(226, 232, 240, 0.4);
|
||||
font-weight: 500;
|
||||
@@ -1849,7 +1849,7 @@ to { transform: rotate(360deg);
|
||||
}
|
||||
|
||||
/* Action Buttons */
|
||||
.action-buttons[data-v-f65566fd] {
|
||||
.action-buttons[data-v-f0663be4] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
@@ -1857,7 +1857,7 @@ to { transform: rotate(360deg);
|
||||
}
|
||||
|
||||
/* Control Buttons */
|
||||
.control-btn[data-v-f65566fd] {
|
||||
.control-btn[data-v-f0663be4] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -1871,52 +1871,52 @@ to { transform: rotate(360deg);
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.control-btn[data-v-f65566fd]:hover:not(:disabled) {
|
||||
.control-btn[data-v-f0663be4]:hover:not(:disabled) {
|
||||
background: rgba(66, 153, 225, 0.2);
|
||||
border-color: rgba(66, 153, 225, 0.4);
|
||||
color: rgba(191, 219, 254, 1);
|
||||
}
|
||||
.control-btn[data-v-f65566fd]:disabled {
|
||||
.control-btn[data-v-f0663be4]:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.control-btn.active[data-v-f65566fd] {
|
||||
.control-btn.active[data-v-f0663be4] {
|
||||
background: rgba(245, 158, 11, 0.2);
|
||||
border-color: rgba(245, 158, 11, 0.5);
|
||||
color: rgba(253, 230, 138, 1);
|
||||
}
|
||||
.control-btn.active[data-v-f65566fd]:hover {
|
||||
.control-btn.active[data-v-f0663be4]:hover {
|
||||
background: rgba(245, 158, 11, 0.3);
|
||||
border-color: rgba(245, 158, 11, 0.6);
|
||||
}
|
||||
.control-icon[data-v-f65566fd] {
|
||||
.control-icon[data-v-f0663be4] {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
/* Slider Container */
|
||||
.slider-container[data-v-f65566fd] {
|
||||
.slider-container[data-v-f0663be4] {
|
||||
background: rgba(26, 32, 44, 0.9);
|
||||
border: 1px solid rgba(226, 232, 240, 0.2);
|
||||
border-radius: 6px;
|
||||
padding: 6px;
|
||||
}
|
||||
.slider-container--disabled[data-v-f65566fd] {
|
||||
.slider-container--disabled[data-v-f0663be4] {
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
.section-header-with-toggle[data-v-f65566fd] {
|
||||
.section-header-with-toggle[data-v-f0663be4] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.section-header-with-toggle .setting-label[data-v-f65566fd] {
|
||||
.section-header-with-toggle .setting-label[data-v-f0663be4] {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
/* Toggle Switch */
|
||||
.toggle-switch[data-v-f65566fd] {
|
||||
.toggle-switch[data-v-f0663be4] {
|
||||
position: relative;
|
||||
width: 36px;
|
||||
height: 20px;
|
||||
@@ -1925,7 +1925,7 @@ to { transform: rotate(360deg);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.toggle-switch__track[data-v-f65566fd] {
|
||||
.toggle-switch__track[data-v-f0663be4] {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: var(--comfy-input-bg, #333);
|
||||
@@ -1933,11 +1933,11 @@ to { transform: rotate(360deg);
|
||||
border-radius: 10px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.toggle-switch--active .toggle-switch__track[data-v-f65566fd] {
|
||||
.toggle-switch--active .toggle-switch__track[data-v-f0663be4] {
|
||||
background: rgba(66, 153, 225, 0.3);
|
||||
border-color: rgba(66, 153, 225, 0.6);
|
||||
}
|
||||
.toggle-switch__thumb[data-v-f65566fd] {
|
||||
.toggle-switch__thumb[data-v-f0663be4] {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
left: 2px;
|
||||
@@ -1948,12 +1948,12 @@ to { transform: rotate(360deg);
|
||||
transition: all 0.2s;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.toggle-switch--active .toggle-switch__thumb[data-v-f65566fd] {
|
||||
.toggle-switch--active .toggle-switch__thumb[data-v-f0663be4] {
|
||||
transform: translateX(16px);
|
||||
background: #4299e1;
|
||||
opacity: 1;
|
||||
}
|
||||
.toggle-switch:hover .toggle-switch__thumb[data-v-f65566fd] {
|
||||
.toggle-switch:hover .toggle-switch__thumb[data-v-f0663be4] {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@@ -2077,7 +2077,7 @@ to { transform: rotate(360deg);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.lora-cycler-widget[data-v-b97187b9] {
|
||||
.lora-cycler-widget[data-v-3f46897a] {
|
||||
padding: 6px;
|
||||
background: rgba(40, 44, 52, 0.6);
|
||||
border-radius: 6px;
|
||||
@@ -13240,7 +13240,8 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
||||
__name: "LoraRandomizerWidget",
|
||||
props: {
|
||||
widget: {},
|
||||
node: {}
|
||||
node: {},
|
||||
api: {}
|
||||
},
|
||||
setup(__props) {
|
||||
const props = __props;
|
||||
@@ -13248,6 +13249,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
||||
const HAS_EXECUTED = Symbol("HAS_EXECUTED");
|
||||
const currentLoras = ref([]);
|
||||
const isMounted = ref(false);
|
||||
const pendingExecutions = [];
|
||||
const canReuseLast = computed(() => {
|
||||
const lastUsed = state.lastUsed.value;
|
||||
if (!lastUsed || lastUsed.length === 0) return false;
|
||||
@@ -13377,22 +13379,55 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
||||
};
|
||||
const originalOnExecuted = (_b = props.node.onExecuted) == null ? void 0 : _b.bind(props.node);
|
||||
props.node.onExecuted = function(output) {
|
||||
var _a3;
|
||||
console.log("[LoraRandomizerWidget] Node executed with output:", output);
|
||||
const pendingUpdate = {};
|
||||
if ((output == null ? void 0 : output.last_used) !== void 0) {
|
||||
state.lastUsed.value = output.last_used;
|
||||
console.log(`[LoraRandomizerWidget] Updated last_used: ${output.last_used ? output.last_used.length : 0} LoRAs`);
|
||||
pendingUpdate.lastUsed = output.last_used;
|
||||
console.log(`[LoraRandomizerWidget] Queued last_used update: ${output.last_used ? output.last_used.length : 0} LoRAs`);
|
||||
}
|
||||
const lorasWidget2 = (_a3 = props.node.widgets) == null ? void 0 : _a3.find((w2) => w2.name === "loras");
|
||||
if (lorasWidget2 && (output == null ? void 0 : output.loras) && Array.isArray(output.loras)) {
|
||||
console.log("[LoraRandomizerWidget] Received loras data from backend:", output.loras);
|
||||
lorasWidget2.value = output.loras;
|
||||
currentLoras.value = output.loras;
|
||||
if ((output == null ? void 0 : output.loras) && Array.isArray(output.loras)) {
|
||||
pendingUpdate.loras = output.loras;
|
||||
console.log("[LoraRandomizerWidget] Queued loras data from backend:", output.loras);
|
||||
}
|
||||
if (pendingUpdate.lastUsed !== void 0 || pendingUpdate.loras !== void 0) {
|
||||
pendingExecutions.push(pendingUpdate);
|
||||
}
|
||||
if (originalOnExecuted) {
|
||||
return originalOnExecuted(output);
|
||||
}
|
||||
};
|
||||
if (props.api) {
|
||||
const handleExecutionComplete = () => {
|
||||
var _a3;
|
||||
if (pendingExecutions.length === 0) {
|
||||
return;
|
||||
}
|
||||
const pending = pendingExecutions.shift();
|
||||
if (pending.lastUsed !== void 0) {
|
||||
state.lastUsed.value = pending.lastUsed;
|
||||
}
|
||||
if (pending.loras !== void 0) {
|
||||
const lorasWidget2 = (_a3 = props.node.widgets) == null ? void 0 : _a3.find((w2) => w2.name === "loras");
|
||||
if (lorasWidget2) {
|
||||
lorasWidget2.value = pending.loras;
|
||||
}
|
||||
currentLoras.value = pending.loras;
|
||||
}
|
||||
};
|
||||
props.api.addEventListener("execution_success", handleExecutionComplete);
|
||||
props.api.addEventListener("execution_error", handleExecutionComplete);
|
||||
props.api.addEventListener("execution_interrupted", handleExecutionComplete);
|
||||
const apiCleanup = () => {
|
||||
props.api.removeEventListener("execution_success", handleExecutionComplete);
|
||||
props.api.removeEventListener("execution_error", handleExecutionComplete);
|
||||
props.api.removeEventListener("execution_interrupted", handleExecutionComplete);
|
||||
};
|
||||
const existingCleanup = props.widget.onRemoveCleanup;
|
||||
props.widget.onRemoveCleanup = () => {
|
||||
existingCleanup == null ? void 0 : existingCleanup();
|
||||
apiCleanup();
|
||||
};
|
||||
}
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return openBlock(), createElementBlock("div", {
|
||||
@@ -13439,7 +13474,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
||||
};
|
||||
}
|
||||
});
|
||||
const LoraRandomizerWidget = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-94d3fca2"]]);
|
||||
const LoraRandomizerWidget = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-ca6e8cec"]]);
|
||||
const _hoisted_1$3 = { class: "cycler-settings" };
|
||||
const _hoisted_2$3 = { class: "setting-section progress-section" };
|
||||
const _hoisted_3$3 = { class: "progress-label" };
|
||||
@@ -13480,11 +13515,14 @@ const _hoisted_24 = { class: "setting-section" };
|
||||
const _hoisted_25 = { class: "slider-container" };
|
||||
const _hoisted_26 = { class: "setting-section" };
|
||||
const _hoisted_27 = { class: "section-header-with-toggle" };
|
||||
const _hoisted_28 = { class: "setting-label" };
|
||||
const _hoisted_29 = ["aria-checked"];
|
||||
const _hoisted_30 = { class: "setting-section" };
|
||||
const _hoisted_31 = { class: "section-header-with-toggle" };
|
||||
const _hoisted_28 = ["aria-checked"];
|
||||
const _hoisted_29 = { class: "setting-section" };
|
||||
const _hoisted_30 = { class: "section-header-with-toggle" };
|
||||
const _hoisted_31 = { class: "setting-label" };
|
||||
const _hoisted_32 = ["aria-checked"];
|
||||
const _hoisted_33 = { class: "setting-section" };
|
||||
const _hoisted_34 = { class: "section-header-with-toggle" };
|
||||
const _hoisted_35 = ["aria-checked"];
|
||||
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
__name: "LoraCyclerSettingsView",
|
||||
props: {
|
||||
@@ -13495,6 +13533,8 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
modelStrength: {},
|
||||
clipStrength: {},
|
||||
useCustomClipRange: { type: Boolean },
|
||||
usePresetStrength: { type: Boolean },
|
||||
presetStrengthScale: {},
|
||||
isClipStrengthDisabled: { type: Boolean },
|
||||
repeatCount: {},
|
||||
repeatUsed: {},
|
||||
@@ -13505,7 +13545,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
includeNoLora: { type: Boolean },
|
||||
isNoLora: { type: Boolean }
|
||||
},
|
||||
emits: ["update:currentIndex", "update:modelStrength", "update:clipStrength", "update:useCustomClipRange", "update:repeatCount", "update:includeNoLora", "toggle-pause", "reset-index", "open-lora-selector"],
|
||||
emits: ["update:currentIndex", "update:modelStrength", "update:clipStrength", "update:useCustomClipRange", "update:usePresetStrength", "update:presetStrengthScale", "update:repeatCount", "update:includeNoLora", "toggle-pause", "reset-index", "open-lora-selector"],
|
||||
setup(__props, { emit: __emit }) {
|
||||
const props = __props;
|
||||
const emit2 = __emit;
|
||||
@@ -13551,7 +13591,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return openBlock(), createElementBlock("div", _hoisted_1$3, [
|
||||
_cache[24] || (_cache[24] = createBaseVNode("div", { class: "settings-header" }, [
|
||||
_cache[28] || (_cache[28] = createBaseVNode("div", { class: "settings-header" }, [
|
||||
createBaseVNode("h3", { class: "settings-title" }, "CYCLER SETTINGS")
|
||||
], -1)),
|
||||
createBaseVNode("div", _hoisted_2$3, [
|
||||
@@ -13568,7 +13608,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
title: __props.currentLoraFilename
|
||||
}, [
|
||||
createTextVNode(toDisplayString(__props.currentLoraName || "None") + " ", 1),
|
||||
_cache[12] || (_cache[12] = createBaseVNode("svg", {
|
||||
_cache[14] || (_cache[14] = createBaseVNode("svg", {
|
||||
class: "selector-icon",
|
||||
viewBox: "0 0 24 24",
|
||||
fill: "currentColor"
|
||||
@@ -13579,7 +13619,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
], 2),
|
||||
createBaseVNode("div", _hoisted_5$1, [
|
||||
createBaseVNode("span", _hoisted_6$1, toDisplayString(__props.currentIndex), 1),
|
||||
_cache[13] || (_cache[13] = createBaseVNode("span", { class: "progress-separator" }, "/", -1)),
|
||||
_cache[15] || (_cache[15] = createBaseVNode("span", { class: "progress-separator" }, "/", -1)),
|
||||
createBaseVNode("span", _hoisted_7$1, toDisplayString(__props.totalCount), 1),
|
||||
__props.repeatCount > 1 ? (openBlock(), createElementBlock("div", _hoisted_8, [
|
||||
createBaseVNode("div", _hoisted_9, [
|
||||
@@ -13596,7 +13636,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
createBaseVNode("div", _hoisted_11, [
|
||||
createBaseVNode("div", _hoisted_12, [
|
||||
createBaseVNode("div", _hoisted_13, [
|
||||
_cache[14] || (_cache[14] = createBaseVNode("label", { class: "control-group-label" }, "Starting Index", -1)),
|
||||
_cache[16] || (_cache[16] = createBaseVNode("label", { class: "control-group-label" }, "Starting Index", -1)),
|
||||
createBaseVNode("div", _hoisted_14, [
|
||||
createBaseVNode("input", {
|
||||
type: "number",
|
||||
@@ -13618,7 +13658,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
])
|
||||
]),
|
||||
createBaseVNode("div", _hoisted_17, [
|
||||
_cache[16] || (_cache[16] = createBaseVNode("label", { class: "control-group-label" }, "Repeat", -1)),
|
||||
_cache[18] || (_cache[18] = createBaseVNode("label", { class: "control-group-label" }, "Repeat", -1)),
|
||||
createBaseVNode("div", _hoisted_18, [
|
||||
createBaseVNode("input", {
|
||||
type: "number",
|
||||
@@ -13636,7 +13676,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
}, ["stop"])),
|
||||
title: "Each LoRA will be used this many times before moving to the next"
|
||||
}, null, 40, _hoisted_19),
|
||||
_cache[15] || (_cache[15] = createBaseVNode("span", { class: "repeat-suffix" }, "×", -1))
|
||||
_cache[17] || (_cache[17] = createBaseVNode("span", { class: "repeat-suffix" }, "×", -1))
|
||||
])
|
||||
]),
|
||||
createBaseVNode("div", _hoisted_20, [
|
||||
@@ -13646,9 +13686,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
onClick: _cache[6] || (_cache[6] = ($event) => _ctx.$emit("toggle-pause")),
|
||||
title: __props.isPauseDisabled ? "Cannot pause while prompts are queued" : __props.isPaused ? "Continue iteration" : "Pause iteration"
|
||||
}, [
|
||||
__props.isPaused ? (openBlock(), createElementBlock("svg", _hoisted_22, [..._cache[17] || (_cache[17] = [
|
||||
__props.isPaused ? (openBlock(), createElementBlock("svg", _hoisted_22, [..._cache[19] || (_cache[19] = [
|
||||
createBaseVNode("path", { d: "M8 5v14l11-7z" }, null, -1)
|
||||
])])) : (openBlock(), createElementBlock("svg", _hoisted_23, [..._cache[18] || (_cache[18] = [
|
||||
])])) : (openBlock(), createElementBlock("svg", _hoisted_23, [..._cache[20] || (_cache[20] = [
|
||||
createBaseVNode("path", { d: "M6 4h4v16H6zm8 0h4v16h-4z" }, null, -1)
|
||||
])]))
|
||||
], 10, _hoisted_21),
|
||||
@@ -13656,7 +13696,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
class: "control-btn",
|
||||
onClick: _cache[7] || (_cache[7] = ($event) => _ctx.$emit("reset-index")),
|
||||
title: "Reset to index 1"
|
||||
}, [..._cache[19] || (_cache[19] = [
|
||||
}, [..._cache[21] || (_cache[21] = [
|
||||
createBaseVNode("svg", {
|
||||
viewBox: "0 0 24 24",
|
||||
fill: "currentColor",
|
||||
@@ -13669,7 +13709,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
])
|
||||
]),
|
||||
createBaseVNode("div", _hoisted_24, [
|
||||
_cache[20] || (_cache[20] = createBaseVNode("label", { class: "setting-label" }, "Model Strength", -1)),
|
||||
_cache[22] || (_cache[22] = createBaseVNode("label", { class: "setting-label" }, "Model Strength", -1)),
|
||||
createBaseVNode("div", _hoisted_25, [
|
||||
createVNode(SingleSlider, {
|
||||
min: -10,
|
||||
@@ -13683,18 +13723,47 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
]),
|
||||
createBaseVNode("div", _hoisted_26, [
|
||||
createBaseVNode("div", _hoisted_27, [
|
||||
createBaseVNode("label", _hoisted_28, " Clip Strength - " + toDisplayString(__props.useCustomClipRange ? "Custom Value" : "Use Model Strength"), 1),
|
||||
_cache[24] || (_cache[24] = createBaseVNode("label", { class: "setting-label" }, " Preset Strength Scale ", -1)),
|
||||
createBaseVNode("button", {
|
||||
type: "button",
|
||||
class: normalizeClass(["toggle-switch", { "toggle-switch--active": __props.usePresetStrength }]),
|
||||
onClick: _cache[9] || (_cache[9] = ($event) => _ctx.$emit("update:usePresetStrength", !__props.usePresetStrength)),
|
||||
role: "switch",
|
||||
"aria-checked": __props.usePresetStrength,
|
||||
title: "Use scaled preset strength when enabled"
|
||||
}, [..._cache[23] || (_cache[23] = [
|
||||
createBaseVNode("span", { class: "toggle-switch__track" }, null, -1),
|
||||
createBaseVNode("span", { class: "toggle-switch__thumb" }, null, -1)
|
||||
])], 10, _hoisted_28)
|
||||
]),
|
||||
createBaseVNode("div", {
|
||||
class: normalizeClass(["slider-container", { "slider-container--disabled": !__props.usePresetStrength }])
|
||||
}, [
|
||||
createVNode(SingleSlider, {
|
||||
min: 0,
|
||||
max: 2,
|
||||
value: __props.presetStrengthScale,
|
||||
step: 0.1,
|
||||
"default-range": { min: 0.5, max: 1 },
|
||||
disabled: !__props.usePresetStrength,
|
||||
"onUpdate:value": _cache[10] || (_cache[10] = ($event) => _ctx.$emit("update:presetStrengthScale", $event))
|
||||
}, null, 8, ["value", "disabled"])
|
||||
], 2)
|
||||
]),
|
||||
createBaseVNode("div", _hoisted_29, [
|
||||
createBaseVNode("div", _hoisted_30, [
|
||||
createBaseVNode("label", _hoisted_31, " Clip Strength - " + toDisplayString(__props.useCustomClipRange ? "Custom Value" : "Use Model Strength"), 1),
|
||||
createBaseVNode("button", {
|
||||
type: "button",
|
||||
class: normalizeClass(["toggle-switch", { "toggle-switch--active": __props.useCustomClipRange }]),
|
||||
onClick: _cache[9] || (_cache[9] = ($event) => _ctx.$emit("update:useCustomClipRange", !__props.useCustomClipRange)),
|
||||
onClick: _cache[11] || (_cache[11] = ($event) => _ctx.$emit("update:useCustomClipRange", !__props.useCustomClipRange)),
|
||||
role: "switch",
|
||||
"aria-checked": __props.useCustomClipRange,
|
||||
title: "Use custom clip strength when enabled, otherwise use model strength"
|
||||
}, [..._cache[21] || (_cache[21] = [
|
||||
}, [..._cache[25] || (_cache[25] = [
|
||||
createBaseVNode("span", { class: "toggle-switch__track" }, null, -1),
|
||||
createBaseVNode("span", { class: "toggle-switch__thumb" }, null, -1)
|
||||
])], 10, _hoisted_29)
|
||||
])], 10, _hoisted_32)
|
||||
]),
|
||||
createBaseVNode("div", {
|
||||
class: normalizeClass(["slider-container", { "slider-container--disabled": __props.isClipStrengthDisabled }])
|
||||
@@ -13706,31 +13775,31 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
||||
step: 0.1,
|
||||
"default-range": { min: 0.5, max: 1.5 },
|
||||
disabled: __props.isClipStrengthDisabled,
|
||||
"onUpdate:value": _cache[10] || (_cache[10] = ($event) => _ctx.$emit("update:clipStrength", $event))
|
||||
"onUpdate:value": _cache[12] || (_cache[12] = ($event) => _ctx.$emit("update:clipStrength", $event))
|
||||
}, null, 8, ["value", "disabled"])
|
||||
], 2)
|
||||
]),
|
||||
createBaseVNode("div", _hoisted_30, [
|
||||
createBaseVNode("div", _hoisted_31, [
|
||||
_cache[23] || (_cache[23] = createBaseVNode("label", { class: "setting-label" }, ' Add "No LoRA" step ', -1)),
|
||||
createBaseVNode("div", _hoisted_33, [
|
||||
createBaseVNode("div", _hoisted_34, [
|
||||
_cache[27] || (_cache[27] = createBaseVNode("label", { class: "setting-label" }, ' Add "No LoRA" step ', -1)),
|
||||
createBaseVNode("button", {
|
||||
type: "button",
|
||||
class: normalizeClass(["toggle-switch", { "toggle-switch--active": __props.includeNoLora }]),
|
||||
onClick: _cache[11] || (_cache[11] = ($event) => _ctx.$emit("update:includeNoLora", !__props.includeNoLora)),
|
||||
onClick: _cache[13] || (_cache[13] = ($event) => _ctx.$emit("update:includeNoLora", !__props.includeNoLora)),
|
||||
role: "switch",
|
||||
"aria-checked": __props.includeNoLora,
|
||||
title: "Add an iteration without LoRA for comparison"
|
||||
}, [..._cache[22] || (_cache[22] = [
|
||||
}, [..._cache[26] || (_cache[26] = [
|
||||
createBaseVNode("span", { class: "toggle-switch__track" }, null, -1),
|
||||
createBaseVNode("span", { class: "toggle-switch__thumb" }, null, -1)
|
||||
])], 10, _hoisted_32)
|
||||
])], 10, _hoisted_35)
|
||||
])
|
||||
])
|
||||
]);
|
||||
};
|
||||
}
|
||||
});
|
||||
const LoraCyclerSettingsView = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-f65566fd"]]);
|
||||
const LoraCyclerSettingsView = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-f0663be4"]]);
|
||||
const _hoisted_1$2 = { class: "search-container" };
|
||||
const _hoisted_2$2 = { class: "lora-list" };
|
||||
const _hoisted_3$2 = ["onMouseenter", "onClick"];
|
||||
@@ -13933,6 +14002,8 @@ function useLoraCyclerState(widget) {
|
||||
const modelStrength = ref(1);
|
||||
const clipStrength = ref(1);
|
||||
const useCustomClipRange = ref(false);
|
||||
const usePresetStrength = ref(false);
|
||||
const presetStrengthScale = ref(1);
|
||||
const sortBy = ref("filename");
|
||||
const currentLoraName = ref("");
|
||||
const currentLoraFilename = ref("");
|
||||
@@ -13955,6 +14026,8 @@ function useLoraCyclerState(widget) {
|
||||
model_strength: modelStrength.value,
|
||||
clip_strength: clipStrength.value,
|
||||
use_same_clip_strength: !useCustomClipRange.value,
|
||||
use_preset_strength: usePresetStrength.value,
|
||||
preset_strength_scale: presetStrengthScale.value,
|
||||
sort_by: sortBy.value,
|
||||
current_lora_name: currentLoraName.value,
|
||||
current_lora_filename: currentLoraFilename.value,
|
||||
@@ -13973,6 +14046,8 @@ function useLoraCyclerState(widget) {
|
||||
model_strength: modelStrength.value,
|
||||
clip_strength: clipStrength.value,
|
||||
use_same_clip_strength: !useCustomClipRange.value,
|
||||
use_preset_strength: usePresetStrength.value,
|
||||
preset_strength_scale: presetStrengthScale.value,
|
||||
sort_by: sortBy.value,
|
||||
current_lora_name: currentLoraName.value,
|
||||
current_lora_filename: currentLoraFilename.value,
|
||||
@@ -13993,6 +14068,8 @@ function useLoraCyclerState(widget) {
|
||||
modelStrength.value = config.model_strength ?? 1;
|
||||
clipStrength.value = config.clip_strength ?? 1;
|
||||
useCustomClipRange.value = !(config.use_same_clip_strength ?? true);
|
||||
usePresetStrength.value = config.use_preset_strength ?? false;
|
||||
presetStrengthScale.value = config.preset_strength_scale ?? 1;
|
||||
sortBy.value = config.sort_by || "filename";
|
||||
currentLoraName.value = config.current_lora_name || "";
|
||||
currentLoraFilename.value = config.current_lora_filename || "";
|
||||
@@ -14122,6 +14199,8 @@ function useLoraCyclerState(widget) {
|
||||
modelStrength,
|
||||
clipStrength,
|
||||
useCustomClipRange,
|
||||
usePresetStrength,
|
||||
presetStrengthScale,
|
||||
sortBy,
|
||||
currentLoraName,
|
||||
currentLoraFilename,
|
||||
@@ -14140,6 +14219,8 @@ function useLoraCyclerState(widget) {
|
||||
modelStrength,
|
||||
clipStrength,
|
||||
useCustomClipRange,
|
||||
usePresetStrength,
|
||||
presetStrengthScale,
|
||||
sortBy,
|
||||
currentLoraName,
|
||||
currentLoraFilename,
|
||||
@@ -14476,6 +14557,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
||||
"model-strength": unref(state).modelStrength.value,
|
||||
"clip-strength": unref(state).clipStrength.value,
|
||||
"use-custom-clip-range": unref(state).useCustomClipRange.value,
|
||||
"use-preset-strength": unref(state).usePresetStrength.value,
|
||||
"preset-strength-scale": unref(state).presetStrengthScale.value,
|
||||
"is-clip-strength-disabled": unref(state).isClipStrengthDisabled.value,
|
||||
"is-loading": unref(state).isLoading.value,
|
||||
"repeat-count": unref(state).repeatCount.value,
|
||||
@@ -14490,25 +14573,27 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
||||
"onUpdate:modelStrength": _cache[0] || (_cache[0] = ($event) => unref(state).modelStrength.value = $event),
|
||||
"onUpdate:clipStrength": _cache[1] || (_cache[1] = ($event) => unref(state).clipStrength.value = $event),
|
||||
"onUpdate:useCustomClipRange": handleUseCustomClipRangeChange,
|
||||
"onUpdate:usePresetStrength": _cache[2] || (_cache[2] = ($event) => unref(state).usePresetStrength.value = $event),
|
||||
"onUpdate:presetStrengthScale": _cache[3] || (_cache[3] = ($event) => unref(state).presetStrengthScale.value = $event),
|
||||
"onUpdate:repeatCount": handleRepeatCountChange,
|
||||
"onUpdate:includeNoLora": handleIncludeNoLoraChange,
|
||||
onTogglePause: handleTogglePause,
|
||||
onResetIndex: handleResetIndex,
|
||||
onOpenLoraSelector: _cache[2] || (_cache[2] = ($event) => isModalOpen.value = true)
|
||||
}, null, 8, ["current-index", "total-count", "current-lora-name", "current-lora-filename", "model-strength", "clip-strength", "use-custom-clip-range", "is-clip-strength-disabled", "is-loading", "repeat-count", "repeat-used", "is-paused", "is-pause-disabled", "is-workflow-executing", "executing-repeat-step", "include-no-lora", "is-no-lora"]),
|
||||
onOpenLoraSelector: _cache[4] || (_cache[4] = ($event) => isModalOpen.value = true)
|
||||
}, null, 8, ["current-index", "total-count", "current-lora-name", "current-lora-filename", "model-strength", "clip-strength", "use-custom-clip-range", "use-preset-strength", "preset-strength-scale", "is-clip-strength-disabled", "is-loading", "repeat-count", "repeat-used", "is-paused", "is-pause-disabled", "is-workflow-executing", "executing-repeat-step", "include-no-lora", "is-no-lora"]),
|
||||
createVNode(LoraListModal, {
|
||||
visible: isModalOpen.value,
|
||||
"lora-list": cachedLoraList.value,
|
||||
"current-index": unref(state).currentIndex.value,
|
||||
"include-no-lora": unref(state).includeNoLora.value,
|
||||
onClose: _cache[3] || (_cache[3] = ($event) => isModalOpen.value = false),
|
||||
onClose: _cache[5] || (_cache[5] = ($event) => isModalOpen.value = false),
|
||||
onSelect: handleModalSelect
|
||||
}, null, 8, ["visible", "lora-list", "current-index", "include-no-lora"])
|
||||
], 32);
|
||||
};
|
||||
}
|
||||
});
|
||||
const LoraCyclerWidget = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-b97187b9"]]);
|
||||
const LoraCyclerWidget = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-3f46897a"]]);
|
||||
const _hoisted_1$1 = { class: "json-display-widget" };
|
||||
const _hoisted_2$1 = {
|
||||
class: "json-content",
|
||||
@@ -14853,11 +14938,24 @@ const LORA_PROVIDER_NODE_TYPES$1 = [
|
||||
"Lora Randomizer (LoraManager)",
|
||||
"Lora Cycler (LoraManager)"
|
||||
];
|
||||
const LORA_STACK_AGGREGATOR_NODE_TYPES$1 = [
|
||||
"Lora Stack Combiner (LoraManager)"
|
||||
];
|
||||
const LORA_CHAIN_NODE_TYPES$1 = [
|
||||
...LORA_PROVIDER_NODE_TYPES$1,
|
||||
...LORA_STACK_AGGREGATOR_NODE_TYPES$1
|
||||
];
|
||||
function isLoraStackAggregatorNode$1(comfyClass) {
|
||||
return LORA_STACK_AGGREGATOR_NODE_TYPES$1.includes(comfyClass);
|
||||
}
|
||||
function getActiveLorasFromNodeByType(node) {
|
||||
const comfyClass = node == null ? void 0 : node.comfyClass;
|
||||
if (comfyClass === "Lora Cycler (LoraManager)") {
|
||||
return extractFromCyclerConfig(node);
|
||||
}
|
||||
if (isLoraStackAggregatorNode$1(comfyClass)) {
|
||||
return /* @__PURE__ */ new Set();
|
||||
}
|
||||
return extractFromLorasWidget(node);
|
||||
}
|
||||
function extractFromLorasWidget(node) {
|
||||
@@ -14917,8 +15015,18 @@ const LORA_PROVIDER_NODE_TYPES = [
|
||||
"Lora Randomizer (LoraManager)",
|
||||
"Lora Cycler (LoraManager)"
|
||||
];
|
||||
function isLoraProviderNode(comfyClass) {
|
||||
return LORA_PROVIDER_NODE_TYPES.includes(comfyClass);
|
||||
const LORA_STACK_AGGREGATOR_NODE_TYPES = [
|
||||
"Lora Stack Combiner (LoraManager)"
|
||||
];
|
||||
const LORA_CHAIN_NODE_TYPES = [
|
||||
...LORA_PROVIDER_NODE_TYPES,
|
||||
...LORA_STACK_AGGREGATOR_NODE_TYPES
|
||||
];
|
||||
function isLoraStackAggregatorNode(comfyClass) {
|
||||
return LORA_STACK_AGGREGATOR_NODE_TYPES.includes(comfyClass);
|
||||
}
|
||||
function isLoraChainNode(comfyClass) {
|
||||
return LORA_CHAIN_NODE_TYPES.includes(comfyClass);
|
||||
}
|
||||
function isMapLike(collection) {
|
||||
return collection && typeof collection.entries === "function" && typeof collection.values === "function";
|
||||
@@ -14956,14 +15064,17 @@ function getLinkFromGraph(graph, linkId) {
|
||||
}
|
||||
return graph.links[linkId] || null;
|
||||
}
|
||||
function getConnectedInputStackers(node) {
|
||||
function isLoraStackInput(input) {
|
||||
return (input == null ? void 0 : input.type) === "LORA_STACK";
|
||||
}
|
||||
function getConnectedInputLoraChainNodes(node) {
|
||||
var _a2, _b;
|
||||
const connectedStackers = [];
|
||||
const connectedNodes = [];
|
||||
if (!(node == null ? void 0 : node.inputs)) {
|
||||
return connectedStackers;
|
||||
return connectedNodes;
|
||||
}
|
||||
for (const input of node.inputs) {
|
||||
if (input.name !== "lora_stack" || !input.link) {
|
||||
if (!isLoraStackInput(input) || !input.link) {
|
||||
continue;
|
||||
}
|
||||
const link = getLinkFromGraph(node.graph, input.link);
|
||||
@@ -14971,11 +15082,11 @@ function getConnectedInputStackers(node) {
|
||||
continue;
|
||||
}
|
||||
const sourceNode = (_b = (_a2 = node.graph) == null ? void 0 : _a2.getNodeById) == null ? void 0 : _b.call(_a2, link.origin_id);
|
||||
if (sourceNode && isLoraProviderNode(sourceNode.comfyClass)) {
|
||||
connectedStackers.push(sourceNode);
|
||||
if (sourceNode && isLoraChainNode(sourceNode.comfyClass)) {
|
||||
connectedNodes.push(sourceNode);
|
||||
}
|
||||
}
|
||||
return connectedStackers;
|
||||
return connectedNodes;
|
||||
}
|
||||
function getConnectedTriggerToggleNodes(node) {
|
||||
var _a2, _b, _c;
|
||||
@@ -15010,6 +15121,9 @@ function getActiveLorasFromNode(node) {
|
||||
}
|
||||
return activeLoraNames;
|
||||
}
|
||||
if (isLoraStackAggregatorNode(node.comfyClass)) {
|
||||
return activeLoraNames;
|
||||
}
|
||||
let lorasWidget = node.lorasWidget;
|
||||
if (!lorasWidget && node.widgets) {
|
||||
lorasWidget = node.widgets.find((w2) => w2.name === "loras");
|
||||
@@ -15033,11 +15147,14 @@ function collectActiveLorasFromChain(node, visited = /* @__PURE__ */ new Set())
|
||||
}
|
||||
visited.add(nodeKey);
|
||||
const isNodeActive2 = node.mode === void 0 || node.mode === 0 || node.mode === 3;
|
||||
const allActiveLoraNames = isNodeActive2 ? getActiveLorasFromNode(node) : /* @__PURE__ */ new Set();
|
||||
const inputStackers = getConnectedInputStackers(node);
|
||||
for (const stacker of inputStackers) {
|
||||
const stackerLoras = collectActiveLorasFromChain(stacker, visited);
|
||||
stackerLoras.forEach((name) => allActiveLoraNames.add(name));
|
||||
if (!isNodeActive2) {
|
||||
return /* @__PURE__ */ new Set();
|
||||
}
|
||||
const allActiveLoraNames = getActiveLorasFromNode(node);
|
||||
const inputChainNodes = getConnectedInputLoraChainNodes(node);
|
||||
for (const chainNode of inputChainNodes) {
|
||||
const upstreamLoras = collectActiveLorasFromChain(chainNode, visited);
|
||||
upstreamLoras.forEach((name) => allActiveLoraNames.add(name));
|
||||
}
|
||||
return allActiveLoraNames;
|
||||
}
|
||||
@@ -15106,7 +15223,7 @@ function updateDownstreamLoaders(startNode, visited = /* @__PURE__ */ new Set())
|
||||
if (targetNode && targetNode.comfyClass === "Lora Loader (LoraManager)") {
|
||||
const allActiveLoraNames = collectActiveLorasFromChain(targetNode);
|
||||
updateConnectedTriggerWords(targetNode, allActiveLoraNames);
|
||||
} else if (targetNode && isLoraProviderNode(targetNode.comfyClass)) {
|
||||
} else if (targetNode && isLoraChainNode(targetNode.comfyClass)) {
|
||||
updateDownstreamLoaders(targetNode, visited);
|
||||
}
|
||||
}
|
||||
@@ -15121,7 +15238,7 @@ const LORA_RANDOMIZER_WIDGET_MIN_WIDTH = 500;
|
||||
const LORA_RANDOMIZER_WIDGET_MIN_HEIGHT = 448;
|
||||
const LORA_RANDOMIZER_WIDGET_MAX_HEIGHT = LORA_RANDOMIZER_WIDGET_MIN_HEIGHT;
|
||||
const LORA_CYCLER_WIDGET_MIN_WIDTH = 380;
|
||||
const LORA_CYCLER_WIDGET_MIN_HEIGHT = 344;
|
||||
const LORA_CYCLER_WIDGET_MIN_HEIGHT = 408;
|
||||
const LORA_CYCLER_WIDGET_MAX_HEIGHT = LORA_CYCLER_WIDGET_MIN_HEIGHT;
|
||||
const JSON_DISPLAY_WIDGET_MIN_WIDTH = 300;
|
||||
const JSON_DISPLAY_WIDGET_MIN_HEIGHT = 200;
|
||||
@@ -15262,7 +15379,8 @@ function createLoraRandomizerWidget(node) {
|
||||
};
|
||||
const vueApp = createApp(LoraRandomizerWidget, {
|
||||
widget,
|
||||
node
|
||||
node,
|
||||
api
|
||||
});
|
||||
vueApp.use(PrimeVue, {
|
||||
unstyled: true,
|
||||
@@ -15294,7 +15412,24 @@ function createLoraCyclerWidget(node) {
|
||||
container.style.flexDirection = "column";
|
||||
container.style.overflow = "hidden";
|
||||
forwardMiddleMouseToCanvas(container);
|
||||
let internalValue;
|
||||
const defaultConfig = {
|
||||
current_index: 1,
|
||||
total_count: 0,
|
||||
pool_config_hash: "",
|
||||
model_strength: 1,
|
||||
clip_strength: 1,
|
||||
use_same_clip_strength: true,
|
||||
use_preset_strength: false,
|
||||
preset_strength_scale: 1,
|
||||
sort_by: "filename",
|
||||
current_lora_name: "",
|
||||
current_lora_filename: "",
|
||||
repeat_count: 1,
|
||||
repeat_used: 0,
|
||||
is_paused: false,
|
||||
include_no_lora: false
|
||||
};
|
||||
let internalValue = defaultConfig;
|
||||
const widget = node.addDOMWidget(
|
||||
"cycler_config",
|
||||
"CYCLER_CONFIG",
|
||||
@@ -15681,7 +15816,7 @@ app$1.registerExtension({
|
||||
return originalConfigure == null ? void 0 : originalConfigure.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
if (LORA_PROVIDER_NODE_TYPES$1.includes(comfyClass)) {
|
||||
if (LORA_CHAIN_NODE_TYPES$1.includes(comfyClass)) {
|
||||
const originalOnNodeCreated = nodeType.prototype.onNodeCreated;
|
||||
nodeType.prototype.onNodeCreated = function() {
|
||||
originalOnNodeCreated == null ? void 0 : originalOnNodeCreated.apply(this, arguments);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user