-
Notifications
You must be signed in to change notification settings - Fork 55
Add option to use dispersion fitter without rich.progress #2258
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
base: develop
Are you sure you want to change the base?
Conversation
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.
Thanks @caseyflex yeah I think we need to generally streamline sources/sinks for logging etc., this is kind of related to that.
A lazy import for rich
is the right choice (as we do elsewhere), what I'm a bit concerned about is the duplication of logic in the fit()
function, it's more surface area for bugs to creep in. I think a more robust approach might be to keep the current logic as-is, but introduce a dummy progress bar that exposes all the same methods but does nothing if the rich
import fails. This could in principle also be reused in other functions. We could either add it here, or perhaps better in tidy3d/log.py
(although we import rich
there too so this ends up being a bit of a rabbit hole...).
Something like:
class NoOpProgress:
def __enter__(self): return self
def __exit__(self, *args, **kwargs): pass
# any other methods that are called
try:
from rich.progress import Progress
except ImportError:
Progress = NoOpProgress
Depending on your bandwidth I think it'd be ok to define the dummy within the context of the function for now (this is mostly an MC thing right?), but we should aim for a more complete solution down the line. What do you think?
Thanks @yaugenst-flex Converting this to draft as we need to clarify the requirements here. I now see that even Regarding the general streamlining -- let's say we don't worry about imports for now. It would be nice to introduce classes in |
dbabe42
to
2456d15
Compare
2456d15
to
0e5b570
Compare
4e7124d
to
1530e75
Compare
1530e75
to
d94a912
Compare
The
rich
package is not supported by GUI, so they requested the option to use the fitter without this package.