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

Add testing for ComfyUI examples #95

Merged
merged 5 commits into from
Jul 7, 2024
Merged

Add testing for ComfyUI examples #95

merged 5 commits into from
Jul 7, 2024

Conversation

pythongosssss
Copy link
Member

Adds simple test for examples from https://github.com/comfyanonymous/ComfyUI_examples, just checks that loading the workflow and converting to prompt generates the same output as in the examples.

  • Moved png & flac metadata extraction to own files so they can be imported without API etc being set up
  • Add script npm run test:generate:examples - This requires the ComfyUI examples repo to be cloned
    • This extracts metadata from the examples and stores them in workflow/examples, noting any changes/issues
    • I couldn't decide between storing them in this repo vs having an action to extract each time was better, however thought that having hard copies would be useful for spotting differences in future. Happy to reconsider.
  • Add chalk as dev dep for color output, this was already included via other packages (e.g. jest)
  • Test currently provide a few simple "fixes" where new inputs have been added since their creation (these were backwards compatible)
  • Tests currently skip examples with group nodes as these don't generate the same ID as saved in the workflow so the examples will need regenerating

@pythongosssss pythongosssss requested a review from huchenlei July 6, 2024 13:53
@huchenlei huchenlei added the enhancement New feature or request label Jul 6, 2024
Copy link
Member

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

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

Adds simple test for examples from https://github.com/comfyanonymous/ComfyUI_examples, just checks that loading the workflow and converting to prompt generates the same output as in the examples.

  • Moved png & flac metadata extraction to own files so they can be imported without API etc being set up

LGTM

  • Add script npm run test:generate:examples - This requires the ComfyUI examples repo to be cloned

    • This extracts metadata from the examples and stores them in workflow/examples, noting any changes/issues
    • I couldn't decide between storing them in this repo vs having an action to extract each time was better, however thought that having hard copies would be useful for spotting differences in future. Happy to reconsider.

I think we should do similar thing as we did for test:generate, i.e. ignore the examples. If we want to verify things are not changed, we should add the git ref when checking out https://github.com/comfyanonymous/ComfyUI_examples. So things will only break when we update the ref.

  • Add chalk as dev dep for color output, this was already included via other packages (e.g. jest)

LGTM

  • Test currently provide a few simple "fixes" where new inputs have been added since their creation (these were backwards compatible)

Can you move the legacy prompt support to main app's code?

  • Tests currently skip examples with group nodes as these don't generate the same ID as saved in the workflow so the examples will need regenerating

LGTM

Some potential TODOs:

  • Add the test prep command to Github action workflow
  • Update README about the extra test prep


const dirname = path.dirname(fileURLToPath(import.meta.url));
const repoPath =
process.env.EXAMPLE_REPO_PATH || path.resolve(dirname, "ComfyUI_examples");
Copy link
Member

Choose a reason for hiding this comment

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

We should add EXAMPLE_REPO_PATH to .env_example and init dotenv here.

import dotenv from "dotenv";
dotenv.config();

@pythongosssss
Copy link
Member Author

pythongosssss commented Jul 7, 2024

Can you move the legacy prompt support to main app's code?

The main app (litegraph) adds these values when generating using old example workflows (the problem is that when doing the comparison they dont exist in the example, but will in the test output) so adding the defaults at the point of comparison is the simplest approach.

Adding/changing inputs isnt particularly common, and does need to be done carefully so in situations where it does happen, I think the tests failing and requiring double checking & updating to add the new default is probably fine?

@pythongosssss pythongosssss marked this pull request as ready for review July 7, 2024 11:32
@huchenlei huchenlei merged commit 32d81c1 into main Jul 7, 2024
3 checks passed
@huchenlei huchenlei deleted the test-comfyui-examples branch July 7, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants