fix: 🐛 debug issues

also properly print to console now...
This commit is contained in:
Mel Massadian
2024-04-21 17:01:25 +02:00
parent e838c04758
commit 7807449e6d
3 changed files with 13 additions and 9 deletions
+5 -2
View File
@@ -47,6 +47,8 @@ def process_list(anything):
text.append(
f"List of Tensors: {first_element.shape} (x{len(anything)})"
)
else:
text.append(f"Array: {anything}")
return {"text": text}
@@ -90,7 +92,7 @@ class MTB_Debug:
CATEGORY = "mtb/debug"
OUTPUT_NODE = True
def do_debug(self, output_to_console, **kwargs):
def do_debug(self, output_to_console: bool, **kwargs):
output = {
"ui": {"b64_images": [], "text": []},
# "result": ("A"),
@@ -103,7 +105,8 @@ class MTB_Debug:
bool: process_bool,
}
if output_to_console:
print("bouh!")
for k, v in kwargs.items():
print(f"{k}: {v}")
for anything in kwargs.values():
processor = processors.get(type(anything), process_text)
+7 -5
View File
@@ -45,16 +45,18 @@ export class LocalStorageManager {
}
clear() {
Object.keys(localStorage)
.filter((k) => k.startsWith(this.namespace + ':'))
.forEach((k) => localStorage.removeItem(k))
for (const key of Object.keys(localStorage).filter((k) =>
k.startsWith(`${this.namespace}:`),
)) {
localStorage.removeItem(key)
}
}
}
// - log utilities
function createLogger(emoji, color, consoleMethod = 'log') {
return function (message, ...args) {
return (message, ...args) => {
if (window.MTB?.DEBUG) {
console[consoleMethod](
`%c${emoji} ${message}`,
@@ -147,7 +149,7 @@ export function getWidgetType(config) {
// Special handling for COMBO so we restrict links based on the entries
let type = config?.[0]
let linkType = type
if (type instanceof Array) {
if (Array.isArray(type)) {
type = 'COMBO'
linkType = linkType.join(',')
}
+1 -2
View File
@@ -52,7 +52,7 @@ app.registerExtension({
//- infer type
if (link_info) {
const fromNode = this.graph._nodes.find(
(otherNode) => otherNode.id == link_info.origin_id,
(otherNode) => otherNode.id === link_info.origin_id,
)
const type = fromNode.outputs[link_info.origin_slot].type
this.inputs[index].type = type
@@ -83,7 +83,6 @@ app.registerExtension({
this.widgets.length = 1
}
let widgetI = 1
if (message.text) {
for (const txt of message.text) {
const w = this.addCustomWidget(