Skip to content

Commit

Permalink
Kowalski Filter - not_if_tns_reported (#561)
Browse files Browse the repository at this point in the history
* add support for the not_if_tns_reported kowalski parameter when updating filters

* add frontend to edit that parameter on the filter page
  • Loading branch information
Theodlz authored Nov 5, 2024
1 parent 8f5ad28 commit 61c937d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
20 changes: 20 additions & 0 deletions extensions/skyportal/skyportal/handlers/api/kowalski_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,31 @@ def patch(self, filter_id):
"radius",
"implements_update",
"ignore_allocation_ids",
"not_if_tns_reported",
}
if not set(auto_followup.keys()).issubset(valid_keys):
return self.error(
f"auto_followup dict keys must be a subset of {valid_keys}"
)
if "not_if_tns_reported" in auto_followup:
# if it's not empty or None, verify it's a a float or an int
# it should be in hours
if (
auto_followup["not_if_tns_reported"] is not None
and str(auto_followup["not_if_tns_reported"]).strip() != ""
):
try:
auto_followup["not_if_tns_reported"] = float(
auto_followup["not_if_tns_reported"]
)
except ValueError:
return self.error(
"not_if_tns_reported must be a float or an int, if not an empty string or None"
)
else:
# we still want to keep it when None, for example when we want to unset it
auto_followup["not_if_tns_reported"] = None

# query the allocation by id
allocation_id = auto_followup.get("allocation_id", None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const FilterPlugins = ({ group }) => {
const [autosaveComment, setAutosaveComment] = useState("");
const [autoFollowupComment, setAutoFollowupComment] = useState("");
const [autoFollowupRadius, setAutoFollowupRadius] = useState(0.5);
const [autoFollowupTnsAge, setAutoFollowupTnsAge] = useState(null);

const [otherVersion, setOtherVersion] = React.useState("");

Expand Down Expand Up @@ -321,6 +322,7 @@ const FilterPlugins = ({ group }) => {
const newAutoFollowup = {
...filter_v.auto_followup,
radius: autoFollowupRadius,
not_if_tns_reported: autoFollowupTnsAge,
};
const result = await dispatch(
filterVersionActions.editAutoFollowup({
Expand All @@ -331,7 +333,7 @@ const FilterPlugins = ({ group }) => {
if (result.status === "success") {
dispatch(
showNotification(
`Set auto_followup radius constraint to ${autoFollowupRadius}`,
`Set auto_followup radius constraint to ${autoFollowupRadius}, and TNS age constraint to ${autoFollowupTnsAge}`,
),
);
}
Expand Down Expand Up @@ -1570,6 +1572,21 @@ const FilterPlugins = ({ group }) => {
}
/>
</div>
<div style={{ marginTop: "1rem" }}>
<InputLabel id="auto_followup_constraints_tns_age">
Cancel if TNS reported in the last N hours. Leave empty to disable
</InputLabel>
<TextField
labelId="auto_followup_constraints_tns_age"
className={classes.formControl}
disabled={!filter_v.active}
id="auto_followup_constraints_tns_age"
defaultValue={filter_v.auto_followup?.not_if_tns_reported}
onChange={(event) =>
setAutoFollowupTnsAge(event.target.value)
}
/>
</div>
<div
style={{
display: "flex",
Expand Down
5 changes: 5 additions & 0 deletions fritz.defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ skyportal:
host:
port:

gemini:
protocol: https
host: gsodbtest.gemini.edu # this is the test server host, just remove 'test' for production
port: 8443 # this is the test server port, production is 443

treasuremap_endpoint: https://treasuremap.space

tns:
Expand Down

0 comments on commit 61c937d

Please sign in to comment.