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
386ef74e
Commit
386ef74e
authored
1 year ago
by
Geoffrey Mo
Browse files
Options
Downloads
Patches
Plain Diff
Add unit test for check_vector retry
parent
00e0c6d0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gwcelery/tasks/detchar.py
+1
-1
1 addition, 1 deletion
gwcelery/tasks/detchar.py
gwcelery/tests/test_tasks_detchar.py
+19
-0
19 additions, 0 deletions
gwcelery/tests/test_tasks_detchar.py
with
20 additions
and
1 deletion
gwcelery/tasks/detchar.py
+
1
−
1
View file @
386ef74e
...
...
@@ -459,7 +459,7 @@ def check_vectors(self, event, graceid, start, end):
except
ValueError
as
exc
:
# check_vector likely failed to find the requested data
# in the cache because it has yet to arrive
raise
self
.
retry
(
exc
=
exc
,
max_retries
=
3
)
raise
self
.
retry
(
exc
=
exc
,
max_retries
=
4
)
# Pick out DQ and injection states, then filter for active detectors
dq_states
=
{
key
:
value
for
key
,
value
in
states
.
items
()
if
key
.
split
(
'
_
'
)[
-
1
]
!=
'
INJ
'
}
...
...
This diff is collapsed.
Click to expand it.
gwcelery/tests/test_tasks_detchar.py
+
19
−
0
View file @
386ef74e
...
...
@@ -4,6 +4,7 @@ from pathlib import Path
from
unittest.mock
import
call
,
patch
from
astropy.time
import
Time
import
celery
from
gwpy.timeseries
import
Bits
import
matplotlib.pyplot
as
plt
import
numpy
as
np
...
...
@@ -324,6 +325,24 @@ def test_check_vectors_fails(
mock_remove_label
.
assert_called_with
(
'
DQOK
'
,
'
S12345a
'
)
@patch
(
'
gwcelery.tasks.gracedb.upload.run
'
)
@patch
(
'
celery.app.task.Task.request
'
)
@patch
(
'
gwcelery.tasks.detchar.check_vector
'
,
side_effect
=
ValueError
)
def
test_check_vectors_retries_on_valueerror
(
mock_check_vector
,
mock_request
,
mock_upload
,
llhoft_glob_pass
,
ifo_h1
,
ifo_h1_idq
):
# Mocking this retry https://docs.celeryq.dev/en/stable/_modules/celery/app/task.html#Task.retry # noqa E501
event
=
{
'
search
'
:
'
AllSky
'
,
'
instruments
'
:
'
L1
'
,
'
pipeline
'
:
'
oLIB
'
}
superevent_id
=
'
S12345a
'
start
,
end
=
1216577978
,
1216577978.1
mock_request
.
called_directly
=
False
mock_request
.
retries
=
3
with
pytest
.
raises
(
celery
.
exceptions
.
Retry
)
as
retry_exc
:
detchar
.
check_vectors
.
delay
(
event
,
superevent_id
,
start
,
end
)
# after three retries, should still retry once in 5 seconds
assert
retry_exc
.
value
.
when
==
5
@patch
(
'
gwcelery.tasks.detchar.dqr_json
'
,
return_value
=
'
dqrjson
'
)
@patch
(
'
gwcelery.tasks.gracedb.upload.run
'
)
@patch
(
'
gwcelery.tasks.gracedb.remove_label
'
)
...
...
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