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

Kowalski Filter - not_if_tns_reported #561

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Theodlz marked this conversation as resolved.
Show resolved Hide resolved
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
Loading