Skip to content

Commit

Permalink
SWIFT ToO API: UVOT justification (skyportal#5250)
Browse files Browse the repository at this point in the history
* Require uvot_just (justification) when the uvot_mode is 0x0270

* skip GCN Tach-related tests if the server is down

---------

Co-authored-by: Theodlz <theophile.dulaz@gmail.com>
  • Loading branch information
mcoughlin and Theodlz authored Sep 8, 2024
1 parent c2019aa commit fff6294
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
38 changes: 38 additions & 0 deletions skyportal/facility_apis/swift.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ def _build_payload(self, request):
modes_index = modes_values.index(request.payload["uvot_mode"])
too.uvot_mode = modes_keys[modes_index]
too.science_just = request.payload["science_just"]
if too.uvot_mode == '0x0270':
too.uvot_just = request.payload.get("uvot_just", None)
if not too.uvot_just:
raise ValueError(
'uvot_just is required when the UVOT mode select is 0x0270 (ToO Upload Mode).'
)

return too

Expand Down Expand Up @@ -764,6 +770,38 @@ def submit(request, session, **kwargs):
"default": "An X-ray detection of this transient will further associate this object to a relativistic explosion and will help unveil the nature of the progenitor type.",
},
},
"dependencies": {
"uvot_mode": {
"oneOf": [
{
"properties": {
"uvot_mode": {
"enum": [
"0x0270 - U+B+V+All UV (ToO Upload Mode)"
],
},
"uvot_just": {
"title": "UVOT Mode Justification",
"type": "string",
"default": "We wish to use mode 0x0270 - U+B+V+All UV (ToO Upload Mode).",
},
},
"required": ["uvot_just"],
},
{
"properties": {
"uvot_mode": {
"not": {
"enum": [
"0x0270 - U+B+V+All UV (ToO Upload Mode)"
],
},
},
}
},
]
},
},
},
],
},
Expand Down
13 changes: 13 additions & 0 deletions skyportal/tests/api/candidates_sources_events/test_gcn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import numpy as np
import requests

from skyportal.tests import api
from skyportal.utils.gcn import from_url
Expand All @@ -12,6 +13,17 @@

import pytest

tach_isonline = False
try:
response = requests.get(
"https://heasarc.gsfc.nasa.gov/wsgi-scripts/tach/gcn_v2/tach.wsgi/", timeout=5
)
response.raise_for_status()
except Exception:
pass
else:
tach_isonline = True


@pytest.mark.flaky(reruns=2)
def test_gcn_GW(super_admin_token, view_only_token):
Expand Down Expand Up @@ -905,6 +917,7 @@ def test_confirm_reject_source_in_gcn(
assert len(data) == 0


@pytest.mark.skipif(not tach_isonline, reason="GCN TACH is not online")
def test_gcn_tach(
super_admin_token,
view_only_token,
Expand Down
13 changes: 13 additions & 0 deletions skyportal/tests/frontend/test_gcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest
import time
import uuid
import requests

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
Expand All @@ -13,6 +14,17 @@

cfg = load_config()

tach_isonline = False
try:
response = requests.get(
"https://heasarc.gsfc.nasa.gov/wsgi-scripts/tach/gcn_v2/tach.wsgi/", timeout=5
)
response.raise_for_status()
except Exception:
pass
else:
tach_isonline = True


def get_summary(driver, user, group, showSources, showGalaxies, showObservations):
driver.get(f'/become_user/{user.id}')
Expand Down Expand Up @@ -57,6 +69,7 @@ def get_summary(driver, user, group, showSources, showGalaxies, showObservations


@pytest.mark.flaky(reruns=3)
@pytest.mark.skipif(not tach_isonline, reason="GCN TACH is not online")
def test_gcn_tach(
driver,
super_admin_user,
Expand Down
2 changes: 1 addition & 1 deletion static/js/components/Notes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Notes = () => {
useEffect(() => {
const uniqueNotes = new Set(
[...notes, ...NotesState].filter(
(note) => !note.note.includes("No WebSocket connection"),
(note) => !note.note?.includes("No WebSocket connection"),
),
);
setNotes([...uniqueNotes]);
Expand Down

0 comments on commit fff6294

Please sign in to comment.