Skip to content
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

DM-47120: Add more columns to metric viewer #10

Merged
merged 8 commits into from
Nov 18, 2024
Merged

DM-47120: Add more columns to metric viewer #10

merged 8 commits into from
Nov 18, 2024

Conversation

sr525
Copy link
Contributor

@sr525 sr525 commented Nov 11, 2024

No description provided.

Copy link
Member

@ctslater ctslater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments on cleanups that I think would help, but overall this looks good.

return (patch_str,)


def mk_shape_cols(t, metric_defs, n, bands, col_dict):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would replace col_dict with a list of columns, and have the caller be responsible extracting the shape_cols entry from the dictionary.

(Same thing applies to the other functions that use col_dict, but I'm not going to repeat the comment each time)

sig_str = f"<FONT CLASS=badValue>{sig:.3g}</FONT>\n"
bad_val += 1

return val_str, sig_str, bad_val, link, debug_group
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would replace this tuple with a named dataclass.

shape_str += sig_str + "<BR>\n"
if debug_group is not None:
debug_group_all = debug_group
shape_strs.append((shape_str, num_bad, link, debug_group_all))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tuple too should be a named class (same applies to other uses of this set of return values).

import numpy as np


def mk_table_value(t, metric_defs, val_col_name, sig_col_name, n):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not keen on passing a table and a row number, can this take a row instead? The other option in my mind is to take the values and the column name; I think that might be even cleaner but I'm not positive (i.e. take val and sig instead of extracting them in lines 64, 66 etc).

The formatted number of patches in each band
"""
patch_str = ""
for band in ["g", "r", "i", "z", "y"]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok with this being hard coded but a variable at the top of the file is probably better. Should add u. All the instances in other functions should reference the variable too.

patch_col = "coaddPatchCount_" + band + "_patchCount"
patch_str += "<B>" + band + "</B>: " + str(int(t[patch_col][n])) + "<BR>\n"

return (patch_str,)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a tuple?

__name__,
url_prefix="/plot-navigator/metrics",
static_folder="../../../../static",
)

NO_BUTLER = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be deleted.


# Add a nan/bad summary cell next but need to calculate these numbers first
row_list.append((num_bad,))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a tuple?

{% else %}
{% if 'badValue' in cell[0] %}
<td>
<a href={{url_for(cell[1], collection_name=collection_urlencoded, metric=cell[2])}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hope is that using a dataclass for cell will make it so you can use named fields instead of [1], [2], etc? I assume Jinja will be ok with that, but I'm not sure.

)
if val_str is None:
continue
row_str += (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be simpler as an f-string?

@sr525 sr525 merged commit 762bfa0 into main Nov 18, 2024
3 checks passed
@sr525 sr525 deleted the tickets/DM-47120 branch November 18, 2024 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants