Skip to content

Commit

Permalink
* cleared serialization bug
Browse files Browse the repository at this point in the history
* better "docker" environment check
* cleaner type hints
  • Loading branch information
Amorano committed Feb 10, 2025
1 parent e9fdd09 commit b5e7668
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 75 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ You can colorize nodes via their `title background`, `node body` or `title text`

## UPDATES

**2024/02/07** @1.7.9:
**2024/02/10** @1.7.12:
* cleared serialization bug
* better "docker" environment check
* cleaner type hints

**2024/02/08** @1.7.9:
* moved to proper semantic version numbers
* PyOpenGL-accelerate updated to 3.1.9
* better versioning in requirements around numpy

* cleaner
**2024/02/07** @1.7.08:
* `JOV_SCAN_DEVICES` reset to default off.

Expand Down
11 changes: 10 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,16 @@
# direct the documentation output -- used to build jovimetrix-examples
JOV_INTERNAL_DOC = os.getenv("JOV_INTERNAL_DOC", str(ROOT / "_doc"))

JOV_DOCKERENV = os.path.exists('/.dockerenv')
JOV_DOCKERENV = False
try:
with open('/proc/1/cgroup', 'rt') as f:
content = f.read()
JOV_DOCKERENV = any(x in content for x in ['docker', 'kubepods', 'containerd'])
except FileNotFoundError:
pass

if JOV_DOCKERENV:
logger.info("RUNNING IN A DOCKER")

# The object_info route data -- cached
COMFYUI_OBJ_DATA = {}
Expand Down
4 changes: 2 additions & 2 deletions core/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
# turn any all inputs into the
data_list = parse_dynamic(kw, Lexicon.UNKNOWN, EnumConvertType.ANY, [""])
if data_list is None:
Expand Down Expand Up @@ -768,7 +768,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
pA = parse_param(kw, Lexicon.IN_A, EnumConvertType.VEC4, [(0,0,0,0)])
pB = parse_param(kw, Lexicon.IN_B, EnumConvertType.VEC4, [(0,0,0,0)])
swap_x = parse_param(kw, Lexicon.SWAP_X, EnumSwizzle, EnumSwizzle.A_X.name)
Expand Down
12 changes: 6 additions & 6 deletions core/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
pA = parse_param(kw, Lexicon.PIXEL_A, EnumConvertType.IMAGE, None)
pB = parse_param(kw, Lexicon.PIXEL_B, EnumConvertType.IMAGE, None)
mask = parse_param(kw, Lexicon.MASK, EnumConvertType.MASK, None)
Expand Down Expand Up @@ -760,7 +760,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
rgba = parse_param(kw, Lexicon.PIXEL, EnumConvertType.IMAGE, None)
R = parse_param(kw, Lexicon.R, EnumConvertType.MASK, None)
G = parse_param(kw, Lexicon.G, EnumConvertType.MASK, None)
Expand Down Expand Up @@ -832,7 +832,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
images = []
pA = parse_param(kw, Lexicon.PIXEL, EnumConvertType.IMAGE, None)
pbar = ProgressBar(len(pA))
Expand Down Expand Up @@ -870,7 +870,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
pA = parse_param(kw, Lexicon.PIXEL_A, EnumConvertType.IMAGE, None)
pB = parse_param(kw, Lexicon.PIXEL_B, EnumConvertType.IMAGE, None)
swap_r = parse_param(kw, Lexicon.SWAP_R, EnumPixelSwizzle, EnumPixelSwizzle.RED_A.name)
Expand Down Expand Up @@ -932,7 +932,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
images = parse_dynamic(kw, Lexicon.IMAGE, EnumConvertType.IMAGE, None)
if len(images) == 0:
logger.warning("no images to stack")
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
pA = parse_param(kw, Lexicon.PIXEL, EnumConvertType.IMAGE, None)
offset = parse_param(kw, Lexicon.XY, EnumConvertType.VEC2, [(0, 0)], -2.5, 2.5)
angle = parse_param(kw, Lexicon.ANGLE, EnumConvertType.FLOAT, 0)
Expand Down
8 changes: 4 additions & 4 deletions core/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
shape = parse_param(kw, Lexicon.SHAPE, EnumShapes, EnumShapes.CIRCLE.name)
sides = parse_param(kw, Lexicon.SIDES, EnumConvertType.INT, 3, 3, 100)
angle = parse_param(kw, Lexicon.ANGLE, EnumConvertType.FLOAT, 0)
Expand Down Expand Up @@ -183,7 +183,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
pA = parse_param(kw, Lexicon.PIXEL, EnumConvertType.IMAGE, None)
depth = parse_param(kw, Lexicon.DEPTH, EnumConvertType.IMAGE, None)
divisions = parse_param(kw, Lexicon.TILE, EnumConvertType.INT, 1, 1, 8)
Expand Down Expand Up @@ -225,7 +225,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor]:
pA = parse_param(kw, Lexicon.PIXEL, EnumConvertType.IMAGE, None)
baseline = parse_param(kw, Lexicon.INT, EnumConvertType.FLOAT, 0, 0.1, 1)
focal_length = parse_param(kw, Lexicon.VALUE, EnumConvertType.FLOAT, 500, 0)
Expand Down Expand Up @@ -283,7 +283,7 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, **kw) -> Tuple[torch.Tensor, ...]:
full_text = parse_param(kw, Lexicon.STRING, EnumConvertType.STRING, "jovimetrix")
font_idx = parse_param(kw, Lexicon.FONT, EnumConvertType.STRING, self.FONT_NAMES[0])
autosize = parse_param(kw, Lexicon.AUTOSIZE, EnumConvertType.BOOLEAN, False)
Expand Down
3 changes: 1 addition & 2 deletions core/device_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
if not JOV_DOCKERENV:
from ..sup.stream import window_capture


from ..sup.image.adjust import EnumScaleMode, EnumInterpolation, \
image_scalefit

Expand Down Expand Up @@ -150,7 +149,7 @@ def __init__(self, *arg, **kw) -> None:
self.__empty = (a, e, m,)
self.__last = [(a, e, m,)]

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
def run(self, *arg, **kw) -> Tuple[torch.Tensor, ...]:
wait = parse_param(kw, Lexicon.WAIT, EnumConvertType.BOOLEAN, False)[0]
if wait:
return self.__last
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "jovimetrix"
description = "Integrates Webcam, MIDI, Spout and GLSL shader support. Animation via tick. Parameter manipulation with wave generator. Math operations with Unary and Binary support. Value conversion for all major types (int, string, list, dict, Image, Mask). Shape mask generation, image stacking and channel ops, batch splitting, merging and randomizing, load images and video from anywhere, dynamic bus routing with a single node, export support for GIPHY, save output anywhere! flatten, crop, transform; check colorblindness, make stereogram or stereoscopic images, or liner interpolate values and more."
version = "1.7.9"
version = "1.7.12"
license = { file = "LICENSE" }
readme = "README.md"
authors = [{ name = "Alexander G. Morano", email = "[email protected]" }]
Expand All @@ -27,12 +27,12 @@ dependencies = [
"mido[ports-rtmidi]",
"mss",
"numba",
"numpy>=1.26.4,<2.0.0; python_version < '3.12'",
"numpy>=2.0.0; python_version > '3.11'",
"numpy>=1.26.4,<2.0.0; python_version <= '3.11'",
"numpy>=2.0.0; python_version >= '3.12'",
"opencv-contrib-python",
"Pillow",
"PyOpenGL",
"PyOpenGL-accelerate; python_version < '3.12'",
"PyOpenGL-accelerate",
"pywin32; platform_system==\"Windows\"",
"requests",
"scikit-image",
Expand Down
40 changes: 1 addition & 39 deletions web/nodes/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { app } from "../../../scripts/app.js";
import { ComfyWidgets } from "../../../scripts/widgets.js"
import { apiJovimetrix } from '../util/util_api.js'
import { flashBackgroundColor } from '../util/util_fun.js'
import { nodeFitHeight, TypeSlotEvent, TypeSlot } from '../util/util_node.js'
import { widgetHide, widgetShow } from '../util/util_widget.js'
import { TypeSlotEvent, TypeSlot } from '../util/util_node.js'
import { widgetSizeModeHook } from '../util/util_jov.js'

const _id1 = "QUEUE (JOV) 🗃";
Expand Down Expand Up @@ -60,45 +59,8 @@ app.registerExtension({

const widget_queue = this.widgets.find(w => w.name == 'Q');
const widget_batch = this.widgets.find(w => w.name == 'BATCH');
const widget_value = this.widgets.find(w => w.name == 'VAL');
const widget_hold = this.widgets.find(w => w.name == '✋🏽');
const widget_reset = this.widgets.find(w => w.name == 'RESET');
const widget_stop = this.widgets.find(w => w.name == 'STOP');
const widget_loop = this.widgets.find(w => w.name == '🔄');
/*
widget_batch.callback = () => {
widgetHide(this, widget_value);
widgetHide(this, widget_hold);
widgetHide(this, widget_stop);
widgetHide(this, widget_loop);
widgetHide(this, widget_reset);
if (widget_batch.value == false) {
widgetShow(widget_value);
widgetShow(widget_hold);
if (widget_hold.value == false) {
widgetShow(widget_stop);
widgetShow(widget_loop);
widgetShow(widget_reset);
}
}
nodeFitHeight(this);
}
widget_hold.callback = () => {
if (widget_batch.value == true) {
return;
}
widgetHide(this, widget_stop);
widgetHide(this, widget_loop);
widgetHide(this, widget_reset);
if (widget_hold.value == false) {
widgetShow(widget_stop);
widgetShow(widget_loop);
widgetShow(widget_reset);
}
nodeFitHeight(this);
}
*/

widget_queue.inputEl.addEventListener('input', function () {
const value = widget_queue.value.split('\n');
Expand Down
2 changes: 1 addition & 1 deletion web/nodes/stream_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ app.registerExtension({
}
nodeFitHeight(self);
}
setTimeout(() => { source.callback(); }, 10);
setTimeout(source.callback(), 10);
return me;
}
}
Expand Down
14 changes: 0 additions & 14 deletions web/util/util_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,6 @@ export function widgetHide(node, widget, suffix = '') {
widget.origComputeSize = widget.computeSize;
widget.computeSize = () => [0, -4];

widget.origSerializeValue = widget.serializeValue;
widget.serializeValue = async () => {
// Prevent serializing the widget if we have no input linked
if (!node.inputs) {
return undefined;
}

let node_input = node.inputs.find((i) => i.widget?.name == widget.name);
if (!node_input || !node_input.link) {
return undefined;
}
return widget.origSerializeValue ? widget.origSerializeValue() : widget.value;
}

// Hide any linked widgets, e.g. seed+seedControl
if (widget.linkedWidgets) {
for (const w of widget.linkedWidgets) {
Expand Down

0 comments on commit b5e7668

Please sign in to comment.