Skip to content

Adding CLI option --output-dir#14442

Closed
canoalberto wants to merge 2 commits intoAUTOMATIC1111:devfrom
canoalberto:dev
Closed

Adding CLI option --output-dir#14442
canoalberto wants to merge 2 commits intoAUTOMATIC1111:devfrom
canoalberto:dev

Conversation

@canoalberto
Copy link
Contributor

Description

Adding CLI option --output-dir to the cmd_args.
Useful when the base path is not writable for the user (thus cannot create/write default "outputs" folder)
Use case: shared installation by multiple users

Screenshots/videos:

NA (only CLI change)

Checklist:

@w-e-w
Copy link
Collaborator

w-e-w commented Dec 27, 2023

if you're going to change the defaut save path you might as well base it off --data-dir directory and not webui root
but more importantly this only changes the default save path, which is not useful at all if the user has already saved the config, which means this is only useful for generating new config file

if you want a quick way of changing the same directory for all images then you can set outdir_samples
so I don't really see a point of adding a new cli arg (at least with the current implementation)


out of curiosity in what situation would cause "base path is not writable for the user"
and are you sure webui would even run without being able to write to its base path?

@canoalberto
Copy link
Contributor Author

Use case: a single, shared, pre-configured installation of stable-diffusion-webui in a read-only directory (e.g. /opt/stable-diffusion-webui) to be used by multiple end users (e.g. in an open ondemand environment where each user is running their own stable-diffusion-webui on a different port (it works!)).

Issue: There are hardcoded "outputs" and "log" folders in modules/shared_options.py
using outdir_samples isn't sufficient to fix all of them

Fix: allow the CLI to specify an output directory (e.g. --output-dir=$HOME/stable-diffusion-webui-outputs)

@w-e-w
Copy link
Collaborator

w-e-w commented Dec 27, 2023

are you saying that in your use case each user has their own separate config ui-config --data-path venv ......
the new --output-dir is used for initializing the users config.json with the the users own dir as the default?
and so after the config file is saved --output-dir becomes useless

if this is the case that I'm not sure if cli arg suitable, I feel like cli args should have an effect even after the config is saved
more so because the name --output-dir follows the same pattern as other --xxx-dir args which all have effect after relaunching independent of the config

I still think it makes more sense to just base the default output dir on --data-path and not adding a new cli arg

I'm pretty sure that you're already using --data-path
otherwise if the webui root not writable you shouldn't be able to generate images
and if `config.json non writable and so webui won't even be able to switch models

@canoalberto
Copy link
Contributor Author

canoalberto commented Dec 27, 2023

I am already using --data-dir but that is not sufficient. When using --data-dir it creates its own ui-config.json, cache.json, etc for the given session, that's fine. However, --data-dir isn't in the path where the outputs are stored according to modules/shared_options.py

If the issue is adding an "unnecessary" extra parameter to the CLI then the fix (to the hardcoded outputs/log folder) is even simpler if in modules/shared_options.py

references to OptionInfo("outputs/...") and OptionInfo("log/images")
are changed to OptionInfo(f"{shared.cmd_opts.data_dir}/outputs/...") and OptionInfo(f"{shared.cmd_opts.data_dir}/log/images")

The point is not to have hardcoded outputs and logs references. If that's easier I will close this PR and open a new one with simply adding the data_dir prefix to the outputs and log folder

@canoalberto canoalberto deleted the dev branch December 27, 2023 18:16
@w-e-w
Copy link
Collaborator

w-e-w commented Dec 27, 2023

--data-dir don't implicitly create its own config.json it only behaved like so because it changes the default location of --ui-config-file and if the config file is not found it will create a new one next time the user saves the settings

the main issue that I have with --output-dir is that once the settings is saved to file, this cli arg becomes effectively useless
which means it is something that's used purely for configuring the initial default location,
this means that this is not useful for most people, and so I don't think it's useful for most people in order to warrant adding a cli arg, and would add confusion to people wondering why the cli arg does not take effect because this similarity to other --xxx-dir cli args

I'm not against adding a new --output-dir, I'm against because it is not generally useful

it's possible to make --output-dir useful but it will require much more change to the code base
so instead as opposed to adding a cli arg I suggest something like the following

# modules\paths_internal.py
default_output_dir = os.path.join(data_path, "output")

# modules\shared_options.py
"outdir_txt2img_samples": OptionInfo(os.path.join(default_output_dir, 'txt2img-images'), 'Output directory for txt2img images', component_args=hide_dirs),
"outdir_save": OptionInfo(os.path.join(data_path, 'log', 'images'), "Directory for saving images using the Save button", component_args=hide_dirs),

this makes it so that the default save paths is instead based off the data_path (--data-dir) and not webui root, which may suits you needs

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.

2 participants