diff --git a/.github/workflows/python-format.yml b/.github/workflows/python-format.yml new file mode 100644 index 0000000..4f82905 --- /dev/null +++ b/.github/workflows/python-format.yml @@ -0,0 +1,44 @@ +name: Check Black Formatting + +on: + pull_request: + types: [opened, synchronize, reopened] + +permissions: + contents: read + pull-requests: write + +jobs: + black-formatting: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install black==24.4.2 + + - name: Run Black formatting check + run: python3 -m black --check . + + - name: Add PR review comment if formatting is incorrect + if: failure() + uses: actions/github-script@v4 + with: + script: | + const { pull_request } = context.payload; + const comment = "Your code does not meet the Black formatting standards.\nPlease run `python3 -m pip install black==24.4.2 && python3 -m black .` to format your code."; + await github.issues.createComment({ + issue_number: pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); diff --git a/auth.py b/auth.py index 6756d3a..dccddb1 100644 --- a/auth.py +++ b/auth.py @@ -140,7 +140,11 @@ async def get_api_key(request): class SetAPIKey: @classmethod def INPUT_TYPES(s): - return {"required": {"API_KEY": ("STRING", {"default": "YOUR_API_KEY"}),}} + return { + "required": { + "API_KEY": ("STRING", {"default": "YOUR_API_KEY"}), + } + } RETURN_TYPES = () FUNCTION = "set_api_key" diff --git a/image_utils.py b/image_utils.py index 5bc753e..7bc9b04 100644 --- a/image_utils.py +++ b/image_utils.py @@ -84,9 +84,7 @@ def decode_comfy_image(img_data: Union[List, str], image_format="png") -> torch. out = decode_base64_to_np(img_data, format=image_format) out = np.array(out).astype(np.float32) / 255.0 - output = torch.from_numpy(out)[ - None, - ] + output = torch.from_numpy(out)[None,] return output diff --git a/kolors.py b/kolors.py index d5cb0bc..63b80d5 100644 --- a/kolors.py +++ b/kolors.py @@ -25,8 +25,20 @@ class BizyAirKolorsTextEncode: def INPUT_TYPES(s): return { "required": { - "prompt": ("STRING", {"multiline": True, "default": "",}), - "negative_prompt": ("STRING", {"multiline": True, "default": "",}), + "prompt": ( + "STRING", + { + "multiline": True, + "default": "", + }, + ), + "negative_prompt": ( + "STRING", + { + "multiline": True, + "default": "", + }, + ), "num_images_per_prompt": ( "INT", {"default": 1, "min": 1, "max": 4, "step": 1}, @@ -73,7 +85,11 @@ class BizyAirKolorsVAEEncode: @classmethod def INPUT_TYPES(s): - return {"required": {"pixels": ("IMAGE",),}} + return { + "required": { + "pixels": ("IMAGE",), + } + } RETURN_TYPES = ("LATENT",) FUNCTION = "encode" @@ -114,7 +130,11 @@ class BizyAirKolorsVAEDecode: @classmethod def INPUT_TYPES(s): - return {"required": {"samples": ("LATENT",),}} + return { + "required": { + "samples": ("LATENT",), + } + } RETURN_TYPES = ("IMAGE",) FUNCTION = "decode" diff --git a/llm.py b/llm.py index ef42654..d9df2c8 100644 --- a/llm.py +++ b/llm.py @@ -47,7 +47,11 @@ class SiliconCloudLLMAPI: ), "user_prompt": ( "STRING", - {"default": "小猫,梵高风格", "multiline": True, "dynamicPrompts": True,}, + { + "default": "小猫,梵高风格", + "multiline": True, + "dynamicPrompts": True, + }, ), "max_tokens": ("INT", {"default": 512, "min": 100, "max": 1e5}), "temperature": ( @@ -100,7 +104,10 @@ class BizyAirImageCaption: CATEGORY = "☁️BizyAir/AI Assistants" def detailed_caption( - self, image, num_beams, max_new_tokens, + self, + image, + num_beams, + max_new_tokens, ): API_KEY = get_api_key() diff --git a/nodes_controlnet_union_sdxl.py b/nodes_controlnet_union_sdxl.py index 03c4841..512f394 100644 --- a/nodes_controlnet_union_sdxl.py +++ b/nodes_controlnet_union_sdxl.py @@ -2,6 +2,7 @@ huggingface: https://huggingface.co/xinsir/controlnet-union-sdxl-1.0 github: https://github.com/xinsir6/ControlNetPlus/tree/main """ + import json import os import numpy as np @@ -44,7 +45,11 @@ class StableDiffusionXLControlNetUnionPipeline: "segment_image": ("IMAGE",), "prompt": ( "STRING", - {"default": "a car", "multiline": True, "dynamicPrompts": True,}, + { + "default": "a car", + "multiline": True, + "dynamicPrompts": True, + }, ), "negative_prompt": ( "STRING", @@ -56,11 +61,21 @@ class StableDiffusionXLControlNetUnionPipeline: ), "control_guidance_start": ( "FLOAT", - {"default": 0, "min": 0.0, "max": 1, "step": 0.01,}, + { + "default": 0, + "min": 0.0, + "max": 1, + "step": 0.01, + }, ), "control_guidance_end": ( "FLOAT", - {"default": 1.0, "min": 0.0, "max": 1, "step": 0.01,}, + { + "default": 1.0, + "min": 0.0, + "max": 1, + "step": 0.01, + }, ), }, } @@ -127,7 +142,9 @@ class StableDiffusionXLControlNetUnionPipeline: payload.update(**kwargs) response = requests.post( - self.API_URL, json=payload, headers=self.get_headers(), + self.API_URL, + json=payload, + headers=self.get_headers(), ) result = response.json() diff --git a/supernode.py b/supernode.py index c06c39d..25553a1 100644 --- a/supernode.py +++ b/supernode.py @@ -20,7 +20,12 @@ class SuperResolution: @classmethod def INPUT_TYPES(s): - return {"required": {"image": ("IMAGE",), "scale": (["2x", "4x"],),}} + return { + "required": { + "image": ("IMAGE",), + "scale": (["2x", "4x"],), + } + } RETURN_TYPES = ("IMAGE",) FUNCTION = "super_resolution" @@ -66,7 +71,11 @@ class RemoveBackground: @classmethod def INPUT_TYPES(s): - return {"required": {"image": ("IMAGE",),}} + return { + "required": { + "image": ("IMAGE",), + } + } RETURN_TYPES = ("IMAGE", "MASK") FUNCTION = "remove_background"