-
Notifications
You must be signed in to change notification settings - Fork 11
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
43 sofast as a service #61
Conversation
In order to more easily view the pieces pulled out of SofastGUI into SofastService, I've also created PR #62 |
e92357f
to
b720656
Compare
@@ -133,6 +111,17 @@ def _plot_image(self, ax: plt.Axes, image: np.ndarray, title: str = '', xlabel: | |||
ax.set_xlabel(xlabel) | |||
ax.set_ylabel(ylabel) | |||
|
|||
@functools.cached_property |
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.
This is a cool decorator, didn't know that existed!
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.
Right?! Pretty nifty. Also extremely susceptible to bugs if not used with care since by definition it produces hidden side effects.
opencsp/app/sofast/SofastGUI.py
Outdated
self.service.run_gray_levels_cal( | ||
calibration_class=cal_type, | ||
calibration_hdf5_path_name_ext=file, | ||
on_calibrating=on_calibrating, |
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.
I believe the input "on_calibrating" should be "on_captured," (or the other way around). It doesn't look like SofastService doesn't have an "on_calibrating" input.
on_calibrating=on_calibrating, | |
on_captured=on_calibrating, |
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.
I don't know how you even saw this. Nice catch! Thanks!
opencsp/app/sofast/SofastService.py
Outdated
def load_gray_levels_cal(self, hdf5_file_path_name_ext: str) -> None: | ||
"""Loads saved results of a projector-camera intensity calibration""" | ||
# Load file | ||
cal_type = h5.load_hdf5_datasets(['Calibration/calibration_type'], hdf5_file_path_name_ext)['calibration_type'] |
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.
This is 100% my error that got propagated (I don't use the "Load Gray Levels" button very often apparently). But the ImageCalibration class actually saves/loads to HDF files as "ImageCalibration/calibration_type".
See:
datasets = ['ImageCalibration/calibration_type'] |
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 for pointing this out. Fixed!
@bbean23, these improvements look great! There are just a couple bugs I found; if you could address those when you get a chance that would be great. Not necessary for this PR, but this reminds me of something that I've been meaning to bring up with everyone. SofastGUI, since it is a GUI, isn't unit-tested. Is there a way to do this? If not, should it live in the opencsp/... folder or somewhere else? (putting it in contrib/ doesn't feel right, so IDK). Let me know what you think, but no action necessary for this PR. |
@bbean23, I had some thoughts about SofastService.py. This is a bit late into your development, so sorry I didn't think of this earlier. Also feel free to disregard, this is just something to think about.
|
[4:05 PM] Ben I was also considering this. Ideally SofastService will apply to both SofastFringe and SofastFixed so that it can be a singular interface to the various Sofast algorithms, but maybe that is the wrong way to think about it. What do you think? [4:08 PM] Braden Yeah, that would be great if it applied to both actually. If that's the vision for it, then I'd agree it should remain SofastService.py. [4:20 PM] Ben Now for 2: Would it be better to put those methods ( I'd say that if there is a method that is specific to SofastSystemFringe or SofastSystemFixed, then that method should go in that class. I haven't worked with SofastSystemFixed yet, but I'm assuming it doesn't have a gray levels calibration? [4:28 PM] Braden [4:29 PM] Ben |
@braden6521 I made some changes while I was writing unit tests. Will you please take a look at them? They're all in the commit 7edc3e1. Thanks! |
7edc3e1
to
79653ba
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.
@bbean23, this all looks good; approved!
I even gave it a test in the optics lab today and everything seems to be working fine.
79653ba
to
4010a60
Compare
Thanks for the review, Braden! I just rebased on top of develop and will merge once the checks are completed. |
This is part 1 of 2, which extracts pieces of the SofastGUI into another class. The goal is to have a common interface to Sofast, which can be wrapped with other GUIs, scripts, or web interfaces.
closes #43
to be continued in #60