Skip to content

Commit

Permalink
merge: 🔀 pull request #32 from melMass/dev/next
Browse files Browse the repository at this point in the history
  • Loading branch information
melMass authored Jul 24, 2023
2 parents bbdac97 + cf86552 commit 8695cd3
Show file tree
Hide file tree
Showing 13 changed files with 4,196 additions and 1,610 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ jobs:
with:
submodules: "recursive"
path: ${{ env.repo_name }}

# - name: 📝 Prepare file with paths to remove
# run: |
# find ${{ env.repo_name }} -type f -size +10M > .release_ignore
# find ${{ env.repo_name }} -type d -empty >> .release_ignore
# shell: bash

- name: 🗑️ Remove files and directories listed in .release_ignore
shell: bash
run: |
if [ -f "${{ env.repo_name }}/.release_ignore" ]; then
while IFS= read -r entry; do
if [ -f "${{ env.repo_name }}/$entry" ]; then
rm "${{ env.repo_name }}/$entry"
elif [ -d "${{ env.repo_name }}/$entry" ]; then
rm -r "${{ env.repo_name }}/$entry"
fi
done < "${{ env.repo_name }}/.release_ignore"
else
echo "No .release_ignore file found. Skipping removal of files and directories."
fi
- name: 📦 Building custom comfy nodes
shell: bash
run: |
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false
}
3 changes: 3 additions & 0 deletions .release_ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extern/frame_interpolation/moment.gif
extern/frame_interpolation/photos
extern/GFPGAN/inputs
43 changes: 38 additions & 5 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
###
# File: __init__.py
# Project: comfy_mtb
# Author: Mel Massadian
# Copyright (c) 2023 Mel Massadian
#
###
import os

os.environ["TF_FORCE_GPU_ALLOW_GROWTH"] = "true"

import traceback
from .log import log, blue_text, cyan_text, get_summary, get_label
from .utils import here
from .utils import comfy_dir
import importlib
import os
import ast
Expand All @@ -14,7 +24,7 @@
NODE_DISPLAY_NAME_MAPPINGS = {}
NODE_CLASS_MAPPINGS_DEBUG = {}

__version__ = "0.1.0"
__version__ = "0.1.1"


def extract_nodes_from_source(filename):
Expand Down Expand Up @@ -89,7 +99,7 @@ def load_nodes():


# - REGISTER WEB EXTENSIONS
web_extensions_root = utils.comfy_dir / "web" / "extensions"
web_extensions_root = comfy_dir / "web" / "extensions"
web_mtb = web_extensions_root / "mtb"

if web_mtb.exists():
Expand Down Expand Up @@ -158,12 +168,11 @@ def load_nodes():

# - ENDPOINT
from server import PromptServer
from .log import mklog, log
from .log import log
from aiohttp import web
from importlib import reload
import logging

endlog = mklog("mtb endpoint")
from .endpoint import endlog


@PromptServer.instance.routes.get("/mtb/status")
Expand Down Expand Up @@ -260,6 +269,30 @@ async def get_debug(request):
return web.json_response({"enabled": enabled})


@PromptServer.instance.routes.get("/mtb/actions")
async def no_route(request):
from . import endpoint

if "text/html" in request.headers.get("Accept", ""):
html_response = f"""
<h1>Actions has no get for now...</h1>
"""
return web.Response(
text=endpoint.render_base_template("Actions", html_response),
content_type="text/html",
)
return web.json_response({"message": "actions has no get for now"})


@PromptServer.instance.routes.post("/mtb/actions")
async def do_action(request):
from . import endpoint

reload(endpoint)

return await endpoint.do_action(request)


# - WAS Dictionary
MANIFEST = {
"name": "MTB Nodes", # The title that will be displayed on Node Class menu,. and Node Class view
Expand Down
52 changes: 52 additions & 0 deletions endpoint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
from .utils import here
from aiohttp import web
from .log import mklog
import os

endlog = mklog("mtb endpoint")

#- ACTIONS

def ACTIONS_getStyles(style_name=None):
from .nodes.conditions import StylesLoader

styles = StylesLoader.options
match_list = ["name"]
if styles:
filtered_styles = {
key: value
for key, value in styles.items()
if not key.startswith("__") and key not in match_list
}
if style_name:
if style_name in filtered_styles:
return filtered_styles[style_name]
else:
return {"error": "Style not found"}
return filtered_styles
return {"error": "No styles found"}


async def do_action(request) -> web.Response:
endlog.debug("Init action request")
request_data = await request.json()
name = request_data.get("name")
args = request_data.get("args")

endlog.debug(f"Received action request: {name} {args}")

method_name = "ACTIONS_" + name
method = globals().get(method_name)

if callable(method):
result = method(args) if args else method()
endlog.debug(f"Action result: {result}")
return web.json_response({"result": result})

available_methods = [
attr[len("ACTIONS_") :] for attr in globals() if attr.startswith("ACTIONS_")
]

return web.json_response(
{"error": "Invalid method name.", "available_methods": available_methods}
)


# - HTML UTILS
def render_table(table_dict, sort=True, title=None):
table_rows = ""
table_dict = sorted(
Expand Down
Loading

0 comments on commit 8695cd3

Please sign in to comment.