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

Moving models download settings to user settings. #3216

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lerignoux
Copy link
Contributor

@lerignoux lerignoux commented Mar 24, 2025

I would like to be able to customize the download urls for comfy to whitelist new models servers.

I saw there was a todo in the front end part suggesting to do this change in particular so I decided to do it.

It should be completely transparent for user, just allow to customize the comfy.settings.json to have a custom option in case it needs to be changed.

I didn't find any relevant unit test to add, but please tell me if you think there should be one (both the modal and settings are already tested.)

┆Issue is synchronized with this Notion page by Unito

@lerignoux lerignoux requested a review from a team as a code owner March 24, 2025 05:05
@lerignoux lerignoux marked this pull request as draft March 24, 2025 05:06
id: 'Comfy.ModelLibrary.AllowedSources',
category: ['Comfy', 'Model', 'Download'],
name: 'Model Download Allowed Sources',
type: 'hidden',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There does not seem to exists an array type so relying on hidden for now. I don't think allowing configuration in Interface brings a lot of value

defaultValue: [
'https://civitai.com/',
'https://huggingface.co/',
'http://localhost:'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

should this be added only if current domain is localhost ? It would be safer no ?

@lerignoux lerignoux force-pushed the models_download_configuration branch 2 times, most recently from ff613ca to bf0df5c Compare March 24, 2025 05:15
Comment on lines 46 to 47
const allowedSources = await settingsStore.get('Comfy.ModelLibrary.AllowedSources')
const allowedSuffixes = await settingsStore.get('Comfy.ModelLibrary.AllowedSuffixes')
Copy link
Contributor

@christian-byrne christian-byrne Mar 24, 2025

Choose a reason for hiding this comment

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

I think we can remove the await. Using await in top level of the script makes it so the setup function returns a Promise.

Edit: Sorry, didn't see it was still a draft PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, I was still testing and doing changes.
Should be ok now, please tell me if you see any issue or suggestion

@lerignoux lerignoux force-pushed the models_download_configuration branch from bf0df5c to a0888d9 Compare March 24, 2025 10:31
@lerignoux
Copy link
Contributor Author

I am not sure what kind of tests could be added. Do you see any or is it ok without additional tests ?

@lerignoux lerignoux force-pushed the models_download_configuration branch 2 times, most recently from d3d4e36 to edfbcf5 Compare March 24, 2025 13:52
@lerignoux lerignoux marked this pull request as ready for review March 24, 2025 14:03
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.

Just for some context:

Originally I changed these hardcoded values to user settings, but they are reverted in https://github.com/Comfy-Org/ComfyUI_frontend/pull/890/files#r1772680306 with this TODO. The original idea for this TODO is to serve the allowed values from the backend server via server configuration rather than a value that the user can control.

@mcmonkey4eva for explaining what needs to be done here to resolve the TODO.

Ref: #890 (comment)

@lerignoux
Copy link
Contributor Author

Just for some context:

Originally I changed these hardcoded values to user settings, but they are reverted in https://github.com/Comfy-Org/ComfyUI_frontend/pull/890/files#r1772680306 with this TODO. The original idea for this TODO is to serve the allowed values from the backend server via server configuration rather than a value that the user can control.

@mcmonkey4eva for explaining what needs to be done here to resolve the TODO.

Ref: #890 (comment)

Thank you for the feedback.

I tried to follow what I understood from the discussion intention.
I could not find a relevant API and config in Comfy so I tried adding a simple one.
Do you think it is acceptable ?
cf ComfyUI Merge Request

@lerignoux lerignoux force-pushed the models_download_configuration branch 2 times, most recently from ea3e346 to bead8a6 Compare March 25, 2025 02:59
@lerignoux lerignoux force-pushed the models_download_configuration branch from bead8a6 to ec2731a Compare March 25, 2025 06:51
@lerignoux lerignoux force-pushed the models_download_configuration branch from ec2731a to df1055c Compare March 25, 2025 07:08
@lerignoux lerignoux requested a review from huchenlei March 25, 2025 07:19
@mcmonkey4eva
Copy link
Contributor

The download restrictions (last I looked at things some months ago) are defined in ComfyUI (the python code repo), the frontend is merely just prerendering what the python is going to say about it -- so the values should be sourced from the python repo (eg a consistent internal API). Frontend settings make no sense for that data. Frontend hardcoding is a lazy but functional placeholder.

@huchenlei
Copy link
Member

huchenlei commented Mar 25, 2025

The download restrictions (last I looked at things some months ago) are defined in ComfyUI (the python code repo), the frontend is merely just prerendering what the python is going to say about it -- so the values should be sourced from the python repo (eg a consistent internal API). Frontend settings make no sense for that data. Frontend hardcoding is a lazy but functional placeholder.

BTW, the model downloading logic has been removed from the comfyui backend, the download for standalone is just using browser's download to download the model file. Download to directory directly feature is only available on desktop version. I think it is fine now to have the validation in the frontend only.

Ref: comfyanonymous/ComfyUI#5432

@lerignoux
Copy link
Contributor Author

lerignoux commented Mar 26, 2025

The download restrictions (last I looked at things some months ago) are defined in ComfyUI (the python code repo), the frontend is merely just prerendering what the python is going to say about it -- so the values should be sourced from the python repo (eg a consistent internal API). Frontend settings make no sense for that data. Frontend hardcoding is a lazy but functional placeholder.

Thank you for the info.

I could not find a reference to this whitelist in the Comfy repo so I added a configuration and internal for it as you suggested.
Do you think it is ok ?
Cf MR

@lerignoux
Copy link
Contributor Author

validation in the frontend only.

I see.
So that would mean keeping the current code and just removing the comment (In that case I will just suggest to move the list to a constant file).
@mcmonkey4eva It seems the comment to move this to API download was coming from you is it ok to keep that in the front end code ?

@mcmonkey4eva
Copy link
Contributor

My comments in the code there are outdated to the modern system per huchenlei's explanation

@lerignoux lerignoux marked this pull request as draft March 29, 2025 14:37
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.

LGTM on proceeding with orginal implementation of moving allow list to user settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants