Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show_examples_timetaken #278

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/workflow-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -102,6 +106,29 @@ 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'
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 Linux: \n${timeTaken}`;
await github.issues.createComment({
issue_number: pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})



- name: remove the time_taken.txt file
if: matrix.os == 'ubuntu-latest'
run: |
rm ComfyUI/custom_nodes/BizyAir/time_taken.txt

- name: Run ComfyUI on Windows
if: matrix.os == 'windows-latest'
run: |
Expand All @@ -115,3 +142,24 @@ 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 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
})

- name: remove the time_taken.txt file
if: matrix.os == 'windows-latest'
run: |
rm ComfyUI/custom_nodes/BizyAir/time_taken.txt
10 changes: 10 additions & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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)

Expand Down Expand Up @@ -225,8 +231,12 @@ 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"| title and file | timetaken |\n|:--:|:--:|\n")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里建议根据耗时排序一下

for title, file in all_examples_json.items():
print(f"Running example: {title} - {file}")
with open(os.path.join(base_path, "..", "time_taken.txt"), "a") as f:
f.write(f"| {title} - {file} |")
launch_prompt(
driver,
COMFY_HOST,
Expand Down
Loading