mirror of
https://github.com/SamueleLorefice/ComfySharp
synced 2026-01-15 16:43:41 +00:00
Adjusted logging levels for a less spammy logging, added extra documentation
This commit is contained in:
@@ -74,7 +74,7 @@ public class ComfyClient {
|
|||||||
if (req is { IsSuccessStatusCode: true, Content: not null }) {
|
if (req is { IsSuccessStatusCode: true, Content: not null }) {
|
||||||
var doc = await req.Content.ReadFromJsonAsync<JsonDocument>();
|
var doc = await req.Content.ReadFromJsonAsync<JsonDocument>();
|
||||||
dbGenerator.GenerateClasses(doc);
|
dbGenerator.GenerateClasses(doc);
|
||||||
//ObjectInfoParser.Parse(doc, out nodes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -87,14 +87,19 @@ public class NodeDBGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates C# classes for all known types, enums and stringLists, then also for every node
|
||||||
|
/// </summary>
|
||||||
|
/// <property name="document">JsonDocument containing the nodes off an objectInfo api call</property>
|
||||||
public void GenerateClasses(JsonDocument document) {
|
public void GenerateClasses(JsonDocument document) {
|
||||||
|
Logger.Info("NodeDB Scan phase 1: building Types, Enum and StringLists DataBases");
|
||||||
foreach (var node in document.RootElement.EnumerateObject())
|
foreach (var node in document.RootElement.EnumerateObject())
|
||||||
ScanNode(node);
|
ScanNode(node);
|
||||||
|
|
||||||
string types = "";
|
string types = "";
|
||||||
foreach (var knownType in knownTypes)
|
foreach (var knownType in knownTypes)
|
||||||
types += $"\t{knownType}";
|
types += $"\t{knownType}";
|
||||||
Logger.Info($"List of recognized Types:\n{types}");
|
Logger.Debug($"List of recognized Types:\n{types}");
|
||||||
Logger.Info($"Total amount of types iterated: {typeFields}\n");
|
Logger.Info($"Total amount of types iterated: {typeFields}\n");
|
||||||
|
|
||||||
string enums = "";
|
string enums = "";
|
||||||
@@ -104,8 +109,11 @@ public class NodeDBGenerator {
|
|||||||
enums += $"\t{value}";
|
enums += $"\t{value}";
|
||||||
enums += "\n";
|
enums += "\n";
|
||||||
}
|
}
|
||||||
Logger.Info($"List of recognized Enums: {enums}");
|
Logger.Debug($"List of recognized Enums: {enums}");
|
||||||
Logger.Info($"Total amount of enums iterated: {enumFields}\n");
|
Logger.Info($"Total amount of enums iterated: {enumFields}\n");
|
||||||
|
|
||||||
|
Logger.Info("NodeDB Scan phase 2: generating types");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -131,7 +139,7 @@ public class NodeDBGenerator {
|
|||||||
/// Executed on the input property inside a node
|
/// Executed on the input property inside a node
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ScanInputs(JsonProperty input) {
|
private void ScanInputs(JsonProperty input) {
|
||||||
Logger.Debug($"Scanning inputs of node: {input.Name}");
|
Logger.Trace($"Scanning inputs of node: {input.Name}");
|
||||||
foreach (var inputType in input.Value.EnumerateObject()) {
|
foreach (var inputType in input.Value.EnumerateObject()) {
|
||||||
//these are related to the nodes themselves and useless for us
|
//these are related to the nodes themselves and useless for us
|
||||||
if (inputType.Name == "hidden") continue;
|
if (inputType.Name == "hidden") continue;
|
||||||
@@ -145,7 +153,7 @@ public class NodeDBGenerator {
|
|||||||
/// Executed for each of the elements inside a required or optional input
|
/// Executed for each of the elements inside a required or optional input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ScanInputField(JsonProperty inputProperty) {
|
private void ScanInputField(JsonProperty inputProperty) {
|
||||||
Logger.Debug($"Scanning input field: {inputProperty.Name}");
|
Logger.Trace($"Scanning input field: {inputProperty.Name}");
|
||||||
|
|
||||||
// if element 0 is a string, this is a type
|
// if element 0 is a string, this is a type
|
||||||
if (inputProperty.Value[0].ValueKind == JsonValueKind.String) {
|
if (inputProperty.Value[0].ValueKind == JsonValueKind.String) {
|
||||||
@@ -186,8 +194,11 @@ public class NodeDBGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executed for each output array of every node.
|
||||||
|
/// </summary>
|
||||||
private void ScanOutputs(JsonProperty output) {
|
private void ScanOutputs(JsonProperty output) {
|
||||||
Logger.Debug($"Scanning outputs of node: {output.Name}");
|
Logger.Trace($"Scanning outputs of node: {output.Name}");
|
||||||
foreach (var outputType in output.Value.EnumerateArray()) AddKnownType(outputType.GetString()!);
|
foreach (var outputType in output.Value.EnumerateArray()) AddKnownType(outputType.GetString()!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user