Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gwcelery
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
emfollow
gwcelery
Commits
e3fd45ab
Commit
e3fd45ab
authored
2 years ago
by
Cody Messick
Browse files
Options
Downloads
Patches
Plain Diff
Add temporary fix to igwn_alert task
parent
f7db3ba4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!887
Add temporary fix to igwn_alert task
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gwcelery/tasks/igwn_alert.py
+8
-1
8 additions, 1 deletion
gwcelery/tasks/igwn_alert.py
gwcelery/tests/test_tasks_igwn_alert.py
+19
-4
19 additions, 4 deletions
gwcelery/tests/test_tasks_igwn_alert.py
pyproject.toml
+1
-1
1 addition, 1 deletion
pyproject.toml
with
28 additions
and
6 deletions
gwcelery/tasks/igwn_alert.py
+
8
−
1
View file @
e3fd45ab
"""
IGWN alert client.
"""
import
json
from
celery.utils.log
import
get_task_logger
from
..igwn_alert.signals
import
igwn_alert_received
...
...
@@ -18,7 +20,12 @@ class _IGWNAlertDispatchHandler(DispatchHandler):
igwn_alert_topics
.
update
(
keys
)
return
super
().
__call__
(
*
keys
,
**
kwargs
)
def
process_args
(
self
,
topic
,
alert
):
def
process_args
(
self
,
topic
,
message
):
# FIXME: Loading the message with json.loads() is a change required
# because we are using a newer version of hop-client than IGWN-Alert
# is, once IGWN-Alert upgrades to the newest version the message may
# become a dictionary once again
alert
=
json
.
loads
(
message
.
content
)
# Determine GraceDB service URL
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
gwcelery/tests/test_tasks_igwn_alert.py
+
19
−
4
View file @
e3fd45ab
...
...
@@ -3,7 +3,7 @@ import json
import
logging
import
os
import
stat
from
unittest.mock
import
patch
from
unittest.mock
import
Mock
,
patch
import
lxml
import
pytest
...
...
@@ -54,7 +54,12 @@ def test_handle_messages(mock_superevents_handle, mock_get_event,
alert
[
'
object
'
][
'
self
'
].
replace
(
'
gracedb.ligo.org
'
,
'
gracedb.invalid
'
)
# Run function under test
igwn_alert
.
handler
.
dispatch
(
node
,
alert
)
# FIXME: We need to mock the content attribute of a JSONBlob because we
# IGWN-Alert does not yet use hop-client 0.6.0. Once IGWN-Alert updates
# that dep we will probably be able to drop this mock
mock_message
=
Mock
()
mock_message
.
content
=
json
.
dumps
(
alert
)
igwn_alert
.
handler
.
dispatch
(
node
,
mock_message
)
mock_superevents_handle
.
assert_called_once
()
...
...
@@ -72,8 +77,13 @@ def test_handle_messages_wrong_server(mock_superevents_handle,
alert
[
'
object
'
][
'
self
'
].
replace
(
'
gracedb.ligo.org
'
,
'
gracedb2.invalid
'
)
# Run function under test
# FIXME: We need to mock the content attribute of a JSONBlob because we
# IGWN-Alert does not yet use hop-client 0.6.0. Once IGWN-Alert updates
# that dep we will probably be able to drop this mock
mock_message
=
Mock
()
mock_message
.
content
=
json
.
dumps
(
alert
)
caplog
.
set_level
(
logging
.
WARNING
)
igwn_alert
.
handler
.
dispatch
(
node
,
alert
)
igwn_alert
.
handler
.
dispatch
(
node
,
mock_message
)
record
,
*
_
=
caplog
.
records
assert
record
.
message
==
(
'
ignoring IGWN alert message because it is
'
'
intended for GraceDB server
'
...
...
@@ -95,8 +105,13 @@ def test_handle_messages_no_self_link(mock_superevents_handle,
del
alert
[
'
object
'
][
'
self
'
]
# Run function under test
# FIXME: We need to mock the content attribute of a JSONBlob because we
# IGWN-Alert does not yet use hop-client 0.6.0. Once IGWN-Alert updates
# that dep we will probably be able to drop this mock
mock_message
=
Mock
()
mock_message
.
content
=
json
.
dumps
(
alert
)
caplog
.
set_level
(
logging
.
ERROR
)
igwn_alert
.
handler
.
dispatch
(
node
,
alert
)
igwn_alert
.
handler
.
dispatch
(
node
,
mock_message
)
record
,
=
caplog
.
records
assert
'
IGWN alert message does not contain an API URL
'
in
record
.
message
mock_superevents_handle
.
assert_not_called
()
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
1
View file @
e3fd45ab
...
...
@@ -59,7 +59,7 @@ gracedb-sdk = ">=0.1.5"
gwdatafind
=
">
=
1.1
.
1
"
gwpy
=
">
=
2.0
.
1
" # https://github.com/gwpy/gwpy/issues/1277
healpy
=
"*"
igwn-alert
=
"
*
"
igwn-alert
=
"
0.2.1
"
imapclient
=
"*"
importlib-metadata
=
{
version
=
"*"
,
python
=
"<3.8"
}
jinja2
=
">
=
2.11
.
2
" # https://github.com/pallets/jinja/issues/1168
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment