Skip to content

Commit

Permalink
version up
Browse files Browse the repository at this point in the history
  • Loading branch information
Amorano committed Aug 18, 2024
1 parent 83bf228 commit a2d1df7
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 434 deletions.
422 changes: 23 additions & 399 deletions README.md

Large diffs are not rendered by default.

68 changes: 44 additions & 24 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@
from string import Template
from typing import Any, Dict, List, Literal, Tuple

try:
from server import PromptServer
from aiohttp import web
except:
pass
from aiohttp import web
from server import PromptServer
from nodes import load_custom_node

from loguru import logger

Expand Down Expand Up @@ -429,34 +427,43 @@ def INPUT_TYPES(cls) -> dict:
})
return Lexicon._parse(d, cls)

# original sourced from: https://github.com/rgthree/rgthree-comfy/blob/dd534e5384be8cf0c0fa35865afe2126ba75ac55/py/utils.py
class FlexibleOptionalInputType(dict):
"""A special class to make flexible nodes that pass data to our python handlers.
Enables both flexible/dynamic input types (like for Any Switch) or a dynamic number of inputs
(like for Any Switch, Context Switch, Context Merge, Power Lora Loader, etc).
class DynamicInputType(dict):
"""A special class to make flexible nodes that pass data to our python handlers.
Note, for ComfyUI, all that's needed is the `__contains__` override below, which tells ComfyUI
that our node will handle the input, regardless of what it is.
Enables both flexible/dynamic input types or a dynamic number of inputs.
However, with https://github.com/comfyanonymous/ComfyUI/pull/2666 a large change would occur
requiring more details on the input itself. There, we need to return a list/tuple where the first
item is the type. This can be a real type, or use the AnyType for additional flexibility.
"""
def __init__(self, type) -> None:
self.type = type
original sourced from rgthree:
https://github.com/rgthree/rgthree-comfy/blob/dd534e5384be8cf0c0fa35865afe2126ba75ac55/py/utils.py
"""
def __init__(self, type: Any) -> None:
self.type = type

def __getitem__(self, key) -> Tuple[Any]:
return (self.type, )
def __getitem__(self, key: Any) -> Tuple[Any]:
return (self.type, )

def __contains__(self, key) -> Literal[True]:
return True
def __contains__(self, key: Any) -> Literal[True]:
return True

# wildcard trick is 100% stolen from pythongossss's
class AnyType(str):
"""AnyType input wildcard trick taken from pythongossss's:
https://github.com/pythongosssss/ComfyUI-Custom-Scripts
"""
def __ne__(self, __value: object) -> bool:
return False

class DynamicOutputType(tuple):
"""A special class that will return additional "AnyType" strings beyond defined values.
original sourced from Trung0246:
https://github.com/Trung0246/ComfyUI-0246/blob/fb16466a82553aebdc4d851a483847c2dc0cb953/utils.py#L51
"""
def __getitem__(self, index) -> Any:
if index > len(self) - 1:
return AnyType("*")
return super().__getitem__(index)

JOV_TYPE_ANY = AnyType("*")

# want to make explicit entries; comfy only looks for single type
Expand Down Expand Up @@ -762,6 +769,19 @@ def comfy_message(ident:str, route:str, data:dict) -> None:

try:

@PromptServer.instance.routes.get("/jovimetrix/reload")
async def reload(request) -> web.Response:

data = {k: dir(v) for k, v in sys.modules.copy().items()}
with open('a.json', 'w') as fhandle:
json.dump(data, fhandle, indent=4)

module = importlib.import_module("Jovimetrix")
# ensure the module is reloaded
importlib.reload(module)
load_custom_node('custom_nodes/Jovimetrix')
return web.Response(text='RELOADED JOVIMETRIX')

@PromptServer.instance.routes.post("/jovimetrix/message")
async def jovimetrix_message(request) -> Any:
json_data = await request.json()
Expand Down
8 changes: 4 additions & 4 deletions core/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from comfy.utils import ProgressBar
from folder_paths import get_output_directory

from Jovimetrix import deep_merge, comfy_message, parse_reset, \
from Jovimetrix import DynamicInputType, deep_merge, comfy_message, parse_reset, \
Lexicon, JOVBaseNode, JOV_TYPE_ANY, ROOT, JOV_TYPE_IMAGE

from Jovimetrix.sup.util import parse_dynamic, path_next, \
Expand Down Expand Up @@ -687,14 +687,14 @@ class RouteNode(JOVBaseNode):
def INPUT_TYPES(cls) -> dict:
d = super().INPUT_TYPES()
d = deep_merge(d, {
"optional": DynamicInputType(JOV_TYPE_ANY),
"""
"optional": {
Lexicon.ROUTE: ("BUS", {"default": None, "tooltips":"Pass through another route node to pre-populate the outputs."}),
},
"""
"outputs": {
0: (Lexicon.ROUTE, {"tooltips":"Pass through for Route node"})
},
"hidden": {

}
})
return Lexicon._parse(d, cls)
Expand Down
2 changes: 1 addition & 1 deletion 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.2.13"
version = "1.2.14"
license = { file = "LICENSE" }
dependencies = [
"aenum>=3.1.15,<4",
Expand Down
2 changes: 1 addition & 1 deletion web/core/core_help.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ app.registerExtension({

const widget_tooltip = (this.widgets || [])
.find(widget => widget.type === 'JTOOLTIP');
console.info(widget_tooltip)
// console.info(widget_tooltip)
if (widget_tooltip) {
const tips = widget_tooltip.options.default || {};
const url = tips['_'];
Expand Down
2 changes: 1 addition & 1 deletion web/nodes/glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ app.registerExtension({
widget_param.serializeValue = async () =>
self.inputs.reduce((result, widget) =>
({ ...result, [widget.name]: widget.value }), {});
widgetHide(this, widget_param);
widgetHide(this, widget_param, '-jov');

// parse this for vars... check existing vars and "types" and keep
// or ignore as is the case -- I should stick to a common set of
Expand Down
11 changes: 7 additions & 4 deletions web/nodes/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import { app } from "../../../scripts/app.js"
import {
TypeSlot, TypeSlotEvent, nodeFitHeight,
nodeVirtualLinkRoot, nodeVirtualLinkChild,
nodeInputsClear, nodeOutputsClear
nodeVirtualLinkRoot, nodeInputsClear, nodeOutputsClear
} from '../util/util_node.js'
import { widgetHide } from '../util/util_widget.js';

const _id = "ROUTE (JOV) 🚌";
const _prefix = '🔮';
Expand All @@ -33,9 +33,12 @@ app.registerExtension({

let widget_param = this.inputs?.find(w => w.name === 'PARAM');
if (widget_param === undefined) {
widget_param = this.addWidget('PARAM', 'JDICT');
widget_param.hidden = true;
widget_param = this.addInput('PARAM', 'JDICT');
}
widget_param.serializeValue = async () =>
self.inputs.reduce((result, widget) =>
({ ...result, [widget.name]: widget.value }), {});
widgetHide(this, widget_param, '-jov');

const self = this;
widget_param.serializeValue = async () =>
Expand Down

0 comments on commit a2d1df7

Please sign in to comment.