From c84a16ff814597c68a33a999e368b72d0cbf3229 Mon Sep 17 00:00:00 2001 From: zhujintao <2030442731@qq.com> Date: Mon, 16 Dec 2024 14:36:24 +0800 Subject: [PATCH 1/7] show_examples_timetaken --- .github/workflows/workflow-ci.yml | 37 +++++++++++++++++++++++++++++++ tests/test_examples.py | 12 ++++++++++ 2 files changed, 49 insertions(+) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 78a75ad0..38574703 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -102,6 +102,24 @@ jobs: BIZYAIR_API_KEY: ${{ secrets.BIZYAIR_KEY }} PYTHONPATH: ${{ github.workspace }}/ComfyUI + - name: Add PR review comment about the time taken to run the examples on Windows + if: matrix.os == 'windows-latest' + uses: actions/github-script@v4 + with: + script: | + const { pull_request } = context.payload; + const fs = require('fs'); + const timeTaken = fs.readFileSync('ComfyUI/custom_nodes/BizyAir/time_taken.txt', 'utf8'); + const comment = `The time taken by running the examples on Windows: \n${timeTaken}`; + await github.issues.createComment({ + issue_number: pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }) + run: + rm ComfyUI/custom_nodes/BizyAir/time_taken.txt + - name: Run ComfyUI on Windows if: matrix.os == 'windows-latest' run: | @@ -115,3 +133,22 @@ jobs: BIZYAIR_KEY: ${{ secrets.BIZYAIR_KEY }} BIZYAIR_API_KEY: ${{ secrets.BIZYAIR_KEY }} PYTHONPATH: ${{ github.workspace }}/ComfyUI + + - name: Add PR review comment about the time taken to run the examples on Linux + if: matrix.os == 'ubuntu-latest' + uses: actions/github-script@v4 + with: + script: | + const { pull_request } = context.payload; + # 从 time_taken.txt 文件中读取 comment + const fs = require('fs'); + const timeTaken = fs.readFileSync('ComfyUI/custom_nodes/BizyAir/time_taken.txt', 'utf8'); + const comment = `The time taken by running the examples on Linux: \n${timeTaken}`; + await github.issues.createComment({ + issue_number: pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }) + run: + rm ComfyUI/custom_nodes/BizyAir/time_taken.txt diff --git a/tests/test_examples.py b/tests/test_examples.py index 8edb3177..465daa02 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -149,8 +149,12 @@ def launch_prompt(driver, comfy_host, comfy_port, workflow, timeout): print(f" check if error occurs...") check_error_occurs(driver) print(f" no error occurs when executing workflow") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"{duration:.1f} s |\n") except TimeoutException: print("Time out") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"timeout |\n") driver.quit() driver = init_driver() driver.get(f"http://{comfy_host}:{comfy_port}") @@ -159,6 +163,8 @@ def launch_prompt(driver, comfy_host, comfy_port, workflow, timeout): print(type(e)) print(e) print(" exit with error: 1") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"error |\n") driver.quit() exit(1) @@ -225,8 +231,13 @@ def filter_examples_json(all_examples_json: dict, bypass_titles: list): print("========Running all examples========") print("\n".join(f"{key} -- {value}" for key, value in all_examples_json.items())) print("====================================") + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"| json文件 | 耗时 |\n|:--:|:--:|\n") for title, file in all_examples_json.items(): print(f"Running example: {title} - {file}") + # 将 title-file 续写入到 base_path/../time_taken.txt + with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: + f.write(f"| {title} - {file} |") launch_prompt( driver, COMFY_HOST, @@ -234,5 +245,6 @@ def filter_examples_json(all_examples_json: dict, bypass_titles: list): os.path.join(base_path, "..", "examples", file), timeout=100, ) + break driver.quit() From 8f9100b3219285e3254ed4564f0e574f60278d9b Mon Sep 17 00:00:00 2001 From: zhujintao <2030442731@qq.com> Date: Mon, 16 Dec 2024 14:41:06 +0800 Subject: [PATCH 2/7] depart use and run --- .github/workflows/workflow-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 38574703..85d35973 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -117,7 +117,9 @@ jobs: repo: context.repo.repo, body: comment }) - run: + + - name: remove the time_taken.txt file + run: | rm ComfyUI/custom_nodes/BizyAir/time_taken.txt - name: Run ComfyUI on Windows @@ -150,5 +152,7 @@ jobs: repo: context.repo.repo, body: comment }) - run: + + - name: remove the time_taken.txt file + run: | rm ComfyUI/custom_nodes/BizyAir/time_taken.txt From 7a18a5d174fd20ad6577a442cf5caa79810ca5b2 Mon Sep 17 00:00:00 2001 From: zhujintao <2030442731@qq.com> Date: Mon, 16 Dec 2024 14:46:33 +0800 Subject: [PATCH 3/7] exchange the order --- .github/workflows/workflow-ci.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 85d35973..45ad67d0 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -102,15 +102,16 @@ jobs: BIZYAIR_API_KEY: ${{ secrets.BIZYAIR_KEY }} PYTHONPATH: ${{ github.workspace }}/ComfyUI - - name: Add PR review comment about the time taken to run the examples on Windows - if: matrix.os == 'windows-latest' + - name: Add PR review comment about the time taken to run the examples on Linux + if: matrix.os == 'ubuntu-latest' uses: actions/github-script@v4 with: script: | const { pull_request } = context.payload; + # 从 time_taken.txt 文件中读取 comment const fs = require('fs'); const timeTaken = fs.readFileSync('ComfyUI/custom_nodes/BizyAir/time_taken.txt', 'utf8'); - const comment = `The time taken by running the examples on Windows: \n${timeTaken}`; + const comment = `The time taken by running the examples on Linux: \n${timeTaken}`; await github.issues.createComment({ issue_number: pull_request.number, owner: context.repo.owner, @@ -118,6 +119,8 @@ jobs: body: comment }) + + - name: remove the time_taken.txt file run: | rm ComfyUI/custom_nodes/BizyAir/time_taken.txt @@ -136,16 +139,15 @@ jobs: BIZYAIR_API_KEY: ${{ secrets.BIZYAIR_KEY }} PYTHONPATH: ${{ github.workspace }}/ComfyUI - - name: Add PR review comment about the time taken to run the examples on Linux - if: matrix.os == 'ubuntu-latest' + - name: Add PR review comment about the time taken to run the examples on Windows + if: matrix.os == 'windows-latest' uses: actions/github-script@v4 with: script: | const { pull_request } = context.payload; - # 从 time_taken.txt 文件中读取 comment const fs = require('fs'); const timeTaken = fs.readFileSync('ComfyUI/custom_nodes/BizyAir/time_taken.txt', 'utf8'); - const comment = `The time taken by running the examples on Linux: \n${timeTaken}`; + const comment = `The time taken by running the examples on Windows: \n${timeTaken}`; await github.issues.createComment({ issue_number: pull_request.number, owner: context.repo.owner, From 3ed2ed1ce0ffe70636ed602297db6d73aad27e87 Mon Sep 17 00:00:00 2001 From: zhujintao <2030442731@qq.com> Date: Mon, 16 Dec 2024 14:52:10 +0800 Subject: [PATCH 4/7] debug --- .github/workflows/workflow-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index 45ad67d0..b48693d9 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -108,7 +108,6 @@ jobs: with: script: | const { pull_request } = context.payload; - # 从 time_taken.txt 文件中读取 comment const fs = require('fs'); const timeTaken = fs.readFileSync('ComfyUI/custom_nodes/BizyAir/time_taken.txt', 'utf8'); const comment = `The time taken by running the examples on Linux: \n${timeTaken}`; From 3f31b5c36cd93ba9f6a031b5513f4e4e448f3225 Mon Sep 17 00:00:00 2001 From: zhujintao <2030442731@qq.com> Date: Mon, 16 Dec 2024 14:56:57 +0800 Subject: [PATCH 5/7] permissions --- .github/workflows/workflow-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index b48693d9..f3fab67b 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -5,6 +5,10 @@ on: branches: - master +permissions: + contents: read + pull-requests: write + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true From 4ba27f5ee2e8bd39f6c1461b086e9effcc6915a0 Mon Sep 17 00:00:00 2001 From: zhujintao <2030442731@qq.com> Date: Mon, 16 Dec 2024 15:02:37 +0800 Subject: [PATCH 6/7] final --- .github/workflows/workflow-ci.yml | 2 ++ tests/test_examples.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/workflow-ci.yml b/.github/workflows/workflow-ci.yml index f3fab67b..f0049c8e 100644 --- a/.github/workflows/workflow-ci.yml +++ b/.github/workflows/workflow-ci.yml @@ -125,6 +125,7 @@ jobs: - name: remove the time_taken.txt file + if: matrix.os == 'ubuntu-latest' run: | rm ComfyUI/custom_nodes/BizyAir/time_taken.txt @@ -159,5 +160,6 @@ jobs: }) - name: remove the time_taken.txt file + if: matrix.os == 'windows-latest' run: | rm ComfyUI/custom_nodes/BizyAir/time_taken.txt diff --git a/tests/test_examples.py b/tests/test_examples.py index 465daa02..5e8b6c29 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -245,6 +245,5 @@ def filter_examples_json(all_examples_json: dict, bypass_titles: list): os.path.join(base_path, "..", "examples", file), timeout=100, ) - break driver.quit() From 707fb34bf6f1ef86d42a1365d5a7fa21020e5d64 Mon Sep 17 00:00:00 2001 From: zhujintao <2030442731@qq.com> Date: Mon, 16 Dec 2024 15:11:12 +0800 Subject: [PATCH 7/7] change the language --- tests/test_examples.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 5e8b6c29..0bbd92d5 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -232,10 +232,9 @@ def filter_examples_json(all_examples_json: dict, bypass_titles: list): print("\n".join(f"{key} -- {value}" for key, value in all_examples_json.items())) print("====================================") with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: - f.write(f"| json文件 | 耗时 |\n|:--:|:--:|\n") + f.write(f"| title and file | timetaken |\n|:--:|:--:|\n") for title, file in all_examples_json.items(): print(f"Running example: {title} - {file}") - # 将 title-file 续写入到 base_path/../time_taken.txt with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f: f.write(f"| {title} - {file} |") launch_prompt(