-
Notifications
You must be signed in to change notification settings - Fork 0
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
WIP: observing mode group #1470
Conversation
modules/service/src/main/resources/db/migration/V0927__grouping_modes.sql
Outdated
Show resolved
Hide resolved
An example of the mode key:
|
985fd42
to
4a19a26
Compare
CREATE OR REPLACE FUNCTION extract_source_profile_summary( | ||
src_profile jsonb | ||
) | ||
RETURNS source_profile_summary AS $$ |
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 needs testing but we would need to extract the source profile type (point, uniform, or gaussian) from the JSON blob along with the fwhm if gaussian. This information is needed to compute the object size for the binning calculation.
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 my fault … I was concerned that designing a table structure for source profiles would have driven me mad.
-- Set the default binning. | ||
CREATE OR REPLACE PROCEDURE set_gmos_long_slit_default_binning( | ||
oid d_observation_id | ||
) AS $$ |
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.
We need to calculate the default binning in order to group observing modes. Usually the binning is not explicitly set but we need to know what binning will be used to group correctly. As you can see, this calculation is rather involved. It makes me nervous to put so much logic into plpgsql
. Other options that occur to me:
- Carefully update all the mutations that touch relevant fields and explicitly redo the calculation and update via Scala code.
- Create a channel for updates to anything that would impact the default binning, respond to updates in Scala code.
What would be best?
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 seems like the right way to do it, in the sense that it's never stale. If we rely on application logic to keep it up to date we will eventually hit situations where it's wrong. Having said that, we're relying on channel events to deal with calibrations and may end up doing the same for observation warnings and workflow status. So it's hard to say. There will always be problems in this middle ground where a PL/SQL solution is doable but starts to feel like too much. My instinct right now is to just go with it since it works.
CASE WHEN o.c_observing_mode_type = 'gmos_north_long_slit' THEN mode_gnls.c_mode_key END, | ||
CASE WHEN o.c_observing_mode_type = 'gmos_south_long_slit' THEN mode_gsls.c_mode_key END, | ||
NULL | ||
) AS c_mode_key |
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 the new bit in the view, but I suspect that doing this calculation in the view is not a good idea. Instead, I think it probably would need to be done via triggers on updates to the c_mode_key
in t_gmos_north_long_slit
and t_gmos_south_long_slit
. That way we can index on this value for fast joins.
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.
Trying it with a real t_observation.c_mode_key
column updated via a trigger :-/
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.
It's probably fine to do it in the view if it's not being selected 100% of the time, but the safe assumption seems to be that Explore always selects absolutely everything.
96dfdfe
to
56336e5
Compare
I'll mark this as "ready" but recognizing that feedback on the binning calculation may necessitate redoing that chunk of it. |
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.
You have thought about all the issues that come to mind for me, and I'm also not really sure what the right approach is. But it seems to be correct and will probably perform fine once it's a triggered computation, so in the spirit of progress I think it's good to go. 👍
This is a work-in-progress attempt to add observation grouping by observing mode in a way similar to the constraint set grouping. I'd like feedback on whether this looks feasible.
Constraint set grouping is a much simpler case case because observing modes:
t_gmos_north_long_slit
vst_gmos_south_long_slit
)In particular the last point is problematic because the default binning calculation is detailed. Currently we compute the defaults in code, but in order to group observing modes regardless of whether the binning is explicitly provided or supplied by default, I need to get default binning into the long slit tables. How to do that is the question. In this version the calculation is done in
plpgsql
but other alternatives might be:What do we think best?