Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fractalis
fractalis
Commits
9a4a481a
Commit
9a4a481a
authored
Sep 15, 2017
by
Sascha Herzinger
Browse files
Added 'SUBMITTED' state to separate running from deleted tasks
parent
018548e8
Pipeline
#2340
failed with stage
in 11 minutes and 50 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
fractalis/celeryapp.py
View file @
9a4a481a
...
...
@@ -3,7 +3,8 @@ Celery instance."""
import
logging
from
celery
import
Celery
from
celery
import
Celery
,
current_app
from
celery.signals
import
after_task_publish
from
flask
import
Flask
from
fractalis.analytics.task
import
AnalyticTask
...
...
@@ -14,6 +15,18 @@ from fractalis.utils import list_classes_with_base_class
logger
=
logging
.
getLogger
(
__name__
)
# https://stackoverflow.com/questions/9824172/find-out-whether-celery-task-exists
@
after_task_publish
.
connect
def
update_submitted_state
(
sender
=
None
,
**
kwargs
):
"""Add 'SUBMITTED' state to celery task."""
# the task may not exist if sent using `send_task` which
# sends tasks by name, so fall back to the default result backend
# if that is the case.
task
=
current_app
.
tasks
.
get
(
sender
)
backend
=
task
.
backend
if
task
else
current_app
.
backend
backend
.
store_result
(
kwargs
[
'headers'
][
'id'
],
None
,
"SUBMITTED"
)
def
make_celery
(
app
:
Flask
)
->
Celery
:
"""Create a celery instance which executes its tasks in the application
context of our service.
...
...
tests/functional/test_analytics.py
View file @
9a4a481a
...
...
@@ -175,7 +175,7 @@ class TestAnalytics:
assert
new_response
.
status_code
==
200
new_body
=
flask
.
json
.
loads
(
new_response
.
get_data
())
assert
not
new_body
[
'result'
]
assert
new_body
[
'state'
]
==
'
PENDING
'
assert
new_body
[
'state'
]
==
'
SUBMITTED
'
def
test_correct_response_if_task_fails
(
self
,
test_client
):
rv
=
test_client
.
post
(
'/analytics'
,
data
=
flask
.
json
.
dumps
(
dict
(
...
...
tests/functional/test_data.py
View file @
9a4a481a
...
...
@@ -231,7 +231,7 @@ class TestData:
for
data_state
in
body
[
'data_states'
]:
assert
'file_path'
not
in
data_state
assert
'meta'
not
in
data_state
assert
data_state
[
'etl_state'
]
==
'
PENDING
'
assert
data_state
[
'etl_state'
]
==
'
SUBMITTED
'
assert
not
data_state
[
'etl_message'
]
assert
data_state
[
'data_type'
]
==
'mock'
assert
not
data_state
[
'loaded'
]
...
...
tests/functional/test_session.py
View file @
9a4a481a
"""This module provides tests for the session interface of Fractalis."""
from
uuid
import
UUID
from
time
import
sleep
...
...
@@ -8,7 +9,7 @@ from redis import StrictRedis
# noinspection PyMissingOrEmptyDocstring,PyMissingTypeHints
class
TestSession
(
object
)
:
class
TestSession
:
@
pytest
.
fixture
(
scope
=
'module'
)
def
app
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment