-
Notifications
You must be signed in to change notification settings - Fork 12
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
Improve initialization for extra arches #281
Improve initialization for extra arches #281
Conversation
b06397d
to
94b44c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay.
There are 2 things I want to talk about:
-
I really like the
install
function, but I think its API is a little weird. It only returnsFalse
for a single type of failure and throws otherwise. This also contradicts the documentation of the function.I think a better API would be
def install(*, ignore_duplicates=False) -> None
. Basically, it throws by default, but you can useinstall(ignore_duplicates=True)
to ensure that the second install is a noop.Implementation-wise, we just have to add a
ignore_duplicates=False
argument toArchRegistry#add
, and theninstall
can be implemented as simply:def install(*, ignore_duplicates: bool = False) -> None: """TODO: Add docs""" MAIN_REGISTRY.add(*EXTRA_REGISTRY, ignore_duplicates=ignore_duplicates)
-
Throwing aEdit: my badDuplicateArchitectureError
is a breaking change. I don't think it's a bad change, but this is something we have to consider, especially since the need for a unique error has been diminished with theignore_duplicates
parameter.
It's not, IMO, unless you're catching things in a particularly weird way (like, We used to throw I'll get back to the other concerns later, work-work is pressing. |
You're absolutely correct. I overlooked that. Please ignore point 2. |
94b44c5
to
e7e4126
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 minor nits.
Co-authored-by: Michael Schmidt <[email protected]>
a91ab5e
to
11c86dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @akx!
This PR is related to AUTOMATIC1111/stable-diffusion-webui#16144, where we have to do some contortions to install extra arches when Spandrel is late-imported.
It
ValueError
for duplicate architectures a specific exception type, so it can be caught...spandrel_extra_arches.install()
convenience function, which will return False (and not raise) in case the main registry already has (any of) the arches it tries to wire up.