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

feat/restore-snapshot #30

Merged
merged 32 commits into from
Nov 18, 2024
Merged

Conversation

kklemon
Copy link
Contributor

@kklemon kklemon commented Apr 1, 2024

Motivation

Many users and workflows rely on custom nodes and extensions which correspondingly should also be available in a RunPod worker.

ComfyUI Manager, perhaps the most popular ComfyUI management exension, provides a convenient feature to export a snapshot of the ComfyUI instance with all installed extensions.

This PR implements optional restoring of a snapshot if provided as snapshot.json in the root directory. If such a file is found, ComfyUI Manager will be installed and restoring of the snapshot will be triggered by starting ComfyUI with the --cpu --quick-test-for-ci flags within the Docker image build process.

Issues closed

#6 #22 #18 #9 (partially)

Todo

  • Implement tests after this initial proposal is approved.

@triplecookedchips
Copy link

@kklemon Hi - is it possible to provide a little more guidance here? I added a snapshot.json in the root directory, but nothing changed when I built the image in Docker. Thank you

@kklemon
Copy link
Contributor Author

kklemon commented May 21, 2024

Adding a snapshot.json in the root directory should be sufficient. Also, make sure that you are building the image from scratch. Apart from these suggestions, I would need to take a look at the build logs to provide more help.

Edit: Since the Dockerfile uses glob-based file copying, you will need a relatively new Docker installation. I couldn't figure out the exact version, but it should work from Docker version 20 upwards.

@triplecookedchips
Copy link

Thanks @kklemon - I didn't build the image from scratch, so will try again with your advice

@TimPietrusky
Copy link
Member

@kklemon thanks for adding this, it sounds really nice. We will have to test this, as this is a feature we haven't used yet. But it sounds like this would solve a lot of problems regarding custom nodes and backing them into the actual Docker image.

Copy link
Member

@TimPietrusky TimPietrusky left a comment

Choose a reason for hiding this comment

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

@kklemon I have two questions, please take a look!

@@ -39,15 +41,16 @@ RUN if [ -z "$SKIP_DEFAULT_MODELS" ]; then wget -O models/vae/sdxl_vae.safetenso
RUN if [ -z "$SKIP_DEFAULT_MODELS" ]; then wget -O models/vae/sdxl-vae-fp16-fix.safetensors https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors; fi
RUN if [ -z "$SKIP_DEFAULT_MODELS" ]; then wget -O models/loras/xl_more_art-full_v1.safetensors https://civitai.com/api/download/models/152309; fi

# Support for the network volume
ADD src/extra_model_paths.yaml ./
Copy link
Member

Choose a reason for hiding this comment

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

Why is this removed? As this is also usable for adding models into ComfyUI via the network volume.

Dockerfile Outdated
RUN chmod +x /start.sh /restore_snapshot.sh

# Optionally copy snapshot file
ADD snapshot.jso[n] /
Copy link
Member

Choose a reason for hiding this comment

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

Why would we have jso[n] here when we always expect a json-file?

@TimPietrusky TimPietrusky changed the title Implement optional restoring of ComfyUI snapshots feat: optional restoring of ComfyUI snapshots to bake custom nodes into the Docker Image May 29, 2024
@TimPietrusky TimPietrusky deleted the branch blib-la:main June 4, 2024 09:21
@TimPietrusky TimPietrusky reopened this Jun 4, 2024
@TimPietrusky TimPietrusky changed the base branch from dev to main June 4, 2024 09:23
@TimPietrusky
Copy link
Member

@kklemon I updated the base branch as we want to move away from having the dev branch.

@TimPietrusky
Copy link
Member

@kklemon ping 🙏

@kklemon
Copy link
Contributor Author

kklemon commented Oct 27, 2024

@TimPietrusky I've completely forgotten about this PR. I will check whether it's still relevant, update it if that's the case or close it otherwise.

@kklemon
Copy link
Contributor Author

kklemon commented Oct 27, 2024

@martintomov I haven't been active in the ComfyUI community for a while and don't know what the current de facto standard for managing extensions is, but when I created this PR, I assumed that it's ComfyUI Manager.

If you want to incorporate custom nodes into a RunPod deployment, my recommendation is to install your nodes or extensions via ComfyUI Manager and export a snapshot of your setup as JSON file. You can then just put the snapshot.json in the root directory of this repository, which will be recognized by the build script when building the Docker image. The extensions will be installed during the build process.


# Trigger restoring of the snapshot by performing a quick test run
# Note: We need to use `yes` as some custom nodes may try to install dependencies with pip
/usr/bin/yes | python main.py --cpu --quick-test-for-ci
Copy link

Choose a reason for hiding this comment

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

Does this need to be python3?

Choose a reason for hiding this comment

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

I think it's a good idea to add a symlink for python to point to python3.10.

Here is the relevant section of the Dockerfile with the symlink added:

RUN apt-get update && apt-get install -y \
 python3.10 \
 python3-pip \
 git \
 wget \
 && ln -sf /usr/bin/python3.10 /usr/bin/python

@TimPietrusky
Copy link
Member

@kklemon thank you very much, then I will go down this road and make sure it is working.

@TimPietrusky TimPietrusky changed the title feat: optional restoring of ComfyUI snapshots to bake custom nodes into the Docker Image feat/restore-snapshot Nov 16, 2024
@TimPietrusky
Copy link
Member

TimPietrusky commented Nov 17, 2024

Some changes are coming:

  • added comfy-cli
  • install ComfyUI with comfy-cli
  • restore a snapshot using comfy-cli
  • update docs
  • added test for "restore-snapshot"

In my tests this made sure, that we can now install custom nodes using the snapshot created using the ComfyUI Manager, which is way more nice than adding the nodes directly into the Dockerfile.

@TimPietrusky TimPietrusky merged commit 7e4b7d0 into blib-la:main Nov 18, 2024
1 check passed
@TimPietrusky
Copy link
Member

🎉 This PR is included in version 3.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@A-BMT02
Copy link

A-BMT02 commented Nov 19, 2024

I can't seem to get this working . When i start a runpod pod and open my comfy ui on port 8188 it works fine , i can generate my images fine

But when i use the serverless endpoint with the same workflow json , i get an error
2024-11-19 14:00:45.074 [c7msa02ut39p9w] [info] invalid prompt: {'type': 'invalid_prompt', 'message': 'Cannot execute because node FaceDetailer does not exist.',

It seems like the custom nodes are not being recognized in the serverless endpoint even though i have the snapshot.json in the /runpod-volume (/workspace) directory

If i try a request with no custom nodes on the runpod serverless endpoint , it works fine.

@TimPietrusky
Copy link
Member

@A-BMT02 I moved this conversation over into an issue: #79

Calvin-Huang pushed a commit to gazai-io/runpod-worker-comfy that referenced this pull request Nov 26, 2024
* feat: provide option to run the handler locally as API

* ci: run the workflow on our extended instance

* feat: the local API should run on 0.0.0.0

* feat: make the image smaller

* ci: use semantic-version to create releases automatically

* chore: we don't want to break anyone with a minor release

* docs: added section for local API testing

* ci: use custom runner

* fix: added .releaserc, otherwise semantic-release will complain about a missing "package.json"

* feat: support network volumes, skip default models (blib-la#16)

* Support network volumes

* README tweaks

* docs: added comment on what is happening

* feat: don't overwrite the default paths, but add "runpod_worker_comfy" to have additional paths

* docs: updated "bring your own models"

---------

Co-authored-by: Tim Pietrusky <timpietrusky@gmail.com>

* feat: provide access to ComfyUI via web

* fix: use the full path to the output image

* feat: added env vars COMFY_POLLING_INTERVAL_MS and COMFY_POLLING_MAX_RETRIES

* test: added "subfolder"

* Implement optional restoring of ComfyUI snapshots

* feat: use comfy-cli to install ComfyUI & restore snapshot

* fix: install all dependencies from the snapshot

* chore: moved example snapshot to test_resources

* feat: allow any kind of snapshot file

* feat: allow any file that has "snapshot" in its name

* ci: added test for "restore-snapshot"

* ci: run restore snapshat test automatically

* docs: use "snapshots" to bake custom nodes into the docker image

* docs: add link to ComfyUI Manager docs on how to export snapshots

* ci: use correct path to example_snapshot.json

* ci: fix the path

* ci: fix the file path

* ci: use a mock instead of the actual file

* ci: fix the path

* chore: don't ignore snapshot.json as people might use this

---------

Co-authored-by: Tim Pietrusky <timpietrusky@gmail.com>
Co-authored-by: Meptl <git-client@meptl.com>
Calvin-Huang pushed a commit to gazai-io/runpod-worker-comfy that referenced this pull request Dec 2, 2024
* feat: provide option to run the handler locally as API

* ci: run the workflow on our extended instance

* feat: the local API should run on 0.0.0.0

* feat: make the image smaller

* ci: use semantic-version to create releases automatically

* chore: we don't want to break anyone with a minor release

* docs: added section for local API testing

* ci: use custom runner

* fix: added .releaserc, otherwise semantic-release will complain about a missing "package.json"

* feat: support network volumes, skip default models (blib-la#16)

* Support network volumes

* README tweaks

* docs: added comment on what is happening

* feat: don't overwrite the default paths, but add "runpod_worker_comfy" to have additional paths

* docs: updated "bring your own models"

---------

Co-authored-by: Tim Pietrusky <timpietrusky@gmail.com>

* feat: provide access to ComfyUI via web

* fix: use the full path to the output image

* feat: added env vars COMFY_POLLING_INTERVAL_MS and COMFY_POLLING_MAX_RETRIES

* test: added "subfolder"

* Implement optional restoring of ComfyUI snapshots

* feat: use comfy-cli to install ComfyUI & restore snapshot

* fix: install all dependencies from the snapshot

* chore: moved example snapshot to test_resources

* feat: allow any kind of snapshot file

* feat: allow any file that has "snapshot" in its name

* ci: added test for "restore-snapshot"

* ci: run restore snapshat test automatically

* docs: use "snapshots" to bake custom nodes into the docker image

* docs: add link to ComfyUI Manager docs on how to export snapshots

* ci: use correct path to example_snapshot.json

* ci: fix the path

* ci: fix the file path

* ci: use a mock instead of the actual file

* ci: fix the path

* chore: don't ignore snapshot.json as people might use this

---------

Co-authored-by: Tim Pietrusky <timpietrusky@gmail.com>
Co-authored-by: Meptl <git-client@meptl.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants