@@ -54,12 +54,11 @@ public object Post(UpdateComfyAgent request)
54
54
return new EmptyResponse ( ) ;
55
55
}
56
56
57
+ agent . SetLastUpdate ( ) ;
57
58
agent . QueueCount = request . QueueCount ;
58
59
agent . RunningGenerationIds = request . RunningGenerationIds ?? [ ] ;
59
60
agent . QueuedGenerationIds = request . QueuedGenerationIds ?? [ ] ;
60
61
agent . QueuedIds = [ ..agent . QueuedGenerationIds , ..agent . RunningGenerationIds ] ;
61
- agent . LastUpdate = DateTime . UtcNow ;
62
- agent . ModifiedDate = DateTime . UtcNow ;
63
62
agent . Gpus = request . Gpus ?? agent . Gpus ;
64
63
agent . RunningGenerationIds = request . RunningGenerationIds ?? [ ] ;
65
64
agent . QueuedGenerationIds = request . QueuedGenerationIds ?? [ ] ;
@@ -68,7 +67,7 @@ public object Post(UpdateComfyAgent request)
68
67
{
69
68
QueueCount = agent . QueueCount ,
70
69
Gpus = agent . Gpus ,
71
- ModifiedDate = now ,
70
+ ModifiedDate = agent . ModifiedDate ,
72
71
LastIp = Request ! . UserHostAddress ,
73
72
} , where : x => x . DeviceId == request . DeviceId ) ;
74
73
@@ -107,14 +106,40 @@ public object Any(UpdateComfyAgentStatus request)
107
106
return new EmptyResponse ( ) ;
108
107
}
109
108
109
+ agent . Status = request . Status ?? agent . Status ;
110
+ agent . Downloading = request . Downloading ?? agent . Downloading ;
111
+ agent . Downloaded = request . Downloaded ?? agent . Downloaded ;
112
+ agent . DownloadFailed = request . DownloadFailed ?? agent . DownloadFailed ;
113
+ agent . Logs = request . Logs ?? agent . Logs ;
114
+ agent . Error = request . Error ?? agent . Error ;
115
+ agent . SetLastUpdate ( now ) ;
116
+
110
117
using var db = Db ;
111
- db . UpdateOnly ( ( ) => new ComfyAgent
118
+ if ( request . Logs != null )
112
119
{
113
- Status = request . Status ?? agent . Status ,
114
- Logs = request . Logs ?? agent . Logs ,
115
- Error = request . Error ?? agent . Error ,
116
- ModifiedDate = now ,
117
- } , where : x => x . DeviceId == request . DeviceId ) ;
120
+ db . UpdateOnly ( ( ) => new ComfyAgent
121
+ {
122
+ Status = agent . Status ,
123
+ Downloading = agent . Downloading ,
124
+ Downloaded = agent . Downloaded ,
125
+ DownloadFailed = agent . DownloadFailed ,
126
+ Logs = agent . Logs ,
127
+ Error = agent . Error ,
128
+ ModifiedDate = agent . ModifiedDate ,
129
+ } , where : x => x . DeviceId == request . DeviceId ) ;
130
+ }
131
+ else
132
+ {
133
+ db . UpdateOnly ( ( ) => new ComfyAgent
134
+ {
135
+ Status = agent . Status ,
136
+ Downloading = agent . Downloading ,
137
+ Downloaded = agent . Downloaded ,
138
+ DownloadFailed = agent . DownloadFailed ,
139
+ Error = agent . Error ,
140
+ ModifiedDate = now ,
141
+ } , where : x => x . DeviceId == request . DeviceId ) ;
142
+ }
118
143
119
144
return new EmptyResponse ( ) ;
120
145
}
@@ -150,7 +175,7 @@ public async Task<object> Get(GetComfyAgentEvents request)
150
175
ret . Results . Add ( new AgentEvent { Name = EventMessages . Register } ) ;
151
176
return ret ;
152
177
}
153
- agent . ModifiedDate = agent . LastUpdate = DateTime . UtcNow ;
178
+ agent . SetLastUpdate ( ) ;
154
179
155
180
// Return any pending events immediately
156
181
var agentEvents = agentManager . GetAgentEvents ( agent . DeviceId ) ;
@@ -271,11 +296,13 @@ public async Task<object> Any(RegisterComfyAgent request)
271
296
RequireNodes = appData . RequireNodes ,
272
297
RequireModels = appData . RequireModels ,
273
298
DevicePool = DateTime . UtcNow ,
299
+ Settings = new ComfyAgentSettings {
300
+ PreserveOutputs = false ,
301
+ } ,
274
302
} ;
275
303
}
276
304
277
- agent . LastUpdate = DateTime . UtcNow ;
278
-
305
+ agent . SetLastUpdate ( ) ;
279
306
agent . Version = request . Version ;
280
307
agent . ComfyVersion = request . ComfyVersion ;
281
308
agent . Gpus = request . Gpus ;
@@ -286,9 +313,9 @@ public async Task<object> Any(RegisterComfyAgent request)
286
313
agent . ApiKey = apiKey . Key ;
287
314
agent . Enabled = true ;
288
315
agent . OfflineDate = null ;
289
- agent . ModifiedDate = DateTime . UtcNow ;
290
316
agent . LastIp = Request . UserHostAddress ;
291
317
agent . LanguageModels = request . LanguageModels ;
318
+ agent . Downloading = null ;
292
319
agent . Status = "Registered" ;
293
320
agent . Logs = null ;
294
321
agent . Error = null ;
@@ -298,25 +325,37 @@ public async Task<object> Any(RegisterComfyAgent request)
298
325
agent . Checkpoints = sorted ( checkpointLoader . GetInput ( "ckpt_name" ) ? . EnumValues ) ;
299
326
300
327
if ( nodeDefs . TryGetValue ( "UNETLoader" , out var unetLoader ) )
301
- agent . Unets = sorted ( unetLoader . GetInput ( "unet_name" ) ? . EnumValues ) ;
328
+ agent . DiffusionModels = sorted ( unetLoader . GetInput ( "unet_name" ) ? . EnumValues ) ;
302
329
if ( nodeDefs . TryGetValue ( "VAELoader" , out var vaeLoader ) )
303
- agent . Vaes = sorted ( vaeLoader . GetInput ( "vae_name" ) ? . EnumValues ) ;
330
+ agent . Vae = sorted ( vaeLoader . GetInput ( "vae_name" ) ? . EnumValues ) ;
304
331
if ( nodeDefs . TryGetValue ( "CLIPLoader" , out var clipLoader ) )
305
- agent . Clips = sorted ( clipLoader . GetInput ( "clip_name" ) ? . EnumValues ) ;
332
+ agent . Clip = sorted ( clipLoader . GetInput ( "clip_name" ) ? . EnumValues ) ;
306
333
if ( nodeDefs . TryGetValue ( "CLIPVisionLoader" , out var clipVisionLoader ) )
307
- agent . ClipVisions = sorted ( clipVisionLoader . GetInput ( "clip_name" ) ? . EnumValues ) ;
334
+ agent . ClipVision = sorted ( clipVisionLoader . GetInput ( "clip_name" ) ? . EnumValues ) ;
308
335
if ( nodeDefs . TryGetValue ( "LoraLoader" , out var loraLoader ) )
309
336
agent . Loras = sorted ( loraLoader . GetInput ( "lora_name" ) ? . EnumValues ) ;
310
337
if ( nodeDefs . TryGetValue ( "UpscaleModelLoader" , out var upscaleLoader ) )
311
- agent . Upscalers = sorted ( upscaleLoader . GetInput ( "model_name" ) ? . EnumValues ) ;
338
+ agent . UpscaleModels = sorted ( upscaleLoader . GetInput ( "model_name" ) ? . EnumValues ) ;
312
339
if ( nodeDefs . TryGetValue ( "ControlNetLoader" , out var controlNetLoader ) )
313
- agent . ControlNets = sorted ( controlNetLoader . GetInput ( "control_net_name" ) ? . EnumValues ) ;
340
+ agent . Controlnet = sorted ( controlNetLoader . GetInput ( "control_net_name" ) ? . EnumValues ) ;
314
341
if ( nodeDefs . TryGetValue ( "StyleModelLoader" , out var styleLoader ) )
315
- agent . Stylers = sorted ( styleLoader . GetInput ( "style_model_name" ) ? . EnumValues ) ;
342
+ agent . StyleModels = sorted ( styleLoader . GetInput ( "style_model_name" ) ? . EnumValues ) ;
316
343
if ( nodeDefs . TryGetValue ( "PhotoMakerLoader" , out var photoMakerLoader ) )
317
- agent . PhotoMakers = sorted ( photoMakerLoader . GetInput ( "photomaker_model_name" ) ? . EnumValues ) ;
344
+ agent . Photomaker = sorted ( photoMakerLoader . GetInput ( "photomaker_model_name" ) ? . EnumValues ) ;
318
345
if ( nodeDefs . TryGetValue ( "GLIGENLoader" , out var gligenLoader ) )
319
- agent . Gligens = sorted ( gligenLoader . GetInput ( "gligen_name" ) ? . EnumValues ) ;
346
+ agent . Gligen = sorted ( gligenLoader . GetInput ( "gligen_name" ) ? . EnumValues ) ;
347
+
348
+ //TODO Verify predicted locations
349
+ agent . Hypernetworks = sorted ( nodeDefs . TryGetValue ( "HypernetworkLoader" , out var hypernetworkLoader )
350
+ ? hypernetworkLoader . GetInput ( "hypernetwork_name" ) ? . EnumValues : null ) ;
351
+ agent . Diffusers = sorted ( nodeDefs . TryGetValue ( "DiffusersLoader" , out var diffusersLoader )
352
+ ? diffusersLoader . GetInput ( "model_path" ) ? . EnumValues : null ) ; // diffusers_name?
353
+ agent . Embeddings = sorted ( nodeDefs . TryGetValue ( "TextualInversionLoader" , out var textualInversionLoader )
354
+ ? textualInversionLoader . GetInput ( "textual_inversion_name" ) ? . EnumValues : null ) ;
355
+ agent . Configs = sorted ( nodeDefs . TryGetValue ( "ConfigLoader" , out var configLoader )
356
+ ? configLoader . GetInput ( "config_name" ) ? . EnumValues : null ) ;
357
+ agent . VaeApprox = sorted ( nodeDefs . TryGetValue ( "VAEApproxLoader" , out var vaeApproxLoader )
358
+ ? vaeApproxLoader . GetInput ( "vae_approx_name" ) ? . EnumValues : null ) ;
320
359
321
360
db . Save ( agent ) ;
322
361
@@ -353,6 +392,7 @@ public async Task<object> Any(RegisterComfyAgent request)
353
392
RequirePip = appData . RequirePip ,
354
393
RequireNodes = appData . RequireNodes ,
355
394
RequireModels = appData . RequireModels ,
395
+ Settings = agent . Settings ,
356
396
} ;
357
397
358
398
return ret ;
0 commit comments