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

re-work multi --styles-file #14707

Merged
merged 1 commit into from
Jan 23, 2024
Merged

Conversation

w-e-w
Copy link
Collaborator

@w-e-w w-e-w commented Jan 20, 2024

Description


users can specify multiple style file path by using wildcards and multiple entries of --styles-file

  • possible to specify styles files from different directory
  • the default styles file can be explicitly set by the user

Changes

cmd arg --styles-file change action to append str whitch forms a list internally same as --gradio-allowed-path
if no --styles-file is set by the user is then defaults to ['styles.csv']
--styles-file accepts paths or paths with wildcard *
also alow ? to be used to match a single character (previously only * can be used), https://docs.python.org/3/library/fnmatch.html#module-fnmatch

Default styles file path behavior

  1. the first --styles-file entry is use as the default styles file path
  2. if thers a * or ? in the path, it is used as wildcard pattern, the first matching file is used as default sytyles
  3. if no match is found, create a new styles.csv in the same dir as the first path

other changes

  • when saving a new style it will be save in the default styles file
  • when saving a existing style, it will be saved to file it belongs to
  • the order of the styles files in the styles dropdown can be controlled by the order of --styles-file

cmd arg example

use multiple --styles-file all at once

--styles-file "B:\\styles_dir_1\main_styles_file.csv"
--styles-file "B:\\styles_dir_1\sub_styles_file.csv"
--styles-file "B:\\styles_dir_1\prfix_*.csv"
--styles-file "B:\\styles_dir_2\*_suffix.csv"
--styles-file "B:\\styles_dir_3\*.csv"

this example would load
B:\\styles_dir_1\main_styles_file.csv and use as default
B:\\styles_dir_1\sub_styles_file.csv
load every file in styles_dir_1 matching prefix_ and suffix .csv
load every file in styles_dir_2 matching suffix _suffix.csv
loda every .csv in styles_dir_3


@cjj1977 can you check if this satisfies your requirements

Checklist:

@w-e-w w-e-w requested a review from AUTOMATIC1111 as a code owner January 20, 2024 17:43
@w-e-w w-e-w force-pushed the multi-styles-base-styles-file branch 2 times, most recently from ffc4fd9 to dce71df Compare January 20, 2024 18:03
@MisterSeajay
Copy link
Contributor

@w-e-w I will have a look & test. Gotta remind myself how to fetch an upstream branch into my fork.

@w-e-w
Copy link
Collaborator Author

w-e-w commented Jan 20, 2024

@w-e-w I will have a look & test. Gotta remind myself how to fetch an upstream branch into my fork.

github desktop is quite handy

image

--styles-file change to append str
--styles-file is [] then defaults to [styles.csv]

--styles-file accepts paths or paths with wildcard "*"

the first `--styles-file` entry is use as the default styles file path
if filename a wildcard then the first matching file is used
if no match is found, create a new "styles.csv" in the same dir as the first path

when saving a new style it will be save in the default styles file
when saving a existing style, it will be saved to file it belongs to

order of the styles files in the styles dropdown can be controlled to a certain degree by the order of --styles-file
@w-e-w w-e-w force-pushed the multi-styles-base-styles-file branch from dce71df to 25e8273 Compare January 20, 2024 18:55
@MisterSeajay
Copy link
Contributor

@w-e-w This looks good to me. Ran through my own use-cases and all seems fine.

@AUTOMATIC1111 AUTOMATIC1111 merged commit c17f7ee into dev Jan 23, 2024
6 checks passed
@AUTOMATIC1111 AUTOMATIC1111 deleted the multi-styles-base-styles-file branch January 23, 2024 19:22
@w-e-w w-e-w mentioned this pull request Feb 17, 2024
@pawel665j pawel665j mentioned this pull request Apr 16, 2024
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.

3 participants