Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
f2b69709
Commit
f2b69709
authored
Nov 04, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move option access checking to options class out of various places scattered through code
parent
26108a7f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
17 deletions
+18
-17
modules/processing.py
modules/processing.py
+2
-2
modules/shared.py
modules/shared.py
+11
-0
modules/ui.py
modules/ui.py
+5
-15
No files found.
modules/processing.py
View file @
f2b69709
...
@@ -418,13 +418,13 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
...
@@ -418,13 +418,13 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
try
:
try
:
for
k
,
v
in
p
.
override_settings
.
items
():
for
k
,
v
in
p
.
override_settings
.
items
():
opts
.
data
[
k
]
=
v
# we don't call onchange for simplicity which makes changing model, hypernet impossible
setattr
(
opts
,
k
,
v
)
# we don't call onchange for simplicity which makes changing model, hypernet impossible
res
=
process_images_inner
(
p
)
res
=
process_images_inner
(
p
)
finally
:
finally
:
for
k
,
v
in
stored_opts
.
items
():
for
k
,
v
in
stored_opts
.
items
():
opts
.
data
[
k
]
=
v
setattr
(
opts
,
k
,
v
)
return
res
return
res
...
...
modules/shared.py
View file @
f2b69709
...
@@ -396,6 +396,15 @@ class Options:
...
@@ -396,6 +396,15 @@ class Options:
def
__setattr__
(
self
,
key
,
value
):
def
__setattr__
(
self
,
key
,
value
):
if
self
.
data
is
not
None
:
if
self
.
data
is
not
None
:
if
key
in
self
.
data
or
key
in
self
.
data_labels
:
if
key
in
self
.
data
or
key
in
self
.
data_labels
:
assert
not
cmd_opts
.
freeze_settings
,
"changing settings is disabled"
comp_args
=
opts
.
data_labels
[
key
]
.
component_args
if
isinstance
(
comp_args
,
dict
)
and
comp_args
.
get
(
'visible'
,
True
)
is
False
:
raise
RuntimeError
(
f
"not possible to set {key} because it is restricted"
)
if
cmd_opts
.
hide_ui_dir_config
and
key
in
restricted_opts
:
raise
RuntimeError
(
f
"not possible to set {key} because it is restricted"
)
self
.
data
[
key
]
=
value
self
.
data
[
key
]
=
value
return
return
...
@@ -412,6 +421,8 @@ class Options:
...
@@ -412,6 +421,8 @@ class Options:
return
super
(
Options
,
self
)
.
__getattribute__
(
item
)
return
super
(
Options
,
self
)
.
__getattribute__
(
item
)
def
save
(
self
,
filename
):
def
save
(
self
,
filename
):
assert
not
cmd_opts
.
freeze_settings
,
"saving settings is disabled"
with
open
(
filename
,
"w"
,
encoding
=
"utf8"
)
as
file
:
with
open
(
filename
,
"w"
,
encoding
=
"utf8"
)
as
file
:
json
.
dump
(
self
.
data
,
file
,
indent
=
4
)
json
.
dump
(
self
.
data
,
file
,
indent
=
4
)
...
...
modules/ui.py
View file @
f2b69709
...
@@ -1438,8 +1438,6 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -1438,8 +1438,6 @@ def create_ui(wrap_gradio_gpu_call):
def
run_settings
(
*
args
):
def
run_settings
(
*
args
):
changed
=
0
changed
=
0
assert
not
shared
.
cmd_opts
.
freeze_settings
,
"changing settings is disabled"
for
key
,
value
,
comp
in
zip
(
opts
.
data_labels
.
keys
(),
args
,
components
):
for
key
,
value
,
comp
in
zip
(
opts
.
data_labels
.
keys
(),
args
,
components
):
if
comp
!=
dummy_component
and
not
opts
.
same_type
(
value
,
opts
.
data_labels
[
key
]
.
default
):
if
comp
!=
dummy_component
and
not
opts
.
same_type
(
value
,
opts
.
data_labels
[
key
]
.
default
):
return
f
"Bad value for setting {key}: {value}; expecting {type(opts.data_labels[key].default).__name__}"
,
opts
.
dumpjson
()
return
f
"Bad value for setting {key}: {value}; expecting {type(opts.data_labels[key].default).__name__}"
,
opts
.
dumpjson
()
...
@@ -1448,15 +1446,9 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -1448,15 +1446,9 @@ def create_ui(wrap_gradio_gpu_call):
if
comp
==
dummy_component
:
if
comp
==
dummy_component
:
continue
continue
comp_args
=
opts
.
data_labels
[
key
]
.
component_args
if
comp_args
and
isinstance
(
comp_args
,
dict
)
and
comp_args
.
get
(
'visible'
)
is
False
:
continue
if
cmd_opts
.
hide_ui_dir_config
and
key
in
restricted_opts
:
continue
oldval
=
opts
.
data
.
get
(
key
,
None
)
oldval
=
opts
.
data
.
get
(
key
,
None
)
opts
.
data
[
key
]
=
value
setattr
(
opts
,
key
,
value
)
if
oldval
!=
value
:
if
oldval
!=
value
:
if
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
if
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
...
@@ -1469,17 +1461,15 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -1469,17 +1461,15 @@ def create_ui(wrap_gradio_gpu_call):
return
f
'{changed} settings changed.'
,
opts
.
dumpjson
()
return
f
'{changed} settings changed.'
,
opts
.
dumpjson
()
def
run_settings_single
(
value
,
key
):
def
run_settings_single
(
value
,
key
):
assert
not
shared
.
cmd_opts
.
freeze_settings
,
"changing settings is disabled"
if
not
opts
.
same_type
(
value
,
opts
.
data_labels
[
key
]
.
default
):
if
not
opts
.
same_type
(
value
,
opts
.
data_labels
[
key
]
.
default
):
return
gr
.
update
(
visible
=
True
),
opts
.
dumpjson
()
return
gr
.
update
(
visible
=
True
),
opts
.
dumpjson
()
oldval
=
opts
.
data
.
get
(
key
,
None
)
oldval
=
opts
.
data
.
get
(
key
,
None
)
if
cmd_opts
.
hide_ui_dir_config
and
key
in
restricted_opts
:
try
:
setattr
(
opts
,
key
,
value
)
except
Exception
:
return
gr
.
update
(
value
=
oldval
),
opts
.
dumpjson
()
return
gr
.
update
(
value
=
oldval
),
opts
.
dumpjson
()
opts
.
data
[
key
]
=
value
if
oldval
!=
value
:
if
oldval
!=
value
:
if
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
if
opts
.
data_labels
[
key
]
.
onchange
is
not
None
:
opts
.
data_labels
[
key
]
.
onchange
()
opts
.
data_labels
[
key
]
.
onchange
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment